update #20
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Jetpack Compose App | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Setup Android SDK | |
uses: android-actions/setup-android@v3 | |
- name: Install build tools | |
run: | | |
echo "y" | sudo ${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager --install "build-tools;30.0.3" | |
echo "Build tools installed at: ${ANDROID_HOME}/build-tools/30.0.3" | |
ls -la ${ANDROID_HOME}/build-tools/30.0.3 | |
- name: Decode and save keystore file | |
env: | |
KEYSTORE_FILE: ${{ secrets.SIGNING_KEY }} | |
run: | | |
if [ -z "$KEYSTORE_FILE" ]; then | |
echo "Error: SIGNING_KEY secret is not set" | |
exit 1 | |
fi | |
echo "$KEYSTORE_FILE" | base64 --decode > release.keystore | |
if [ ! -f release.keystore ]; then | |
echo "Error: Failed to create keystore file" | |
exit 1 | |
fi | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Build release APK | |
run: ./gradlew assembleRelease | |
- name: Sign and verify APK | |
env: | |
KEYSTORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }} | |
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
run: | | |
if [ -z "$KEYSTORE_PASSWORD" ] || [ -z "$KEY_ALIAS" ] || [ -z "$KEY_PASSWORD" ]; then | |
echo "Error: One or more signing secrets are not set" | |
echo "Required secrets: KEY_STORE_PASSWORD, KEY_ALIAS, KEY_PASSWORD" | |
exit 1 | |
fi | |
echo "Signing APK..." | |
jarsigner \ | |
-verbose \ | |
-sigalg SHA256withRSA \ | |
-digestalg SHA-256 \ | |
-keystore release.keystore \ | |
-storepass "${KEYSTORE_PASSWORD}" \ | |
-keypass "${KEY_PASSWORD}" \ | |
"app/build/outputs/apk/release/app-release-unsigned.apk" \ | |
"${KEY_ALIAS}" | |
echo "Verifying signed APK..." | |
jarsigner -verify -verbose -certs "app/build/outputs/apk/release/app-release-unsigned.apk" | |
- name: Align APK | |
run: | | |
if [ ! -f "app/build/outputs/apk/release/app-release-unsigned.apk" ]; then | |
echo "Error: Unsigned APK not found" | |
exit 1 | |
fi | |
echo "Android SDK location: $ANDROID_HOME" | |
echo "Available build tools:" | |
ls -la ${ANDROID_HOME}/build-tools/ | |
${ANDROID_HOME}/build-tools/30.0.3/zipalign -v 4 \ | |
"app/build/outputs/apk/release/app-release-unsigned.apk" \ | |
"app/build/outputs/apk/release/app-release.apk" | |
if [ ! -f "app/build/outputs/apk/release/app-release.apk" ]; then | |
echo "Error: Failed to create aligned APK" | |
exit 1 | |
fi | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
files: app/build/outputs/apk/release/app-release.apk | |
generate_release_notes: true | |
draft: false | |
prerelease: false | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: app-release | |
path: app/build/outputs/apk/release/app-release.apk | |
if-no-files-found: error |