Skip to content

Commit

Permalink
Add release signing
Browse files Browse the repository at this point in the history
  • Loading branch information
ianfixes committed Dec 28, 2024
1 parent e645a92 commit a74c9fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ env:
APK_DEBUG: "app/build/outputs/apk/debug/app-debug.apk"
APK_RELEASE: "app/build/outputs/apk/release/app-release-unsigned.apk"
ARTIFACT_ROOT: "app/build/outputs"
ANDROID_KEY_ALIAS: ${{ secrets.ANDROID_KEY_ALIAS }}
ANDROID_KEYSTORE_PASSWORD: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}

jobs:
lint:
Expand Down Expand Up @@ -49,10 +51,15 @@ jobs:
with:
name: ${{ env.APP_TITLE }}-debug.apk
path: ${{ env.ARTIFACT_ROOT }}/${{ env.APP_TITLE }}-debug.apk
- name: Decode keystore
run: |
echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > release-key.jks
- name: Build Release APK to make sure it works
run: ./gradlew assembleRelease
- name: Ensure release build is where we expect
run: ls -l ${{ env.APK_RELEASE }} || { find ${{ env.ARTIFACT_ROOT }} ; exit 1 ; }
- name: Verify APK signature
run: jarsigner -verify -verbose -certs ${{ env.APK_RELEASE }}

build-release:
name: Build Release APK
Expand All @@ -65,8 +72,13 @@ jobs:
with:
java-version: '17'
distribution: 'temurin'
- name: Decode keystore
run: |
echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 --decode > release-key.jks
- name: Build Release APK
run: ./gradlew assembleRelease
- name: Verify APK signature
run: jarsigner -verify -verbose -certs ${{ env.APK_RELEASE }}
- name: Rename APK
run: mv ${{ env.APK_RELEASE }} ${{ env.ARTIFACT_ROOT }}/${{ env.APP_TITLE }}-release.apk
- name: Upload Release APK to GitHub Releases
Expand All @@ -75,4 +87,3 @@ jobs:
files: ${{ env.ARTIFACT_ROOT }}/${{ env.APP_TITLE }}-release.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

12 changes: 11 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,18 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

signingConfigs {
release {
storeFile = file("release-key.jks")
storePassword = System.getenv("ANDROID_KEYSTORE_PASSWORD")
keyAlias = System.getenv("ANDROID_KEY_ALIAS")
keyPassword = System.getenv("ANDROID_KEYSTORE_PASSWORD") // Same password
}
}

buildTypes {
release {
signingConfig = signingConfigs.release
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
Expand Down Expand Up @@ -59,4 +69,4 @@ dependencies {
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}
}

0 comments on commit a74c9fa

Please sign in to comment.