Updated workflow to create a release on repo after successful eas build. #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: EAS Android Build & Release | |
on: | |
push: | |
branches: [main] | |
workflow_dispatch: | |
env: | |
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
build-android: | |
name: Build Android App | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
cache: "npm" | |
- name: Install dependencies | |
run: npm ci | |
- name: Install EAS CLI | |
run: npm install -g eas-cli@latest | |
- name: Start EAS Build | |
id: build | |
run: | | |
BUILD_ID=$(npx eas build -p android --profile production --non-interactive --json | jq -r '.[0].id') | |
echo "BUILD_ID=$BUILD_ID" >> $GITHUB_ENV | |
env: | |
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} | |
- name: Wait for EAS Build to Complete | |
run: | | |
while true; do | |
STATUS=$(npx eas build:view --build-id $BUILD_ID --json | jq -r '.status') | |
echo "Current Status: $STATUS" | |
if [ "$STATUS" == "finished" ]; then | |
DOWNLOAD_URL=$(npx eas build:view --build-id $BUILD_ID --json | jq -r '.artifacts.buildUrl') | |
echo "APK_URL=$DOWNLOAD_URL" >> $GITHUB_ENV | |
break | |
elif [ "$STATUS" == "errored" ]; then | |
echo "EAS build failed." | |
exit 1 | |
fi | |
sleep 30 | |
done | |
env: | |
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} | |
- name: Generate Changelog | |
id: changelog | |
run: | | |
echo "Generating changelog..." | |
echo "## Changelog" > changelog.txt | |
echo "" >> changelog.txt | |
git log --pretty=format:"- %s (%h) by %an" $(git rev-parse HEAD^)..HEAD >> changelog.txt | |
cat changelog.txt | |
echo "CHANGELOG<<EOF" >> $GITHUB_ENV | |
cat changelog.txt >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v1.0.${{ github.run_number }} | |
name: Release v1.0.${{ github.run_number }} | |
body: ${{ env.CHANGELOG }} | |
draft: false | |
prerelease: false | |
files: ${{ env.APK_URL }} |