diff --git a/amiga/package-amiga.sh b/amiga/package-amiga.sh index ac72155..cc05187 100755 --- a/amiga/package-amiga.sh +++ b/amiga/package-amiga.sh @@ -34,14 +34,16 @@ rm -rf "$_lha_probe" # OS gets staged under its own directory. rm -rf "$DIST"; mkdir -p "$STAGE/json-c" -# Extract the version from either a release tag, or the dev version + abbreviated commit hash -GIT_DESCR=$(git describe --tags --always) -if [[ "$GIT_DESCR" == json-c-* ]] ; then +# Extract the version from either a release tag, or the dev version + abbreviated commit hash. +# Only use a tag when HEAD is exactly on it: release tags live on release +# branches, so the nearest *reachable* tag is often an old release. +GIT_TAG=$(git describe --tags --exact-match 2>/dev/null) +if [[ "$GIT_TAG" == json-c-* ]] ; then # e.g. 0.19-20260627 - JSON_C_VERS=${GIT_DESCR#json-c-} + JSON_C_VERS=${GIT_TAG#json-c-} else # e.g. 0.19.99-09e45f6 - JSON_C_VERS=$(sed -ne'/define JSON_C_VERSION / { s/"$//; s/.*"//; p }' "${ROOT}/json_c_version.h")-${GIT_DESCR} + JSON_C_VERS=$(sed -ne'/define JSON_C_VERSION / { s/"$//; s/.*"//; p; }' "${ROOT}/json_c_version.h")-$(git rev-parse --short HEAD) fi sed -e"s/VERSION/${JSON_C_VERS}/" "$AMIGA_DIR/json-c.readme.template" > "$STAGE/json-c/json-c.readme"