139 lines
6.0 KiB
YAML
139 lines
6.0 KiB
YAML
name: Android Build & Publish
|
|
|
|
on:
|
|
push:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
jobs:
|
|
android:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# ── 1. Source ────────────────────────────────────────────────────────────
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
# ── 2. Java ──────────────────────────────────────────────────────────────
|
|
- name: Set up JDK 21
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: '21'
|
|
|
|
# ── 3. Node.js ───────────────────────────────────────────────────────────
|
|
- name: Set up Node 22
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: npm
|
|
|
|
# ── 4. Android SDK ───────────────────────────────────────────────────────
|
|
- name: Install Android SDK command-line tools
|
|
run: |
|
|
SDK_DIR="$HOME/android-sdk"
|
|
echo "ANDROID_HOME=$SDK_DIR" >> "$GITHUB_ENV"
|
|
echo "ANDROID_SDK_ROOT=$SDK_DIR" >> "$GITHUB_ENV"
|
|
|
|
mkdir -p "$SDK_DIR/cmdline-tools"
|
|
|
|
# Download cmdline-tools 12.0 (build 11076708) — stable known-good version
|
|
TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip"
|
|
curl -fsSL "$TOOLS_URL" -o /tmp/cmdline-tools.zip
|
|
unzip -q /tmp/cmdline-tools.zip -d "$SDK_DIR/cmdline-tools"
|
|
# The zip unpacks to "cmdline-tools/"; rename to "latest" per SDK layout
|
|
mv "$SDK_DIR/cmdline-tools/cmdline-tools" "$SDK_DIR/cmdline-tools/latest"
|
|
|
|
echo "$SDK_DIR/cmdline-tools/latest/bin" >> "$GITHUB_PATH"
|
|
echo "$SDK_DIR/platform-tools" >> "$GITHUB_PATH"
|
|
|
|
- name: Accept SDK licenses & install platform/build-tools
|
|
run: |
|
|
# { yes || true } absorbs the SIGPIPE that 'yes' gets when sdkmanager closes
|
|
# stdin after accepting all prompts — avoids exit-code 141 under 'pipefail'.
|
|
{ yes 2>/dev/null || true; } | sdkmanager --licenses
|
|
sdkmanager \
|
|
"platforms;android-36" \
|
|
"build-tools;35.0.0" \
|
|
"platform-tools"
|
|
|
|
# ── 5. Caches ────────────────────────────────────────────────────────────
|
|
- name: Cache Gradle files
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: gradle-${{ hashFiles('android/**/*.gradle*', 'android/gradle/wrapper/gradle-wrapper.properties') }}
|
|
restore-keys: gradle-
|
|
|
|
# ── 6. JS build ──────────────────────────────────────────────────────────
|
|
- name: Install JS dependencies
|
|
run: npm ci
|
|
|
|
- name: Build web assets
|
|
run: npm run build
|
|
|
|
# ── 7. Capacitor sync ────────────────────────────────────────────────────
|
|
- name: Capacitor sync android
|
|
run: npx cap sync android
|
|
|
|
# ── 8. Android build ─────────────────────────────────────────────────────
|
|
- name: Make gradlew executable
|
|
run: chmod +x android/gradlew
|
|
|
|
- name: Build Debug APK
|
|
working-directory: android
|
|
run: ./gradlew assembleDebug --no-daemon
|
|
|
|
- name: Build Release APK (unsigned — no signing key required)
|
|
working-directory: android
|
|
run: ./gradlew assembleRelease --no-daemon
|
|
|
|
# ── 9. Upload APKs as workflow artifacts ─────────────────────────────────
|
|
- name: Upload APKs as artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: scopone-android-${{ github.run_number }}
|
|
path: |
|
|
android/app/build/outputs/apk/debug/app-debug.apk
|
|
android/app/build/outputs/apk/release/app-release-unsigned.apk
|
|
retention-days: 30
|
|
|
|
# ── 10. Publish to Gitea generic package registry ────────────────────────
|
|
- name: Publish APKs to Gitea package registry
|
|
env:
|
|
TOKEN: ${{ secrets.PACKAGE_TOKEN }}
|
|
run: |
|
|
set -euo pipefail
|
|
VERSION="${{ github.run_number }}"
|
|
BASE="https://git.sal.giize.com/api/packages/mozempk/generic/scopone-android"
|
|
|
|
upload() {
|
|
local src="$1" dst_name="$2"
|
|
echo "→ Uploading $dst_name (version $VERSION)…"
|
|
HTTP=$(curl --silent --show-error \
|
|
--output /dev/null --write-out "%{http_code}" \
|
|
-X PUT \
|
|
-H "Authorization: token $TOKEN" \
|
|
--upload-file "$src" \
|
|
"$BASE/$VERSION/$dst_name")
|
|
echo " HTTP $HTTP"
|
|
if [[ "$HTTP" != "20"* ]]; then
|
|
echo "✗ Upload failed — HTTP $HTTP"
|
|
exit 1
|
|
fi
|
|
echo "✓ $dst_name → $BASE/$VERSION/$dst_name"
|
|
}
|
|
|
|
upload android/app/build/outputs/apk/debug/app-debug.apk \
|
|
app-debug.apk
|
|
|
|
upload android/app/build/outputs/apk/release/app-release-unsigned.apk \
|
|
app-release-unsigned.apk
|
|
|
|
echo "📦 Package index: $BASE/$VERSION/"
|