Skip to content

Commit 1b964f3

Browse files
committed
ci(eas): attach Android APK to GitHub Release on manual EAS Build
Made-with: Cursor
1 parent a7d1c83 commit 1b964f3

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

.github/workflows/eas-build.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
name: EAS Build
22

3+
# When run with platform=android, also uploads the APK to a GitHub Release (tag vX.Y.Z from package.json).
4+
# Use profile "github-apk" to match release-android.yml and store builds.
5+
36
on:
47
workflow_dispatch:
58
inputs:
@@ -22,6 +25,9 @@ on:
2225
- production
2326
- github-apk
2427

28+
permissions:
29+
contents: write
30+
2531
jobs:
2632
build:
2733
runs-on: ubuntu-latest
@@ -64,6 +70,37 @@ jobs:
6470
exit 1
6571
fi
6672
67-
- name: 🚀 Start build
73+
- name: 🚀 EAS build (Android + attach APK to GitHub Release)
74+
if: github.event.inputs.platform == 'android'
75+
env:
76+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
run: |
78+
set -euo pipefail
79+
BUILD_JSON=$(eas build --platform android --profile "${{ github.event.inputs.profile }}" --non-interactive --wait --json)
80+
echo "$BUILD_JSON" | tee eas-build.json
81+
URL=$(echo "$BUILD_JSON" | jq -r 'if type == "array" then .[] else . end | .artifacts.applicationArchiveUrl // empty' | head -1)
82+
if [ -z "$URL" ] || [ "$URL" = "null" ]; then
83+
echo "Could not read applicationArchiveUrl from EAS output"
84+
cat eas-build.json
85+
exit 1
86+
fi
87+
VERSION=$(node -p "require('./package.json').version")
88+
TAG="v${VERSION}"
89+
OUT="BSR-SolarCar2-${TAG}.apk"
90+
curl -fL --retry 3 -o "$OUT" "$URL"
91+
ls -la "$OUT"
92+
if gh release view "$TAG" --repo "${{ github.repository }}" >/dev/null 2>&1; then
93+
gh release upload "$TAG" "$OUT" --clobber --repo "${{ github.repository }}"
94+
echo "Uploaded APK to existing release $TAG"
95+
else
96+
gh release create "$TAG" "$OUT" \
97+
--repo "${{ github.repository }}" \
98+
--title "BSR Solar Car 2 ${TAG}" \
99+
--notes "APK from manual EAS Build (profile: ${{ github.event.inputs.profile }})."
100+
echo "Created release $TAG with APK"
101+
fi
102+
103+
- name: 🚀 EAS build (iOS or all)
104+
if: github.event.inputs.platform != 'android'
68105
run: |
69106
eas build --platform ${{ github.event.inputs.platform }} --profile ${{ github.event.inputs.profile }} --non-interactive

0 commit comments

Comments
 (0)