Use Gradle #727
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: Make APKs CI | |
on: | |
workflow_dispatch: | |
push: | |
pull_request: | |
jobs: | |
Build-Apks: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-java@v3 | |
with: | |
distribution: 'zulu' # See 'Supported distributions' for available options | |
java-version: '17' | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Install FontForge | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install fontforge | |
- name: Restore debug keystore from GitHub Secrets | |
run: | | |
# Check if exist and use the secret named DEBUG_KEYSTORE | |
# The contents of the secret can be obtained - | |
# from the debug.keystore.asc from you local folder (refer to CONTRIBUTING.md#Using the local debug.keystore on the Github CI actions) | |
if [[ ! "${{ secrets.DEBUG_KEYSTORE }}" = "" ]]; then | |
echo "${{ secrets.DEBUG_KEYSTORE }}" > "debug.keystore.asc" | |
if [[ -s "debug.keystore.asc" ]]; then | |
echo "Restoring debug keystore from GitHub secrets" | |
gpg -d --passphrase "debug0" --batch "debug.keystore.asc" > "debug.keystore" | |
fi | |
fi | |
- name: Restore release keystore from GitHub Secrets | |
env: | |
RELEASE_KEYSTORE_RAW: ${{ secrets.RELEASE_KEYSTORE }} # Used for condition | |
RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }} | |
if: env.RELEASE_KEYSTORE_RAW != '' | |
run: | | |
# Check if exist and use the secret named RELEASE_KEYSTORE | |
# The contents of the secret can be obtained - | |
# from the release.keystore.asc from you local folder | |
if [[ ! "${{ secrets.RELEASE_KEYSTORE }}" = "" ]]; then | |
echo "${{ secrets.RELEASE_KEYSTORE }}" > "release.keystore.asc" | |
if [[ -s "release.keystore.asc" ]]; then | |
echo "Restoring release keystore from GitHub secrets" | |
# Passing secrets as arguments is not recommended since they could be observed by using 'ps' | |
gpg -d --passphrase "$RELEASE_KEYSTORE_PASSWORD" --batch "release.keystore.asc" > "release.keystore" | |
fi | |
fi | |
- name: Build debug APK | |
uses: gradle/gradle-build-action@v2 | |
env: | |
DEBUG_KEYSTORE: "../debug.keystore" | |
DEBUG_KEYSTORE_PASSWORD: debug0 | |
DEBUG_KEY_ALIAS: debug | |
DEBUG_KEY_PASSWORD: debug0 | |
with: | |
arguments: assembleDebug | |
- name: Build signed release APK | |
env: | |
RELEASE_KEYSTORE_RAW: ${{ secrets.RELEASE_KEYSTORE }} # Used for condition | |
RELEASE_KEYSTORE: "../release.keystore" | |
RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }} | |
RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }} | |
RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }} | |
if: ${{ env.RELEASE_KEYSTORE_RAW != '' }} | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: assembleRelease | |
- name: Artifact naming | |
run: | | |
artifact="${{github.repository_owner}} ${{github.ref_name}}" | |
artifact="${artifact//\//-}" # replace slashes | |
echo "artifact=${artifact}" >> $GITHUB_ENV | |
- name: Upload debug APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "${{env.artifact}} debug_apk" | |
path: app/build/outputs/apk/debug/*.apk | |
- name: Upload signed release APK | |
env: | |
RELEASE_KEYSTORE_RAW: ${{ secrets.RELEASE_KEYSTORE }} # Used for condition | |
if: ${{ env.RELEASE_KEYSTORE_RAW != '' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "${{env.artifact}} signed_release_apk" | |
path: app/build/outputs/apk/release/*.apk |