Skip to content

Commit c79caa9

Browse files
Updated workflow to create a release on repo after successful eas build.
1 parent 4abe4cf commit c79caa9

File tree

1 file changed

+44
-7
lines changed

1 file changed

+44
-7
lines changed

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

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: EAS Android Build
1+
name: EAS Android Build & Release
22

33
on:
44
push:
@@ -7,6 +7,7 @@ on:
77

88
env:
99
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
10+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1011

1112
jobs:
1213
build-android:
@@ -28,14 +29,50 @@ jobs:
2829
- name: Install EAS CLI
2930
run: npm install -g eas-cli@latest
3031

31-
- name: Build Production APK
32-
run: npx eas build -p android --profile production --non-interactive
32+
- name: Start EAS Build
33+
id: build
34+
run: |
35+
BUILD_ID=$(npx eas build -p android --profile production --non-interactive --json | jq -r '.[0].id')
36+
echo "BUILD_ID=$BUILD_ID" >> $GITHUB_ENV
3337
env:
3438
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
3539

36-
# Optional: Add a preview build
37-
- name: Build Preview APK
38-
if: github.event_name == 'workflow_dispatch'
39-
run: npx eas build -p android --profile preview --non-interactive
40+
- name: Wait for EAS Build to Complete
41+
run: |
42+
while true; do
43+
STATUS=$(npx eas build:view --build-id $BUILD_ID --json | jq -r '.status')
44+
echo "Current Status: $STATUS"
45+
if [ "$STATUS" == "finished" ]; then
46+
DOWNLOAD_URL=$(npx eas build:view --build-id $BUILD_ID --json | jq -r '.artifacts.buildUrl')
47+
echo "APK_URL=$DOWNLOAD_URL" >> $GITHUB_ENV
48+
break
49+
elif [ "$STATUS" == "errored" ]; then
50+
echo "EAS build failed."
51+
exit 1
52+
fi
53+
sleep 30
54+
done
4055
env:
4156
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
57+
58+
- name: Generate Changelog
59+
id: changelog
60+
run: |
61+
echo "Generating changelog..."
62+
echo "## Changelog" > changelog.txt
63+
echo "" >> changelog.txt
64+
git log --pretty=format:"- %s (%h) by %an" $(git rev-parse HEAD^)..HEAD >> changelog.txt
65+
cat changelog.txt
66+
echo "CHANGELOG<<EOF" >> $GITHUB_ENV
67+
cat changelog.txt >> $GITHUB_ENV
68+
echo "EOF" >> $GITHUB_ENV
69+
70+
- name: Create GitHub Release
71+
uses: softprops/action-gh-release@v2
72+
with:
73+
tag_name: v1.0.${{ github.run_number }}
74+
name: Release v1.0.${{ github.run_number }}
75+
body: ${{ env.CHANGELOG }}
76+
draft: false
77+
prerelease: false
78+
files: ${{ env.APK_URL }}

0 commit comments

Comments
 (0)