Skip to content

Commit 671d34e

Browse files
committed
.github/workflows: ensure release tag version string is valid SemVer
This commit adds a check to this project's GitHub release workflow to ensure that the release version string is SemVer compliant. It also indirectly ensures that the version string matches the tag that would have been created with the `make release-tag` command.
1 parent 720f953 commit 671d34e

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/workflows/release.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,28 @@ jobs:
2222
with:
2323
fetch-depth: 0
2424

25+
- name: Set env
26+
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
27+
28+
- name: Validate release tag ${{ env.RELEASE_VERSION }}
29+
# Validate that the release tag matches the version string generated by
30+
# the `get-version.sh` script.
31+
run: |
32+
local version=${{ env.RELEASE_VERSION }}
33+
local expected_version=$(./script/get-version.sh version.go)
34+
35+
if [ "$version" = "$expected_version" ]; then
36+
echo "Versions are equal."
37+
else
38+
echo "Error: Versions are not equal. Actual: $version, Expected: $expected_version"
39+
exit 1
40+
fi
41+
2542
- name: setup go ${{ env.GO_VERSION }}
2643
uses: actions/setup-go@v2
2744
with:
2845
go-version: '${{ env.GO_VERSION }}'
2946

30-
- name: Set env
31-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
32-
3347
- name: build release for all architectures
3448
run: SKIP_VERSION_CHECK=1 make release tag=${{ env.RELEASE_VERSION }}
3549

0 commit comments

Comments
 (0)