Skip to content

Commit febc071

Browse files
committed
Add versionCode regression guard to set-version.sh
Before stamping the manifest, the script now compares the computed versionCode against the previous release tag's versionCode and fails if it hasn't increased. This prevents silent version regressions like the v0.9.3 release where versionCode was never bumped from v0.9.2.
1 parent 5f36912 commit febc071

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tools/set-version.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,21 @@ if [[ ! -f "${MANIFEST}" ]]; then
3535
exit 1
3636
fi
3737

38+
# Guard: ensure new versionCode is strictly higher than the previous release tag
39+
PREV_TAG="$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || true)"
40+
if [[ -n "${PREV_TAG}" ]]; then
41+
PREV_CODE="$(git show "${PREV_TAG}:${MANIFEST}" 2>/dev/null \
42+
| sed -n 's/.*android:versionCode="\([0-9]*\)".*/\1/p' || true)"
43+
if [[ -n "${PREV_CODE}" && "${VERSION_CODE}" -le "${PREV_CODE}" ]]; then
44+
echo "error: new versionCode ${VERSION_CODE} is not higher than previous tag ${PREV_TAG} (versionCode=${PREV_CODE})" >&2
45+
echo "hint: this usually means the tag version was not bumped correctly" >&2
46+
exit 1
47+
fi
48+
if [[ -n "${PREV_CODE}" ]]; then
49+
echo "versionCode check passed: ${VERSION_CODE} > ${PREV_CODE} (${PREV_TAG})"
50+
fi
51+
fi
52+
3853
python3 - <<PY
3954
import re
4055
from pathlib import Path

0 commit comments

Comments
 (0)