Skip to content

updated new version #31

updated new version

updated new version #31

Workflow file for this run

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: 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 -f 4 \
"app/build/outputs/apk/release/app-release-unsigned.apk" \
"app/build/outputs/apk/release/app-release-aligned.apk"
if [ ! -f "app/build/outputs/apk/release/app-release-aligned.apk" ]; then
echo "Error: Failed to create aligned APK"
exit 1
fi
- 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..."
${ANDROID_HOME}/build-tools/30.0.3/apksigner sign \
--ks release.keystore \
--ks-pass pass:"${KEYSTORE_PASSWORD}" \
--ks-key-alias "${KEY_ALIAS}" \
--key-pass pass:"${KEY_PASSWORD}" \
--v2-signing-enabled true \
--v3-signing-enabled true \
--v4-signing-enabled false \
--out "app/build/outputs/apk/release/app-release.apk" \
"app/build/outputs/apk/release/app-release-aligned.apk"
echo "Verifying signed APK..."
${ANDROID_HOME}/build-tools/30.0.3/apksigner verify --verbose "app/build/outputs/apk/release/app-release.apk"
- 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