Skip to content

Commit 0407483

Browse files
committed
fix(ci): build the Android APK on EAS instead of on the runner
The workflow compiled the whole app locally on a 2-core GitHub runner with no timeout. Runs took hours and were routinely cancelled — the last published APK is from February, so in practice there has been no Android build for months. Three fixes: build in the cloud and download the artifact; drop the JDK and Android SDK setup that a cloud build never uses; add a timeout so a hang is bounded rather than sitting until GitHub's six-hour limit. The APK is also attached to every run as a workflow artifact, so a build off any branch is installable. Previously only a push to main produced anything — and the upload step lacked the branch guard its release step had, so every dev run was going to fail after the build had already succeeded.
1 parent fb51faa commit 0407483

1 file changed

Lines changed: 31 additions & 9 deletions

File tree

.github/workflows/android-apk-build.yml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515
jobs:
1616
build:
1717
runs-on: ubuntu-latest
18+
# A cloud build is a poll, not a compile, so anything approaching this is a
19+
# hang. The previous local build had no limit and sat for hours.
20+
timeout-minutes: 60
1821
defaults:
1922
run:
2023
working-directory: ./app
@@ -30,14 +33,8 @@ jobs:
3033
cache: 'npm'
3134
cache-dependency-path: ./app/package-lock.json
3235

33-
- name: Set up JDK 17
34-
uses: actions/setup-java@v4
35-
with:
36-
java-version: '17'
37-
distribution: 'temurin'
38-
39-
- name: Setup Android SDK
40-
uses: android-actions/setup-android@v3
36+
# No JDK or Android SDK: EAS compiles this in the cloud. Installing a
37+
# toolchain the runner never uses cost minutes on every run.
4138

4239
- name: Setup Expo
4340
uses: expo/expo-github-action@v8
@@ -52,8 +49,29 @@ jobs:
5249
- name: Initialize EAS
5350
run: eas init --force --non-interactive
5451

52+
# Cloud build. `--local` compiled the whole app on a 2-core runner, which
53+
# took hours and routinely had to be cancelled.
5554
- name: Build Android APK
56-
run: eas build --platform android --profile local --local --output ${{ github.workspace }}/app-release.apk --non-interactive
55+
run: |
56+
set -euo pipefail
57+
eas build --platform android --profile local --non-interactive --wait --json \
58+
> "$RUNNER_TEMP/build.json"
59+
url=$(jq -r '.[0].artifacts.buildUrl // .[0].artifacts.applicationArchiveUrl' \
60+
"$RUNNER_TEMP/build.json")
61+
if [ -z "$url" ] || [ "$url" = "null" ]; then
62+
echo "No artifact URL in the build result:"; cat "$RUNNER_TEMP/build.json"; exit 1
63+
fi
64+
curl -fsSL -o "${{ github.workspace }}/app-release.apk" "$url"
65+
ls -la "${{ github.workspace }}/app-release.apk"
66+
67+
# Attached to every run, so a build off any branch is installable without
68+
# needing a GitHub release.
69+
- name: Upload APK as a workflow artifact
70+
uses: actions/upload-artifact@v4
71+
with:
72+
name: chronicle-android-apk
73+
path: ${{ github.workspace }}/app-release.apk
74+
retention-days: 30
5775

5876
- name: Generate release tag
5977
id: tag
@@ -82,7 +100,11 @@ jobs:
82100
draft: false
83101
prerelease: true
84102

103+
# Same condition as Create Release above. Without it this ran on every
104+
# branch with an empty upload_url and failed after the build had already
105+
# succeeded.
85106
- name: Upload Android APK to Release
107+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
86108
uses: actions/upload-release-asset@v1
87109
env:
88110
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)