109 lines
4.1 KiB
YAML
109 lines
4.1 KiB
YAML
name: Build Android APK
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- master
|
|
- 'refactor/**'
|
|
tags:
|
|
- 'v*'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- master
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-android:
|
|
name: Build Release APKs
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/cirruslabs/flutter:3.19.3
|
|
options: --privileged
|
|
steps:
|
|
- name: Setup Node.js 20 & ARM64 Flutter Engine
|
|
run: |
|
|
ARCH=$(uname -m)
|
|
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then NODE_ARCH="arm64"; else NODE_ARCH="x64"; fi
|
|
curl -fsSL "https://nodejs.org/dist/v20.18.0/node-v20.18.0-linux-${NODE_ARCH}.tar.gz" | tar -xzf - -C /usr/local --strip-components=1
|
|
node --version
|
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
|
git config --global --add safe.directory '*'
|
|
|
|
# On Linux ARM64, Flutter engine lacks native linux-arm64 gen_snapshot cross-compilers.
|
|
# We install qemu-user-static and generate thin wrappers to run the linux-x64 gen_snapshot seamlessly.
|
|
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
|
|
echo "Setting up ARM64 Flutter gen_snapshot wrappers via QEMU..."
|
|
apt-get update -qq && apt-get install -y -qq qemu-user-static binfmt-support libc6-amd64-cross libstdc++6-amd64-cross
|
|
update-binfmts --enable qemu-x86_64 2>/dev/null || true
|
|
mkdir -p /lib64
|
|
ln -sf /usr/x86_64-linux-gnu/lib/ld-linux-x86-64.so.2 /lib64/ld-linux-x86-64.so.2
|
|
QEMU_BIN=$(command -v qemu-x86_64-static || command -v qemu-x86_64)
|
|
flutter precache --android
|
|
for dir in /sdks/flutter/bin/cache/artifacts/engine/android-*; do
|
|
if [ -d "$dir/linux-x64" ]; then
|
|
mkdir -p "$dir/linux-arm64"
|
|
printf '#!/bin/sh\nSCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"\nexec %s -L /usr/x86_64-linux-gnu "$SCRIPT_DIR/../linux-x64/gen_snapshot" "$@"\n' "$QEMU_BIN" > "$dir/linux-arm64/gen_snapshot"
|
|
chmod +x "$dir/linux-arm64/gen_snapshot"
|
|
echo "Configured gen_snapshot wrapper for $(basename "$dir")"
|
|
fi
|
|
done
|
|
fi
|
|
|
|
- name: Checkout Repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Make Gradlew Executable
|
|
run: |
|
|
if [ -f android/gradlew ]; then
|
|
chmod +x android/gradlew
|
|
fi
|
|
|
|
- name: Inspect Build Environment
|
|
run: |
|
|
flutter --version
|
|
java -version
|
|
node --version
|
|
|
|
- name: Fetch Flutter Dependencies
|
|
run: flutter pub get
|
|
|
|
- name: Run Code Analysis & Tests
|
|
run: |
|
|
flutter analyze
|
|
flutter test
|
|
|
|
- name: Build Universal Release APK
|
|
run: flutter build apk --release
|
|
|
|
- name: Build Split-per-ABI Release APKs
|
|
run: flutter build apk --release --split-per-abi
|
|
|
|
- name: Organize Artifacts
|
|
run: |
|
|
mkdir -p release-apks
|
|
# Copy universal APK
|
|
if [ -f build/app/outputs/flutter-apk/app-release.apk ]; then
|
|
cp build/app/outputs/flutter-apk/app-release.apk release-apks/oggauer-gemeindetrommler-universal-release.apk
|
|
fi
|
|
# Copy split APKs
|
|
if [ -f build/app/outputs/flutter-apk/app-arm64-v8a-release.apk ]; then
|
|
cp build/app/outputs/flutter-apk/app-arm64-v8a-release.apk release-apks/oggauer-gemeindetrommler-arm64-v8a.apk
|
|
fi
|
|
if [ -f build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk ]; then
|
|
cp build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk release-apks/oggauer-gemeindetrommler-armeabi-v7a.apk
|
|
fi
|
|
if [ -f build/app/outputs/flutter-apk/app-x86_64-release.apk ]; then
|
|
cp build/app/outputs/flutter-apk/app-x86_64-release.apk release-apks/oggauer-gemeindetrommler-x86_64.apk
|
|
fi
|
|
echo "=== Generated APK Artifacts ==="
|
|
ls -lah release-apks/
|
|
|
|
- name: Upload APKs to Gitea Artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: oggauer-gemeindetrommler-apks
|
|
path: release-apks/*.apk
|
|
retention-days: 30
|