92 lines
2.8 KiB
YAML
92 lines
2.8 KiB
YAML
name: Android build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
pull_request:
|
|
release:
|
|
types:
|
|
- published
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Java 17
|
|
uses: actions/setup-java@v5
|
|
with:
|
|
distribution: temurin
|
|
java-version: '17'
|
|
|
|
- name: Install Android SDK command-line tools and packages
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail
|
|
export ANDROID_SDK_ROOT="$HOME/.android/sdk"
|
|
export ANDROID_HOME="$ANDROID_SDK_ROOT"
|
|
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
|
|
if [ ! -x "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" ]; then
|
|
curl -fsSL -o /tmp/commandlinetools.zip https://dl.google.com/android/repository/commandlinetools-linux-12266719_latest.zip
|
|
rm -rf "$ANDROID_SDK_ROOT/cmdline-tools/latest" "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools"
|
|
unzip -q /tmp/commandlinetools.zip -d "$ANDROID_SDK_ROOT/cmdline-tools"
|
|
mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest"
|
|
fi
|
|
export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/platform-tools:$PATH"
|
|
set +o pipefail
|
|
yes | sdkmanager --licenses >/dev/null
|
|
set -o pipefail
|
|
sdkmanager \
|
|
"platform-tools" \
|
|
"platforms;android-35" \
|
|
"build-tools;35.0.0"
|
|
|
|
- name: Make Gradle wrapper executable
|
|
run: chmod +x gradlew
|
|
|
|
- name: Write Android SDK location
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail
|
|
printf 'sdk.dir=%s/.android/sdk\n' "$HOME" > local.properties
|
|
|
|
- name: Build debug APK
|
|
if: github.event_name != 'release'
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail
|
|
export ANDROID_SDK_ROOT="$HOME/.android/sdk"
|
|
export ANDROID_HOME="$ANDROID_SDK_ROOT"
|
|
./gradlew --no-daemon clean assembleDebug
|
|
|
|
- name: Build release AAB
|
|
if: github.event_name == 'release'
|
|
shell: bash
|
|
run: |
|
|
set -euxo pipefail
|
|
export ANDROID_SDK_ROOT="$HOME/.android/sdk"
|
|
export ANDROID_HOME="$ANDROID_SDK_ROOT"
|
|
./gradlew --no-daemon bundleRelease
|
|
|
|
- name: Upload debug APK
|
|
if: github.event_name != 'release'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: debug-apk
|
|
path: app/build/outputs/apk/debug/*.apk
|
|
if-no-files-found: error
|
|
|
|
- name: Upload release AAB
|
|
if: github.event_name == 'release'
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: release-aab
|
|
path: app/build/outputs/bundle/release/*.aab
|
|
if-no-files-found: error
|