|
1 | 1 | name: EAS Build |
2 | 2 |
|
| 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 | + |
3 | 6 | on: |
4 | 7 | workflow_dispatch: |
5 | 8 | inputs: |
|
22 | 25 | - production |
23 | 26 | - github-apk |
24 | 27 |
|
| 28 | +permissions: |
| 29 | + contents: write |
| 30 | + |
25 | 31 | jobs: |
26 | 32 | build: |
27 | 33 | runs-on: ubuntu-latest |
|
64 | 70 | exit 1 |
65 | 71 | fi |
66 | 72 |
|
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' |
68 | 105 | run: | |
69 | 106 | eas build --platform ${{ github.event.inputs.platform }} --profile ${{ github.event.inputs.profile }} --non-interactive |
0 commit comments