Build and Release APK #5
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: Build and Release Signed APK | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
- name: Decode and write keystore | |
run: echo ${{ secrets.KEYSTORE_FILE }} | base64 --decode > release.keystore | |
- name: Build Release APK | |
run: ./gradlew assembleRelease | |
env: | |
KEYSTORE_FILE: release.keystore | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | |
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | |
- name: Sign the APK | |
run: | | |
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 \ | |
-keystore $KEYSTORE_FILE \ | |
-storepass $KEYSTORE_PASSWORD \ | |
-keypass $KEY_PASSWORD \ | |
app/build/outputs/apk/release/app-release-unsigned.apk $KEY_ALIAS | |
- name: Verify the APK | |
run: | | |
jarsigner -verify -verbose -certs app/build/outputs/apk/release/app-release-unsigned.apk | |
- name: Zipalign the APK | |
run: | | |
${ANDROID_SDK_ROOT}/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 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Upload Release Asset | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: app/build/outputs/apk/release/app-release.apk | |
asset_name: app-release.apk | |
asset_content_type: application/vnd.android.package-archive | |