ci: auto-derive versionCode from commit count (never reuse a code)
Some checks failed
build-apk / build-and-publish (push) Successful in 8m58s
gitleaks / scan (push) Failing after 1s

Releases were silently no-op'ing on fdroid: versionCode was a hand-maintained
constant, so a commit that didn't bump it rebuilt the same debug_<vc>.apk, the
publish receiver's anti-downgrade guard refused the duplicate (exit 3 =
"nothing to do"), and the CI went green having shipped nothing. build.yml now
patches ProjectConfig's versionCode from `git rev-list --count HEAD` (minus an
offset keeping it continuous with the manual era, last=91) before assembling,
so every main commit auto-produces a new monotonic code. The ProjectConfig
literal is now just the local-dev default.
This commit is contained in:
Cobb 2026-07-29 07:23:23 -07:00
parent 71155b32b9
commit 574a8183d4
2 changed files with 23 additions and 0 deletions

View file

@ -62,6 +62,25 @@ jobs:
KS_B64: ${{ secrets.STRAW_SIGNING_KEYSTORE_B64 }}
run: echo "$KS_B64" | base64 -d > "$GITHUB_WORKSPACE/straw.keystore"
# Auto-derive versionCode from the main commit count so a release can
# NEVER silently reuse a code — the 2026-07-29 trap where a commit that
# didn't hand-bump ProjectConfig rebuilt the same debug_<vc>.apk, the
# publish receiver's anti-downgrade guard refused the duplicate (exit 3 =
# "nothing to do"), and the CI went green having shipped nothing. The
# OFFSET keeps the number continuous with the manual era (last hand-set
# code was 91). Full clone above ⇒ rev-list --count is the true count.
- name: Auto versionCode from commit count
working-directory: straw
run: |
set -euo pipefail
COUNT=$(git rev-list --count HEAD)
VC=$(( COUNT - 12208 ))
sed -i "s/^const val STRAW_VERSION_CODE = .*/const val STRAW_VERSION_CODE = $VC/" \
buildSrc/src/main/kotlin/ProjectConfig.kt
grep -q "STRAW_VERSION_CODE = $VC\$" buildSrc/src/main/kotlin/ProjectConfig.kt \
|| { echo "::error::versionCode auto-patch failed (sed matched nothing)"; exit 1; }
echo "auto versionCode = $VC (commit count $COUNT)"
- name: Assemble debug APK
working-directory: straw
env:

View file

@ -359,6 +359,10 @@ const val STRAW_SDK_TARGET = 35
// vc=19 / 0.1.0-AE — rust pipeline cutover. Extraction via
// strawcore-core (Sulkta-OSS/strawcore) via the UniFFI wrapper; no
// NewPipeExtractor in the runtime path.
// versionCode is AUTO-DERIVED in CI from the git commit count (see
// .forgejo/workflows/build.yml "Auto versionCode from commit count") so a
// release can never silently reuse a code. This literal is the local-dev
// default only; CI overwrites it at build time.
const val STRAW_VERSION_CODE = 92
const val STRAW_VERSION_NAME = "0.1.0-CZ"
const val STRAW_APPLICATION_ID = "com.sulkta.straw"