Skip to content

Commit

Permalink
feat: Use keystore for pushes
Browse files Browse the repository at this point in the history
Pull request app will not be signed
Push to repository bransh will only sign apk
  • Loading branch information
SyntaxGalaxy committed Aug 5, 2023
1 parent f84d803 commit 4e672fb
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 24 deletions.
32 changes: 8 additions & 24 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,6 @@ name: Android CI

on:
push:
branches:
- main
paths:
- '.github/**'
- 'app/**'
- 'editor/**'
- 'gradle/**'
- 'gradle.properties'
- 'gradlew'
- 'settings.gradle'
pull_request:
branches:
- main
paths:
- '.github/**'
- 'app/**'
- 'editor/**'
- 'gradle/**'
- 'build.gradle'
- 'gradle.properties'
- 'gradlew'
- 'settings.gradle'
workflow_dispatch:

jobs:
buildApkFile:
Expand All @@ -45,6 +22,13 @@ jobs:

- name: Allow gradlew permission
run: chmod +x ./gradlew

- name: Set environmental variables
shell: bash
env:
JSON_CONTENT: ${{ secrets.KEYSTOREPASSWORD }}
run: |
printf 'KEYSTOREPASSWORD<<EOF\n%s\nEOF\n' "$JSON_CONTENT" >> $GITHUB_ENV
- name: Build debug APK
run: ./gradlew assembleDebug --warning-mode all
Expand All @@ -58,4 +42,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: Editor Debug Aar
path: editor/build/outputs/aar/editor-debug.aar
path: editor/build/outputs/aar/editor-debug.aar
38 changes: 38 additions & 0 deletions .github/workflows/android_pull_req.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: GPL-3.0-only
# Original at https://github.com/tyron12233/CodeAssist/blob/main/.github/workflows/build-apk.yml
# Changes: Minor adjustments, removal of Cancel previous runs step, but every change can be found with a simple diff.

name: Android CI[PR]

on:
pull_request:

jobs:
buildApkFile:
name: Build Debug APK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin

- name: Allow gradlew permission
run: chmod +x ./gradlew

- name: Build debug APK
run: ./gradlew assembleDebug --warning-mode all

- name: Upload debug APK
uses: actions/upload-artifact@v3
with:
name: Android Code Editor Debug Apk
path: app/build/outputs/apk/debug
- name: Upload editor aar debug
uses: actions/upload-artifact@v3
with:
name: Editor Debug Aar
path: editor/build/outputs/aar/editor-debug.aar
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
.gradle
app/build
editor/build
secrets.properties
treeview/build
app/src/main/java/android/code/editor/SketchLogger.java
40 changes: 40 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@ plugins {
id 'com.android.application'
}

def KEYSTOREPASSWORD = System.getenv('KEYSTOREPASSWORD')
def secretsPropertiesFile = file('../secrets.properties')
def secretsProperties = new Properties()

if (secretsPropertiesFile.exists()) {
secretsProperties.load(new FileInputStream(secretsPropertiesFile))
}

def signingEnabled = false
def password = ""

if (KEYSTOREPASSWORD != "") {
password = KEYSTOREPASSWORD
signingEnabled = true
} else if (secretsPropertiesFile.exists()) {
if (secretsProperties.getProperty('keyStorePassword') != null) {
password = secretsProperties.getProperty('keyStorePassword')
signingEnabled = true
}
}

android {
compileSdk 32
buildToolsVersion "33.0.2"
Expand Down Expand Up @@ -40,6 +61,25 @@ android {
buildFeatures {
viewBinding true
}

signingConfigs {
release {
if (signingEnabled) {
storeFile file("../keystore.jks")
storePassword password
keyAlias "AndroidCodeEditor"
keyPassword password
}
}
debug {
if (signingEnabled) {
storeFile file("../keystore.jks")
storePassword password
keyAlias "AndroidCodeEditor"
keyPassword password
}
}
}
}

dependencies {
Expand Down
Binary file added keystore.jks
Binary file not shown.

0 comments on commit 4e672fb

Please sign in to comment.