Skip to content

Commit 65c2716

Browse files
fix: Version validation whitespace bug causing false mismatches
The grep/sed extraction wasn't stripping trailing whitespace/CR/LF properly. Both versions were '1.6.0' but bash saw them as different strings. Added 'tr -d \r\n | xargs' to both workflows to strip ALL whitespace. This prevents the endless retag cycle from whitespace bugs.
1 parent e8f6937 commit 65c2716

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ jobs:
2424

2525
- name: Run version validation
2626
run: |
27-
# Extract versions
28-
CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/' | tr -d '\r\n')
29-
TAG_VERSION=${GITHUB_REF_NAME#v}
27+
# Extract versions - strip all whitespace and newlines
28+
CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/' | tr -d '\r\n' | xargs)
29+
TAG_VERSION=$(echo "${GITHUB_REF_NAME#v}" | tr -d '\r\n' | xargs)
3030
3131
echo "🔍 MANDATORY VERSION VALIDATION"
32-
echo "Cargo.toml: $CARGO_VERSION"
33-
echo "Git tag: $TAG_VERSION"
32+
echo "Cargo.toml: '$CARGO_VERSION'"
33+
echo "Git tag: '$TAG_VERSION'"
3434
3535
# FAIL if versions don't match
3636
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then

.github/workflows/version-validation.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ jobs:
5353
run: |
5454
TAG_NAME="${{ steps.determine_tag.outputs.tag_name }}"
5555
56-
# Extract version from Cargo.toml
57-
CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
56+
# Extract version from Cargo.toml - strip all whitespace/newlines
57+
CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/' | tr -d '\r\n' | xargs)
5858
59-
# Extract version from tag (remove 'v' prefix)
60-
TAG_VERSION=${TAG_NAME#v}
59+
# Extract version from tag (remove 'v' prefix) - strip whitespace/newlines
60+
TAG_VERSION=$(echo "${TAG_NAME#v}" | tr -d '\r\n' | xargs)
6161
6262
echo "🔍 Version Check Results:"
63-
echo " Cargo.toml version: $CARGO_VERSION"
64-
echo " Git tag version: $TAG_VERSION"
63+
echo " Cargo.toml version: '$CARGO_VERSION'"
64+
echo " Git tag version: '$TAG_VERSION'"
6565
6666
if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
6767
echo "❌ ERROR: Version mismatch detected!"

0 commit comments

Comments
 (0)