Updated api urls. #48
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 & Smart Release | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| env: | |
| EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| jobs: | |
| build-android: | |
| name: π¨ Build Android - Version Manager | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build_id: ${{ steps.build.outputs.BUILD_ID }} | |
| app_version: ${{ steps.version-control.outputs.app_version }} | |
| build_number: ${{ steps.version-control.outputs.build_number }} | |
| build_date: ${{ steps.version-control.outputs.build_date }} | |
| is_production: ${{ steps.version-control.outputs.is_production }} | |
| steps: | |
| # ======================== | |
| # π οΈ Repository Setup | |
| # ======================== | |
| - name: "π¦ Checkout (Full History)" | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # ======================== | |
| # βοΈ Environment Configuration | |
| # ======================== | |
| - name: "π¦ Setup Node.js 20.x" | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| cache: "npm" | |
| - name: "π§© Install dependencies (ci)" | |
| run: npm ci | |
| # ======================== | |
| # π Version Management | |
| # ======================== | |
| - name: "π Update Production Version" | |
| if: github.ref == 'refs/heads/main' | |
| run: node scripts/bumpVersion.js | |
| - name: "π§ Configure Git for Automation" | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| git config --global user.name "GitHub Actions" | |
| git config --global user.email "actions@github.com" | |
| - name: "πΎ Commit Version Update" | |
| if: github.ref == 'refs/heads/main' | |
| run: | | |
| git add version.json | |
| git commit -m "chore: Auto-increment version [skip ci]" | |
| git push | |
| # ======================== | |
| # π Version Tagging | |
| # ======================== | |
| - name: "π·οΈ Set CI/CD Versions" | |
| id: version-control | |
| run: | | |
| # Set production or preview version | |
| if [ "${{ github.ref }}" == "refs/heads/main" ]; then | |
| APP_VERSION=$(node -p "require('./app.config.js').expo.version") | |
| IS_PRODUCTION="true" | |
| else | |
| APP_VERSION="1.0.0-prerelease.${{ github.run_number }}" | |
| IS_PRODUCTION="false" | |
| fi | |
| # Generate build identifiers | |
| BUILD_NUMBER="${{ github.run_id }}" | |
| BUILD_DATE=$(date +'%Y%m%d-%H%M%S') | |
| # Set outputs for downstream jobs | |
| echo "app_version=$APP_VERSION" >> $GITHUB_OUTPUT | |
| echo "build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT | |
| echo "build_date=$BUILD_DATE" >> $GITHUB_OUTPUT | |
| echo "is_production=$IS_PRODUCTION" >> $GITHUB_OUTPUT | |
| # Export environment variables | |
| echo "APP_VERSION=$APP_VERSION" >> $GITHUB_ENV | |
| echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV | |
| echo "BUILD_DATE=$BUILD_DATE" >> $GITHUB_ENV | |
| # ======================== | |
| # π EAS Setup & Auth | |
| # ======================== | |
| - name: "βοΈ Install EAS CLI" | |
| run: npm install -g eas-cli@latest | |
| - name: "π Verify Expo Credentials" | |
| run: npx eas whoami --token $EXPO_TOKEN | |
| # ======================== | |
| # ποΈ Build Execution | |
| # ======================== | |
| - name: "π Trigger EAS Build" | |
| id: build | |
| run: | | |
| echo "π Initializing build process..." | |
| sudo apt-get install -y jq | |
| # Execute build and capture metadata | |
| BUILD_JSON=$(npx eas build -p android --profile production --non-interactive --json) | |
| BUILD_ID=$(echo "$BUILD_JSON" | jq -r '.[0].id') | |
| # Export build ID for downstream jobs | |
| echo "BUILD_ID=$BUILD_ID" >> $GITHUB_ENV | |
| echo "BUILD_ID=$BUILD_ID" >> $GITHUB_OUTPUT | |
| download-apk: | |
| name: "π₯ APK Artifact Handler" | |
| runs-on: ubuntu-latest | |
| needs: build-android | |
| outputs: | |
| apk_path: ${{ steps.download.outputs.APK_PATH }} | |
| steps: | |
| # ======================== | |
| # π οΈ Environment Setup | |
| # ======================== | |
| - name: "π¦ Checkout Repository" | |
| uses: actions/checkout@v4 | |
| - name: "βοΈ Setup Node.js" | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20.x | |
| # ======================== | |
| # π¦ Dependency Management | |
| # ======================== | |
| - name: "π§° Install Build Tools" | |
| run: | | |
| npm install -g eas-cli@latest | |
| sudo apt-get install -y jq curl | |
| # ======================== | |
| # π Build Monitoring | |
| # ======================== | |
| - name: "β³ Wait for Build Completion" | |
| run: | | |
| echo "β° Monitoring build status..." | |
| npx eas build:wait --build-id ${{ needs.build-android.outputs.build_id }} --timeout 1800 | |
| # ======================== | |
| # π¦ Artifact Handling | |
| # ======================== | |
| - name: "π₯ Download APK" | |
| id: download | |
| run: | | |
| echo "π½ Retrieving APK URL..." | |
| APK_URL=$(npx eas build:list --build-id ${{ needs.build-android.outputs.build_id }} --json | jq -r '.[0].artifacts.url') | |
| echo "π₯ Downloading APK from $APK_URL..." | |
| curl -L "$APK_URL" -o app-release.apk | |
| echo "APK_PATH=app-release.apk" >> $GITHUB_OUTPUT | |
| - name: "π€ Upload Artifact" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: android-apk | |
| path: app-release.apk | |
| generate-changelog: | |
| name: "π Changelog Generator" | |
| runs-on: ubuntu-latest | |
| needs: build-android | |
| outputs: | |
| changelog: ${{ steps.changelog.outputs.CHANGELOG }} | |
| steps: | |
| # ======================== | |
| # π οΈ Repository Setup | |
| # ======================== | |
| - name: "π Checkout with Full History" | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # ======================== | |
| # π Changelog Generation | |
| # ======================== | |
| - name: "π Create Release Notes" | |
| id: changelog | |
| run: | | |
| echo "π Generating changelog from git history..." | |
| CHANGELOG=$(git log --pretty=format:"- %s (%h) by %an" -n 15) | |
| echo "$CHANGELOG" > changelog.txt | |
| echo "CHANGELOG=$(cat changelog.txt)" >> $GITHUB_OUTPUT | |
| - name: "π€ Upload Changelog" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: changelog | |
| path: changelog.txt | |
| create-release: | |
| name: "π Smart Release Publisher" | |
| runs-on: ubuntu-latest | |
| needs: [build-android, download-apk, generate-changelog] | |
| steps: | |
| # ======================== | |
| # π₯ Artifact Retrieval | |
| # ======================== | |
| - name: "π¦ Get APK Artifact" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: android-apk | |
| - name: "π Get Changelog" | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: changelog | |
| # ======================== | |
| # π·οΈ Release Creation | |
| # ======================== | |
| - name: "ποΈ Determine Release Type" | |
| id: release-type | |
| run: | | |
| echo "π Detecting release type..." | |
| if [ "${{ needs.build-android.outputs.is_production }}" = "true" ]; then | |
| echo "π’ Production release detected" | |
| echo "RELEASE_TAG=v${{ needs.build-android.outputs.app_version }}" >> $GITHUB_ENV | |
| echo "RELEASE_TITLE=Production Release v${{ needs.build-android.outputs.app_version }}" >> $GITHUB_ENV | |
| else | |
| echo "π‘ Nightly build detected" | |
| echo "RELEASE_TAG=nightly-${{ needs.build-android.outputs.build_date }}" >> $GITHUB_ENV | |
| echo "RELEASE_TITLE=Nightly Build (${{ needs.build-android.outputs.build_date }})" >> $GITHUB_ENV | |
| fi | |
| - name: "π Publish GitHub Release" | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.RELEASE_TAG }} | |
| name: ${{ env.RELEASE_TITLE }} | |
| body_path: changelog.txt | |
| files: app-release.apk | |
| prerelease: ${{ needs.build-android.outputs.is_production != 'true' }} |