From c11ff5216729e744084a451928eb7238531dd3c4 Mon Sep 17 00:00:00 2001 From: Danil Silantyev Date: Sun, 20 Sep 2026 03:33:01 +0500 Subject: [PATCH] fix(release): compare version components as bounded integers The resolve job failed on the first double-digit patch bump: sort -n parses an unbounded field like "9.10" as the float 9.1, so 0.9.10 ordered below 0.9.9 and the monotonicity check correctly refused the identity. Bound every sort key to its own field (-kN,N) and replace the sort-based greater-than test with a numeric per-component awk compare. --- .github/workflows/release-bundle.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release-bundle.yml b/.github/workflows/release-bundle.yml index 196b0eb..643b4d5 100644 --- a/.github/workflows/release-bundle.yml +++ b/.github/workflows/release-bundle.yml @@ -47,7 +47,7 @@ jobs: mapfile -t tags < <( gh api "repos/$GITHUB_REPOSITORY/tags?per_page=100" --paginate --jq '.[].name' \ | grep -x 'gds-v[0-9]*\.[0-9]*\.[0-9]*' \ - | sort -t. -k1.6nr -k2nr -k3nr + | sort -t. -k1.6,1nr -k2,2nr -k3,3nr ) if [ "${#tags[@]}" -eq 0 ]; then echo "No gds-v* tag exists; the first automatic release requires one published baseline" >&2 @@ -90,9 +90,17 @@ jobs: next_version="$(awk -F. -v v="$previous_version" 'BEGIN{split(v,p,"."); printf "%d.%d.%d", p[1], p[2], p[3]+1}')" fi # Monotonicity is structural, not assumed: the new identity must be - # strictly greater than the release it follows. - highest="$(printf '%s\n' "$previous_version" "$next_version" | sort -t. -k1n -k2n -k3n | tail -1)" - if [ "$highest" != "$next_version" ] || [ "$next_version" = "$previous_version" ]; then + # strictly greater than the release it follows. Compare components + # numerically -- sort -n reads "9.10" as the float 9.1, which orders + # a double-digit patch below its predecessor. + if ! awk -F. -v a="$previous_version" -v b="$next_version" 'BEGIN{ + split(a, x, "."); split(b, y, "."); + for (i = 1; i <= 3; i++) { + if (y[i] + 0 > x[i] + 0) exit 0; + if (y[i] + 0 < x[i] + 0) exit 1; + } + exit 1 + }'; then echo "next version $next_version is not greater than $previous_version" >&2 exit 1 fi