Files
hapi/.github/workflows/android-release.yml
T

76 lines
3.1 KiB
YAML

name: Android Official Build
on:
workflow_dispatch:
inputs:
version_code:
description: 'Increasing Android versionCode (positive integer)'
required: true
type: string
version_name:
description: 'Release versionName, e.g. 0.28.0'
required: true
type: string
permissions:
contents: read
concurrency:
group: android-official-build
cancel-in-progress: false
jobs:
build:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
defaults:
run:
working-directory: android
env:
HAPI_FIREBASE_PROJECT_ID: ${{ vars.ANDROID_FIREBASE_PROJECT_ID }}
HAPI_VERSION_CODE: ${{ inputs.version_code }}
HAPI_VERSION_NAME: ${{ inputs.version_name }}
HAPI_UPLOAD_KEYSTORE_PASSWORD: ${{ secrets.HAPI_UPLOAD_KEYSTORE_PASSWORD }}
HAPI_UPLOAD_KEY_ALIAS: ${{ secrets.HAPI_UPLOAD_KEY_ALIAS }}
HAPI_UPLOAD_KEY_PASSWORD: ${{ secrets.HAPI_UPLOAD_KEY_PASSWORD }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- uses: gradle/actions/setup-gradle@v4
- name: Install official client configuration and signing key
env:
GOOGLE_SERVICES_JSON: ${{ secrets.ANDROID_GOOGLE_SERVICES_JSON }}
UPLOAD_KEYSTORE_BASE64: ${{ secrets.HAPI_UPLOAD_KEYSTORE_BASE64 }}
run: |
set -euo pipefail
test -n "$GOOGLE_SERVICES_JSON"
test -n "$UPLOAD_KEYSTORE_BASE64"
test -n "$HAPI_FIREBASE_PROJECT_ID"
umask 077
HAPI_UPLOAD_KEYSTORE="$RUNNER_TEMP/hapi-upload.keystore"
printf '%s' "$GOOGLE_SERVICES_JSON" > app/google-services.json
printf '%s' "$UPLOAD_KEYSTORE_BASE64" | base64 --decode > "$HAPI_UPLOAD_KEYSTORE"
printf '%s\n' "HAPI_UPLOAD_KEYSTORE=$HAPI_UPLOAD_KEYSTORE" >> "$GITHUB_ENV"
- name: Test and build signed APK and AAB
run: |
./gradlew \
-PhapiOfficialBuild=true \
-PhapiFirebaseProjectId="$HAPI_FIREBASE_PROJECT_ID" \
-PhapiVersionCode="$HAPI_VERSION_CODE" \
-PhapiVersionName="$HAPI_VERSION_NAME" \
:core:protocol:test :core:data:testDebugUnitTest :app:testDebugUnitTest \
:app:assembleRelease :app:bundleRelease
- uses: actions/upload-artifact@v4
with:
name: hapi-android-${{ inputs.version_code }}
if-no-files-found: error
path: |
android/app/build/outputs/apk/release/*.apk
android/app/build/outputs/bundle/release/*.aab
- name: Remove build credentials
if: always()
run: rm -f app/google-services.json "$RUNNER_TEMP/hapi-upload.keystore"