diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index a64a317..e0d105b 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -25,10 +25,15 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 45 permissions: - contents: read + contents: write + outputs: + version: ${{ steps.version.outputs.version }} steps: - name: Checkout repository uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true - name: Setup Bun uses: oven-sh/setup-bun@v2 @@ -72,6 +77,31 @@ jobs: - name: Install Tauri CLI run: cd apps/tauri && bun install + - name: Compute version + id: version + run: | + # Get latest git tag, default to v0.1.0 + LATEST_TAG=$(git tag --list 'v*' --sort=-v:refname | head -1) + if [ -z "$LATEST_TAG" ]; then + NEW_VERSION="0.1.0" + else + # Strip 'v' prefix, bump patch + BASE="${LATEST_TAG#v}" + IFS='.' read -r MAJOR MINOR PATCH <<< "$BASE" + PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" + fi + echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT + echo "New version: ${NEW_VERSION}" + + # Update tauri.conf.json + jq --arg v "${NEW_VERSION}" '.version = $v' apps/tauri/tauri.conf.json > /tmp/tauri.conf.json && mv /tmp/tauri.conf.json apps/tauri/tauri.conf.json + + # Update Cargo.toml + sed -i "s/^version = \".*\"/version = \"${NEW_VERSION}\"/" apps/tauri/Cargo.toml + + echo "Updated tauri.conf.json and Cargo.toml to ${NEW_VERSION}" + - name: Init Tauri Android project working-directory: apps/tauri env: @@ -103,7 +133,7 @@ jobs: ANDROID_KEY_PASSWORD: ${{ secrets.ANDROID_KEY_PASSWORD }} run: | APK_UNSIGNED=$(find apps/tauri/gen/android/app/build/outputs/apk -name '*.apk' ! -name '*-signed*' | head -1) - APK_SIGNED="${APK_UNSIGNED%.apk}-signed.apk" + APK_SIGNED="apps/tauri/gen/android/app/build/outputs/apk/universal/release/zeavis-edu-v${{ steps.version.outputs.version }}.apk" $ANDROID_SDK_ROOT/build-tools/36.0.0/apksigner sign \ --ks apps/tauri/zeavis.keystore \ --ks-pass "pass:${ANDROID_KEYSTORE_PASSWORD}" \ @@ -111,14 +141,28 @@ jobs: --key-pass "pass:${ANDROID_KEY_PASSWORD}" \ --out "$APK_SIGNED" \ "$APK_UNSIGNED" + echo "signed_apk=${APK_SIGNED}" >> $GITHUB_ENV echo "Signed APK: $APK_SIGNED" ls -lh "$APK_SIGNED" - - name: Upload APK artifact - uses: actions/upload-artifact@v4 + - name: Create Release and upload APK + if: github.event_name != 'pull_request' + uses: softprops/action-gh-release@v2 with: - name: zeavis-edu-android - path: | - apps/tauri/gen/android/app/build/outputs/apk/**/*.apk + tag_name: v${{ steps.version.outputs.version }} + name: v${{ steps.version.outputs.version }} + body: | + ZeaVis Edu Android APK v${{ steps.version.outputs.version }} + + 📦 Built from ${{ github.sha }} + 🔗 Triggered by ${{ github.actor }} + + ### Install + Download the APK below and install on your Android device. + + 🤖 Generated with [Claude Code](https://claude.com/claude-code) + files: | + ${{ env.signed_apk }} apps/tauri/gen/android/app/build/outputs/bundle/**/*.aab - retention-days: 30 + draft: false + prerelease: false