Skip to content

Commit

Permalink
Create manual-apk-release.yml (#3003)
Browse files Browse the repository at this point in the history
* Create manual-apk-release.yml
* Integrate Vault secrets
* Manual APK release CI scripting logic 👷
---------

Co-authored-by: bonfaceshisakha <[email protected]>
  • Loading branch information
ndegwamartin and bonfaceshisakha authored Feb 23, 2024
1 parent 8e97b0e commit fd7622e
Showing 1 changed file with 111 additions and 0 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/manual-apk-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Manual APK Release
run-name: Generating a FHIR Core Release APK 🚀
on:
workflow_dispatch:
inputs:
buildType:
description: 'Select APK Build Type'
required: true
default: 'Release'
type: choice
options:
- Debug
- DebugNonProxy
- Release
flavor:
description: 'APK flavor e.g. sidBunda'
required: true
isAab:
description: 'For Playstore release only. Generates AAB'
required: true
default: false
jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
- name: Import Secrets from Vault
id: import-secrets
uses: hashicorp/[email protected]
with:
url: https://vault.onalabs.org
token: ${{ secrets.VAULT_TOKEN }}
# caCertificate: ${{ secrets.VAULT_CA_CERT }}
tlsSkipVerify: true
secrets: |
kv-v2-fhircore/data/fhircore_apk_credentials KEYSTORE_ALIAS | KEYSTORE_ALIAS;
kv-v2-fhircore/data/fhircore_apk_credentials KEYSTORE_FILE | KEYSTORE_FILE;
kv-v2-fhircore/data/fhircore_apk_credentials KEYSTORE_PASSWORD | KEYSTORE_PASSWORD;
kv-v2-fhircore/data/fhircore_apk_credentials KEY_PASSWORD | KEY_PASSWORD;
kv-v2-fhircore/data/fhircore_apk_credentials LOCAL_PROPERTIES_FILE | LOCAL_PROPERTIES_FILE;
- name: Test secret from Vault
id: test-secret
run: |
touch secrets.json
echo '${{ toJson(steps.import-secrets.outputs)}}' >> secrets.json
cat secrets.json
- name: Decode & Generate Keystore file
run: echo $ENCODED_KEYSTORE | base64 -di > "${HOME}"/fhircore.keystore.jks
env:
ENCODED_KEYSTORE: ${{ secrets.KEYSTORE_FILE }}

- name: Checkout 🛎️
uses: actions/checkout@v2
with:
fetch-depth: 2

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: android

- name: Decode & Generate local.properties file
run: echo $LOCAL_PROPERTIES | base64 -di > local.properties
working-directory: android
env:
LOCAL_PROPERTIES: ${{ secrets.LOCAL_PROPERTIES_FILE }}

- name: Decode & Generate keystore.properties file
run: echo $KEYSTORE_PROPERTIES | base64 -di > keystore.properties
working-directory: android
env:
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_FILE }}

- id: product-flavor
name: Generate Product Flavor identifier
run: |
id=$(echo ${{ github.event.inputs.flavor }}${{ github.event.inputs.buildType }} | tr [:upper:] [:lower:])
echo "::set-output name=id::$id"
- name: Generate AAB (Android App Bundle) file
if: ${{ github.event.inputs.isAab }}
run: ./gradlew :quest:bundle${{github.event.inputs.flavor}}${{github.event.inputs.buildType}} -x :quest:test${{github.event.inputs.flavor}}${{github.event.inputs.buildType}}DebugUnitTest --stacktrace
working-directory: android

- name: Upload AAB file to tag assets
if: ${{ github.event.inputs.isAab }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: android/quest/build/outputs/bundle/${{steps.product-flavor.outputs.id}}/release/quest-${{steps.product-flavor.outputs.id}}-release.aab
asset_name: "$tag.aab"
tag: ${{ github.ref }}
overwrite: true

- name: Generate APK (Android App PacKage) file
if: ${{ github.event.inputs.isAab != true }}
run: ./gradlew :quest:assemble${{github.event.inputs.flavor}}${{github.event.inputs.buildType}} -x :quest:test${{github.event.inputs.flavor}}${{github.event.inputs.buildType}}DebugUnitTest --stacktrace
working-directory: android

- name: Test APK file generation
run: |
ls -lha android/quest/build/outputs/apk/${{steps.product-flavor.outputs.id}}/release/quest-${{steps.product-flavor.outputs.id}}-release.apk --stacktrace

0 comments on commit fd7622e

Please sign in to comment.