Skip to content

Commit

Permalink
separate key per flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
kid1412621 committed May 7, 2024
1 parent 5a60267 commit 90def10
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ on:
- '*'

env:
PROD_RELEASE_CI: true
PROD_RELEASE: true

jobs:
build_release_github:
environment: production
env:
FLAVOR: github
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -23,13 +25,13 @@ jobs:
- name: Generate keystore.properties
run: |
cat <<EOF > keystore.properties
storeFile:${{ vars.KEYSTORE_STORE_FILE_PATH }}
storePassword:${{ secrets.KEYSTORE_STORE_PASSWORD }}
keyAlias:${{ secrets.KEYSTORE_KEY_ALIAS }}
keyPassword:${{ secrets.KEYSTORE_KEY_PASSWORD }}
storeFile:${{ vars.GH_KEYSTORE_STORE_FILE_PATH }}
storePassword:${{ secrets.GH_KEYSTORE_STORE_PASSWORD }}
keyAlias:${{ secrets.GH_KEYSTORE_KEY_ALIAS }}
keyPassword:${{ secrets.GH_KEYSTORE_KEY_PASSWORD }}
EOF
- name: Generate keystore.jks
run: echo "${{ secrets.KEYSTORE_JKS_BASE64 }}" | base64 --decode > keystore.jks
run: echo "${{ secrets.GH_KEYSTORE_JKS_BASE64 }}" | base64 --decode > keystore.jks
- name: Generate google-services.json
run: echo "${{ secrets.GOOGLE_SERVICES_BASE64 }}" | base64 --decode > app/google-services.json
- name: Grant execute permission for gradlew
Expand All @@ -46,13 +48,15 @@ jobs:
- name: Publish APK on Github Release
uses: softprops/action-gh-release@v2
with:
files: app/build/outputs/apk/release/app-release.apk
files: app/build/outputs/apk/$FLAVOR/release/app-$FLAVOR-release.apk
generate_release_notes: true
append_body: true
body: ${{ env.RELEASE_NOTE }}

build_release_google_play:
environment: production
env:
FLAVOR: play
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -65,13 +69,13 @@ jobs:
- name: Generate keystore.properties
run: |
cat <<EOF > keystore.properties
storeFile:${{ vars.KEYSTORE_STORE_FILE_PATH }}
storePassword:${{ secrets.KEYSTORE_STORE_PASSWORD }}
keyAlias:${{ secrets.KEYSTORE_KEY_ALIAS }}
keyPassword:${{ secrets.KEYSTORE_KEY_PASSWORD }}
storeFile:${{ vars.PLAY_KEYSTORE_STORE_FILE_PATH }}
storePassword:${{ secrets.PLAY_KEYSTORE_STORE_PASSWORD }}
keyAlias:${{ secrets.PLAY_KEYSTORE_KEY_ALIAS }}
keyPassword:${{ secrets.PLAY_KEYSTORE_KEY_PASSWORD }}
EOF
- name: Generate keystore.jks
run: echo "${{ secrets.KEYSTORE_JKS_BASE64 }}" | base64 --decode > keystore.jks
run: echo "${{ secrets.PLAY_KEYSTORE_JKS_BASE64 }}" | base64 --decode > keystore.jks
- name: Generate google-services.json
run: echo "${{ secrets.GOOGLE_SERVICES_BASE64 }}" | base64 --decode > app/google-services.json
- name: Grant execute permission for gradlew
Expand All @@ -82,5 +86,5 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: subspace
path: app/build/outputs/bundle/release/app-release.aab
path: app/build/outputs/apk/$FLAVOR/release/app-$FLAVOR-release.aab

6 changes: 3 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ android {
}
}

val isProdReleaseCI = System.getenv("PROD_RELEASE_CI")?.toBoolean() ?: false
val isProdRelease = System.getenv("PROD_RELEASE")?.toBoolean() ?: false

signingConfigs {
fun buildSignConfig(apkSigningConfig: ApkSigningConfig) {
val keystorePropertiesFile = rootProject.file("keystore.properties")
if (isProdReleaseCI) {
if (isProdRelease) {
val keystoreProperties = Properties()
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
keystoreProperties.let {
Expand Down Expand Up @@ -89,7 +89,7 @@ android {
onVariants { variant ->
val googleTask =
tasks.findByName("process${variant.name.replaceFirstChar(Char::uppercase)}GoogleServices")
googleTask?.enabled = isProdReleaseCI && "debug" != variant.buildType
googleTask?.enabled = isProdRelease && "debug" != variant.buildType
}
}

Expand Down

0 comments on commit 90def10

Please sign in to comment.