Tileset is a word lol #2158
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: Android | |
on: | |
pull_request: null | |
workflow_dispatch: | |
inputs: | |
myCommit: | |
description: Commit SHA1 | |
required: false | |
default: '' | |
type: string | |
releaseTag: | |
description: Release tag | |
required: false | |
default: '' | |
type: string | |
workflow_call: | |
inputs: | |
myCommit: | |
description: Commit SHA1 | |
required: false | |
default: '' | |
type: string | |
releaseTag: | |
description: Release tag | |
required: false | |
default: '' | |
type: string | |
push: null | |
release: | |
types: | |
- published | |
env: | |
# This version is referenced in android/openenroth/build.gradle. | |
# See https://developer.android.com/ndk/downloads for revision-to-version mapping. | |
# When updating the version here you should also update it in the Dependencies repo! | |
NDK_REVISION: r26d | |
jobs: | |
build_android: | |
timeout-minutes: 60 | |
name: Build Android Client | |
runs-on: ubuntu-22.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
configuration: | |
- Debug | |
- Release | |
# Magical: https://stackoverflow.com/questions/73630573/how-to-write-conditional-expressions-in-github-actions | |
architecture: ${{ fromJson('[["universal"], ["arm64-v8a", "armeabi-v7a", "x86_64"]]')[inputs.releaseTag == ''] }} | |
steps: | |
- name: Configure fast APT mirror | |
uses: vegardit/fast-apt-mirror.sh@v1 | |
with: # the following parameters are listed with their action default values and are optional | |
healthchecks: 10 # Number of mirrors from the mirrors list to check for availability and up-to-dateness | |
speedtests: 6 # Maximum number of healthy mirrors to test for speed | |
parallel: 2 # Number of parallel speed tests | |
sample-size: 1024 # Number of kilobytes to download during the speed from each mirror | |
sample-time: 3 # Maximum number of seconds within the sample download from a mirror must finish | |
- name: Checkout | |
uses: actions/checkout@v4.2.2 | |
with: | |
submodules: recursive | |
ref: '${{inputs.myCommit}}' | |
# Note that secrets are not passed to actions triggered by PRs, so this step will be skipped for PRs. | |
- name: Decode keystore | |
if: env.SECRETS_KEYSTORE != '' | |
id: decode_keystore | |
uses: timheuer/base64-to-file@v1.2.4 | |
with: | |
fileName: android_keystore.jks | |
encodedString: '${{env.SECRETS_KEYSTORE}}' | |
env: | |
# Secrets cannot be referenced in if: blocks, so we have to work it around. | |
SECRETS_KEYSTORE: '${{secrets.KEYSTORE}}' | |
- name: Get NDK | |
id: get-ndk | |
uses: nttld/setup-ndk@v1.5.0 | |
with: | |
ndk-version: '${{env.NDK_REVISION}}' | |
add-to-path: false | |
local-cache: true | |
link-to-sdk: true | |
- name: Install dependencies | |
run: | | |
sudo apt-get install -y yasm | |
if [[ "${{matrix.architecture}}" = "universal" || "${{matrix.architecture}}" = "x86" ]]; then | |
sudo dpkg --add-architecture i386 | |
fi | |
if [[ "${{matrix.architecture}}" = "universal" || "${{matrix.architecture}}" = "x86" || "${{matrix.architecture}}" = "armeabi-v7a" ]]; then | |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y | |
sudo apt-get update | |
sudo apt-get install -y gcc-13-multilib g++-13-multilib | |
fi | |
- uses: actions/setup-java@v4.4.0 | |
with: | |
distribution: temurin | |
java-version: 17.0.6 | |
cache: gradle | |
- name: Run ccache | |
uses: hendrikmuhs/ccache-action@v1.2.14 | |
with: | |
key: 'android-${{matrix.configuration}}-${{matrix.architecture}}' | |
save: ${{ github.ref == 'refs/heads/master' || inputs.releaseTag != '' }} | |
verbose: 2 | |
max-size: ${{ fromJson('["200M", "600M"]')[matrix.architecture == 'universal'] }} | |
- name: Build the app | |
working-directory: android | |
run: | | |
./gradlew "assemble${{matrix.configuration}}" -Pandroid.native.buildOutput=verbose | |
env: | |
SIGNING_KEYSTORE: '${{steps.decode_keystore.outputs.filePath}}' | |
SIGNING_KEY_ALIAS: '${{secrets.SIGNING_KEY_ALIAS}}' | |
SIGNING_KEY_PASSWORD: '${{secrets.SIGNING_KEY_PASSWORD}}' | |
SIGNING_STORE_PASSWORD: '${{secrets.SIGNING_STORE_PASSWORD}}' | |
CMAKE_BUILD_PARALLEL_LEVEL: 3 | |
GITHUBARCH: '${{matrix.architecture}}' | |
- name: List artifacts | |
run: | | |
find android/openenroth/build/outputs/apk | |
- name: Publish apk package | |
if: inputs.releaseTag != '' | |
uses: softprops/action-gh-release@v1 | |
with: | |
prerelease: true | |
tag_name: '${{inputs.releaseTag}}' | |
files: | | |
android/openenroth/build/outputs/apk/debug/openenroth-debug.apk | |
android/openenroth/build/outputs/apk/release/openenroth-release.apk | |
# Don't publish unsigned APKs: | |
# android/openenroth/build/outputs/apk/release/openenroth-release-unsigned.apk | |
- name: Cleanup ccache | |
run: | | |
ccache -c |