Skip to content

Commit

Permalink
Build Android release whenever the app changes
Browse files Browse the repository at this point in the history
Also:
- Produce a universal APK
- Upload that APK to the build artifacts
- If this is a release add that APK to the release also

This resolves #140. Thanks to bartekpacia@ for the initial commit.
  • Loading branch information
chromy committed Oct 16, 2024
1 parent 8a31ead commit 31f75c1
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions .github/workflows/android_release_build.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
name: Android Release Build

on:
push:
branches: [ main ]
tags: [ '*' ]
pull_request:
branches: [ main ]
paths: [ android/** ]
release:
types: [ published ]

jobs:
build:
runs-on: ubuntu-latest

# Only run when the tag begins with the string "android-"
if: ${{ startsWith(github.event.release.tag_name, 'android-') }}

defaults:
run:
working-directory: ./android
Expand Down Expand Up @@ -45,17 +48,47 @@ jobs:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
run: ./gradlew :app:bundleRelease

- name: Convert AAB to APK
uses: mukeshsolanki/[email protected]
with:
aabFile: app/build/outputs/bundle/release/app-release.aab
base64Keystore: ${{ secrets.ANDROID_RELEASE_KEYSTORE_BASE64 }}
keystoreAlias: ${{ secrets.ANDROID_RELEASE_KEY_ALIAS }}
keyPassword: ${{ secrets.ANDROID_RELEASE_KEY_PASSWORD }}
keystorePassword: ${{ secrets.ANDROID_RELEASE_STORE_PASSWORD }}
bundletoolVersion: '1.9.0'

- uses: actions/upload-artifact@v3
with:
name: release-apk
path: ${{ steps.convert_aab.outputs.apkPath }}

# All the below should only run if we are doing a release.

- name: Add APK to GitHub release
uses: softprops/action-gh-release@v2
if: ${{ startsWith(github.event.release.tag_name, 'android-') }}
with:
name: ${{ github.ref_name }}
fail_on_unmatched_files: true
# see https://github.com/softprops/action-gh-release/issues/158
files: |
${{ steps.convert_aab.outputs.apkPath }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
if: ${{ startsWith(github.event.release.tag_name, 'android-') }}
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-west-1

- name: Extract version from tag
if: ${{ startsWith(github.event.release.tag_name, 'android-') }}
run: echo "VERSION_NAME=$(echo ${{ github.event.release.tag_name }} | sed 's/android-//')" >> $GITHUB_ENV

- name: Upload AAB to S3
if: ${{ startsWith(github.event.release.tag_name, 'android-') }}
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down

0 comments on commit 31f75c1

Please sign in to comment.