Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
name: Release

# Builds a signed AAB for Play and an APK for sideloading.
# Builds a signed AAB for Play and an APK for sideloading on every merge to main, and
# publishes both on the GitHub release for the current versionName (v1.4.0 …), replacing
# the files of the previous build of that version.
#
# The very first AAB has to be uploaded manually through the Play Console — the
# Publishing API cannot create a new app, only push to one that already exists.
Expand Down Expand Up @@ -37,6 +39,12 @@ jobs:
- name: Run unit tests
run: ./gradlew testDebugUnitTest

# Every build of main gets a fresh, increasing versionCode so Play accepts it.
- name: Set version
run: |
echo "VERSION_CODE=$((100 + GITHUB_RUN_NUMBER))" >> "$GITHUB_ENV"
echo "VERSION_NAME=$(sed -n 's/.*versionName = "\(.*\)".*/\1/p' app/build.gradle.kts | head -1)" >> "$GITHUB_ENV"

- name: Decode keystore
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
Expand All @@ -56,12 +64,24 @@ jobs:
app/build/outputs/bundle/release/app-release.aab
app/build/outputs/apk/release/app-release.apk

- name: Create GitHub release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: app/build/outputs/apk/release/app-release.apk
generate_release_notes: true
- name: Publish on the GitHub release
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
env:
GH_TOKEN: ${{ github.token }}
run: |
tag="v${VERSION_NAME}"
dir=dist && mkdir -p "$dir"
cp app/build/outputs/bundle/release/app-release.aab "$dir/scanrift-${VERSION_NAME}-${VERSION_CODE}.aab"
cp app/build/outputs/apk/release/app-release.apk "$dir/scanrift-${VERSION_NAME}-${VERSION_CODE}.apk"
if ! gh release view "$tag" >/dev/null 2>&1; then
gh release create "$tag" --target "$GITHUB_SHA" --title "ScanRift ${VERSION_NAME}" --generate-notes
fi
# Keep only this build's files on the release: drop the previous build's.
gh release view "$tag" --json assets -q '.assets[].name' | grep -E '^scanrift-.*\.(aab|apk)$' | while read -r old; do
gh release delete-asset "$tag" "$old" --yes
done
gh release upload "$tag" "$dir"/* --clobber
echo "Published ${VERSION_NAME} (${VERSION_CODE}) on $tag" >> "$GITHUB_STEP_SUMMARY"

# - name: Upload to Play internal track
# uses: r0adkll/upload-google-play@v1
Expand Down
5 changes: 5 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ Compose version moves unexpectedly, check Coil first.
- `main` is protected; work on `dev` and open PRs. The `pre-push` hook enforces this —
activate it once per clone with `git config core.hooksPath .githooks`.
- Commit style: `feat(scanRift):` / `fix(scanRift):` / `chore(scanRift):`, matching iOS.
- **Every merge to `main` is a release build.** The Release workflow signs an `.aab` and
an `.apk` and publishes them on the GitHub release `v<versionName>`, replacing the
previous build's files. CI sets `VERSION_CODE` to 100 + the workflow's run number, so
each build is uploadable to Play without a manual bump; bump `versionName` by hand when
a release should get a new name (and a new GitHub release).

## Architecture

Expand Down
10 changes: 6 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ android {
applicationId = "com.scanrift.android"
minSdk = 26
targetSdk = 36
// Play refuses a re-upload at a versionCode that has already been used, so
// this only ever goes up, once per release, whether or not Play saw the last one.
versionCode = 8
versionName = "1.3.2"
// Play refuses a re-upload at a versionCode that has already been used. CI sets
// VERSION_CODE on every build of main (100 + the Release workflow's run number), so
// each merge produces an uploadable bundle without a manual bump; the literal is
// only what local builds use. versionName is still bumped by hand per release.
versionCode = System.getenv("VERSION_CODE")?.toIntOrNull() ?: 9
versionName = "1.4.0"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
Loading