vpnhide/scripts/build-version.sh
okhsunrog 3fc735572a build: stamp git-describe build version into every artifact
Add scripts/build-version.sh — a single source of truth for the
effective version string:

  * HEAD on tag vX.Y.Z          -> "X.Y.Z"
  * N commits past tag          -> "X.Y.Z-N-gSHA"
  * working tree dirty          -> additional "-dirty" suffix
  * no git / no matching tag    -> VERSION file fallback

Wired into every packaging path:

  * zygisk/build-zip.sh and portshide/build-zip.sh now stage a copy of
    module/ and sed-patch `version=` in the staging copy, so committed
    module.prop files stay at the last-released version.
  * kmod/build-zip.sh now builds into a staging copy too.
  * The kmod CI step runs build-version.sh and sed-patches module.prop
    before zipping (git installed in the DDK container).
  * lsposed/app/build.gradle.kts exec's build-version.sh at configure
    time and assigns the result to `versionName` (versionCode stays
    static, still bumped by release.py).

All actions/checkout@v6 gained `fetch-depth: 0` so git describe sees
the full tag history inside CI containers.

Result: a locally built or CI-from-main APK shows up in Android
Settings as e.g. `0.6.1-16-gf86e5e5`, and the zip inside carries the
same string in module.prop; the Magisk/KSU manager displays it in the
update list. Release tag builds are indistinguishable from before —
clean `X.Y.Z`. Diagnostic bug reports now carry the exact commit in
the App version line of device_info.txt.
2026-04-17 14:42:40 +03:00

20 lines
694 B
Bash
Executable file

#!/usr/bin/env bash
# Print the effective build version for vpnhide artifacts.
#
# - HEAD on a tag vX.Y.Z -> "X.Y.Z" (release build)
# - N commits after tag vX.Y.Z -> "X.Y.Z-N-gSHA" (dev build)
# - working tree dirty -> additional "-dirty" suffix
# - no git / no matching tag -> falls back to VERSION file
#
# Used by every packaging step (module.prop, APK versionName, CI artifact
# names) so dev builds are unambiguously identifiable at a glance.
set -euo pipefail
cd "$(dirname "$0")/.."
if git rev-parse --git-dir >/dev/null 2>&1 \
&& raw=$(git describe --tags --match 'v*' --dirty 2>/dev/null); then
echo "${raw#v}"
else
cat VERSION
fi