Files
health-app/.gitea/workflows/release.yml
Marcus Rehbock 1a65736fb8
Some checks failed
Build & Release APK / build (push) Has been cancelled
CI: reuse persistent runner caches (npm/gradle/android-sdk volumes)
Node lives in the npm volume, cmdline-tools download is guarded, and
sdkmanager no-ops when packages are present. First run seeds the
volumes; later runs skip all toolchain downloads.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 19:33:54 -07:00

95 lines
4.0 KiB
YAML

name: Build & Release APK
on:
push:
branches: [main]
jobs:
build:
# RN/NDK builds need ~6GB and once took down the 8GB VPS — desktop runner only.
# Jobs queue while the desktop is offline.
runs-on: desktop
container:
image: eclipse-temurin:21-jdk
steps:
# actions/checkout needs node, which this container lacks — clone directly
- name: Checkout
run: |
apt-get update -qq && apt-get install -y -qq git unzip curl xz-utils >/dev/null
git init -q .
git fetch -q --depth 1 "https://git.rehbock.xyz/${{ github.repository }}.git" "${{ github.sha }}"
git checkout -q FETCH_HEAD
# /root/.npm and /root/.gradle and /root/android-sdk are persistent named
# volumes (act_runner config.yaml) — downloads below only happen on a cold cache.
- name: Install Node 22 (cached in npm volume)
run: |
NODE_DIR="$HOME/.npm/_node-v22.14.0"
if [ ! -x "$NODE_DIR/bin/node" ]; then
curl -sLo /tmp/node.tar.xz https://nodejs.org/dist/v22.14.0/node-v22.14.0-linux-x64.tar.xz
mkdir -p "$NODE_DIR" && tar xJf /tmp/node.tar.xz -C "$NODE_DIR" --strip-components=1
fi
echo "$NODE_DIR/bin" >> "$GITHUB_PATH"
"$NODE_DIR/bin/node" --version
- name: npm ci
run: npm ci --no-audit --no-fund
- name: Install Android SDK + NDK (cached volume)
run: |
SDK="$HOME/android-sdk"
SDKMAN="$SDK/cmdline-tools/latest/bin/sdkmanager"
if [ ! -x "$SDKMAN" ]; then
mkdir -p "$SDK/cmdline-tools"
curl -sLo /tmp/ct.zip https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
unzip -q /tmp/ct.zip -d /tmp
mv /tmp/cmdline-tools "$SDK/cmdline-tools/latest"
fi
yes | "$SDKMAN" --sdk_root="$SDK" --licenses >/dev/null 2>&1 || true
"$SDKMAN" --sdk_root="$SDK" \
"platform-tools" "platforms;android-36" "build-tools;36.0.0" \
"ndk;27.1.12297006" "cmake;3.22.1" >/dev/null
- name: Decode signing keystore
env:
KEYSTORE_B64: ${{ secrets.KEYSTORE_B64 }}
run: echo "$KEYSTORE_B64" | base64 -d > /tmp/release.jks
- name: Prebuild android project
env:
VERSION_CODE: ${{ github.run_number }}
VERSION_NAME: 1.0.${{ github.run_number }}
run: npx expo prebuild --platform android --no-install
- name: Build signed release APK (arm64)
env:
HEALTH_KEYSTORE: /tmp/release.jks
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: health
VERSION_CODE: ${{ github.run_number }}
VERSION_NAME: 1.0.${{ github.run_number }}
run: |
export ANDROID_HOME="$HOME/android-sdk"
echo "sdk.dir=$ANDROID_HOME" > android/local.properties
cd android && ./gradlew assembleRelease -PreactNativeArchitectures=arm64-v8a \
--no-daemon --console=plain
- name: Publish Gitea release with APK
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
API="https://git.rehbock.xyz/api/v1/repos/${{ github.repository }}"
TAG="v1.0.${{ github.run_number }}"
APK=android/app/build/outputs/apk/release/app-release.apk
test -f "$APK"
curl -sf -X POST "$API/releases" \
-H "Authorization: token $TOKEN" -H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"$TAG\",\"body\":\"Automated build of commit ${{ github.sha }}\",\"target_commitish\":\"${{ github.sha }}\"}" \
> /tmp/release.json
RID=$(grep -o '"id":[0-9]*' /tmp/release.json | head -1 | cut -d: -f2)
echo "release id: $RID"
curl -sf -X POST "$API/releases/$RID/assets?name=health-app-$TAG-arm64.apk" \
-H "Authorization: token $TOKEN" \
-F "attachment=@$APK;type=application/vnd.android.package-archive" >/dev/null
echo "published $TAG"