diff --git a/.forgejo/workflows/build.yml b/.forgejo/workflows/build.yml index 1fe3c804e..0e9ca3ea0 100644 --- a/.forgejo/workflows/build.yml +++ b/.forgejo/workflows/build.yml @@ -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_.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: diff --git a/buildSrc/src/main/kotlin/ProjectConfig.kt b/buildSrc/src/main/kotlin/ProjectConfig.kt index 5e3dda068..6a6042811 100644 --- a/buildSrc/src/main/kotlin/ProjectConfig.kt +++ b/buildSrc/src/main/kotlin/ProjectConfig.kt @@ -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"