Skip to content

Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.

feat: add GitHub Actions workflow for automated release process with version validation

Durganshu Mishraa765db5e37d3
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000..014fb78
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,125 @@
+name: Release
+
+# Fires when update.json changes on main. A version bump there is the trigger
+# for a build+release; anything else touching the file (e.g. releaseNotes
+# text) is a no-op because the "already tagged?" check below short-circuits.
+on:
+ push:
+ branches: [main]
+ paths:
+ - update.json
+
+concurrency:
+ group: release-${{ github.ref }}
+ cancel-in-progress: false
+
+jobs:
+ release:
+ runs-on: ubuntu-latest
+ timeout-minutes: 30
+ permissions:
+ contents: write
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+
+ - name: Read version from update.json
+ id: version
+ run: |
+ VERSION_NAME=$(jq -r '.versionName' update.json)
+ VERSION_CODE=$(jq -r '.versionCode' update.json)
+ DOWNLOAD_URL=$(jq -r '.downloadUrl' update.json)
+ if [ -z "$VERSION_NAME" ] || [ "$VERSION_NAME" = "null" ]; then
+ echo "::error::update.json is missing versionName"
+ exit 1
+ fi
+ echo "name=$VERSION_NAME" >> "$GITHUB_OUTPUT"
+ echo "code=$VERSION_CODE" >> "$GITHUB_OUTPUT"
+ echo "download_url=$DOWNLOAD_URL" >> "$GITHUB_OUTPUT"
+ echo "tag=v$VERSION_NAME" >> "$GITHUB_OUTPUT"
+
+ - name: Skip if this version was already released
+ id: check
+ run: |
+ if git rev-parse -q --verify "refs/tags/${{ steps.version.outputs.tag }}" >/dev/null; then
+ echo "Tag ${{ steps.version.outputs.tag }} already exists — versionName wasn't bumped, nothing to do."
+ echo "should_release=false" >> "$GITHUB_OUTPUT"
+ else
+ echo "should_release=true" >> "$GITHUB_OUTPUT"
+ fi
+
+ - name: Verify app/build.gradle.kts matches update.json
+ if: steps.check.outputs.should_release == 'true'
+ run: |
+ GRADLE_NAME=$(grep -oP 'versionName\s*=\s*"\K[^"]+' app/build.gradle.kts)
+ GRADLE_CODE=$(grep -oP 'versionCode\s*=\s*\K[0-9]+' app/build.gradle.kts)
+ if [ "$GRADLE_NAME" != "${{ steps.version.outputs.name }}" ] || [ "$GRADLE_CODE" != "${{ steps.version.outputs.code }}" ]; then
+ echo "::error::app/build.gradle.kts (versionName=$GRADLE_NAME, versionCode=$GRADLE_CODE) doesn't match update.json (versionName=${{ steps.version.outputs.name }}, versionCode=${{ steps.version.outputs.code }}). Bump both together."
+ exit 1
+ fi
+
+ - name: Verify downloadUrl points at this release
+ if: steps.check.outputs.should_release == 'true'
+ run: |
+ EXPECTED_SUFFIX="/releases/download/${{ steps.version.outputs.tag }}/app-release.apk"
+ case "${{ steps.version.outputs.download_url }}" in
+ *"$EXPECTED_SUFFIX") ;;
+ *)
+ echo "::error::update.json downloadUrl (${{ steps.version.outputs.download_url }}) doesn't end with $EXPECTED_SUFFIX. Update it alongside versionName."
+ exit 1
+ ;;
+ esac
+
+ - uses: actions/setup-java@v4
+ if: steps.check.outputs.should_release == 'true'
+ with:
+ distribution: temurin
+ java-version: "17"
+
+ - uses: gradle/actions/setup-gradle@v4
+ if: steps.check.outputs.should_release == 'true'
+
+ - name: Configure release signing
+ if: steps.check.outputs.should_release == 'true'
+ env:
+ RELEASE_KEYSTORE_BASE64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }}
+ RELEASE_STORE_PASSWORD: ${{ secrets.RELEASE_STORE_PASSWORD }}
+ RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
+ RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
+ run: |
+ if [ -z "$RELEASE_KEYSTORE_BASE64" ]; then
+ echo "::error::RELEASE_KEYSTORE_BASE64 (and the matching password/alias secrets) must be set in repo secrets to build a properly signed release APK. See app/build.gradle.kts signingConfigs."
+ exit 1
+ fi
+ KEYSTORE_PATH="$RUNNER_TEMP/release.keystore"
+ echo "$RELEASE_KEYSTORE_BASE64" | base64 -d > "$KEYSTORE_PATH"
+ cat >> local.properties <<EOF
+ RELEASE_STORE_FILE=$KEYSTORE_PATH
+ RELEASE_STORE_PASSWORD=$RELEASE_STORE_PASSWORD
+ RELEASE_KEY_ALIAS=$RELEASE_KEY_ALIAS
+ RELEASE_KEY_PASSWORD=$RELEASE_KEY_PASSWORD
+ EOF
+
+ - name: Assemble release APK
+ if: steps.check.outputs.should_release == 'true'
+ run: ./gradlew :app:assembleRelease --stacktrace
+
+ - name: Create tag
+ if: steps.check.outputs.should_release == 'true'
+ run: |
+ git config user.name "github-actions[bot]"
+ git config user.email "github-actions[bot]@users.noreply.github.com"
+ git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}"
+ git push origin "${{ steps.version.outputs.tag }}"
+
+ - name: Create GitHub release
+ if: steps.check.outputs.should_release == 'true'
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: |
+ NOTES=$(jq -r '.releaseNotes // ""' update.json)
+ gh release create "${{ steps.version.outputs.tag }}" \
+ app/build/outputs/apk/release/app-release.apk \
+ --title "${{ steps.version.outputs.tag }}" \
+ --notes "$NOTES"