Build APK #12
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 APK | |
on: | |
workflow_dispatch: | |
inputs: | |
buildType: | |
type: choice | |
required: true | |
default: "debug" | |
description: "Build Type" | |
options: | |
- "debug" | |
- "release" | |
release: | |
type: boolean | |
description: "Release built APKs" | |
tag: | |
type: string | |
description: "Tag for the release" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup environment | |
working-directory: ./app | |
env: | |
ENCODED_STRING: ${{ secrets.KEYSTORE }} | |
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }} | |
run: | | |
echo $GOOGLE_SERVICES > google-services.json | |
echo $ENCODED_STRING | base64 --decode > keystore.jks | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
cache: "gradle" | |
java-version: "17" | |
distribution: "temurin" | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Build APK | |
env: | |
BUILD_TYPE: ${{ github.event.inputs.buildType }} | |
KEYSTORE_ALIAS: ${{ secrets.KEYSTORE_ALIAS }} | |
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | |
run: | | |
if [ "$BUILD_TYPE" = "release" ]; then | |
./gradlew assembleRelease | |
mv app/build/outputs/apk/release/*.apk . | |
elif [ "$BUILD_TYPE" = "debug" ]; then | |
./gradlew assembleDebug | |
mv app/build/outputs/apk/debug/*.apk . | |
fi | |
- name: Upload APK artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Build output | |
path: ./*.apk | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event.inputs.buildType == 'release' && github.event.inputs.release == 'true' && startsWith(github.event.inputs.tag, 'v') | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Fetch APKs | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./ | |
merge-multiple: true | |
- name: Create new tag | |
run: | | |
git tag "${{ github.event.inputs.tag }}" | |
git push --tags | |
- name: Create release | |
uses: softprops/action-gh-release@v2 | |
with: | |
draft: true | |
files: "*.apk" | |
generate_release_notes: true |