Skip to content

Release Android APK

Release Android APK #1

Workflow file for this run

name: Release Android APK
on:
workflow_dispatch:
inputs:
bump:
description: Version change for this release
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@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- 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
run: npx expo prebuild -p android --non-interactive
- name: Build release APK
working-directory: android
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 }}