Release Android APK #3
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: Release Android APK | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| bump: | |
| description: Version change for this release (prefer patch/minor; major is a breaking jump) | |
| required: true | |
| type: choice | |
| default: patch | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| - none | |
| # "none" = keep current app.json version (already bumped locally) | |
| concurrency: | |
| group: release-android | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 90 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Node | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - name: Setup Java | |
| uses: actions/setup-java@v5 | |
| with: | |
| distribution: temurin | |
| java-version: 17 | |
| - name: Setup Android SDK | |
| uses: android-actions/setup-android@v3 | |
| - name: Accept Android licenses | |
| run: yes | sdkmanager --licenses >/dev/null || true | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Bump version | |
| if: inputs.bump != 'none' | |
| run: node scripts/bump-version.cjs "${{ inputs.bump }}" | |
| - name: Resolve version | |
| id: meta | |
| run: | | |
| VERSION=$(node -p "require('./app.json').expo.version") | |
| CODE=$(node -p "require('./app.json').expo.android.versionCode") | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "version_code=$CODE" >> "$GITHUB_OUTPUT" | |
| echo "tag=v$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Resolved v$VERSION (versionCode $CODE)" | |
| - name: Prebuild Android project | |
| env: | |
| CI: 1 | |
| NODE_ENV: production | |
| run: npx expo prebuild -p android | |
| - name: Build release APK | |
| working-directory: android | |
| env: | |
| NODE_ENV: production | |
| run: ./gradlew assembleRelease --no-daemon | |
| - name: Package APK artifact | |
| run: | | |
| mkdir -p dist | |
| cp android/app/build/outputs/apk/release/app-release.apk dist/Canal-Study.apk | |
| ls -lh dist/Canal-Study.apk | |
| - name: Commit version bump and create tag | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add app.json package.json | |
| if ! git diff --cached --quiet; then | |
| git commit -m "chore: release v${{ steps.meta.outputs.version }}" | |
| git push origin HEAD:${{ github.ref_name }} | |
| fi | |
| if git rev-parse "${{ steps.meta.outputs.tag }}" >/dev/null 2>&1; then | |
| echo "Tag ${{ steps.meta.outputs.tag }} already exists" | |
| else | |
| git tag "${{ steps.meta.outputs.tag }}" | |
| git push origin "${{ steps.meta.outputs.tag }}" | |
| fi | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.meta.outputs.tag }} | |
| name: Canal Study ${{ steps.meta.outputs.tag }} | |
| generate_release_notes: true | |
| files: dist/Canal-Study.apk | |
| fail_on_unmatched_files: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |