Skip to content

Commit 5d1fd00

Browse files
committed
.github/workflows: validate release tag version string
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 183b11a commit 5d1fd00

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

.github/workflows/release.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,26 @@ 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+
run: |
30+
expected_tag=$(./scripts/get-git-tag-name.sh version.go)
31+
actual_tag=${{ env.RELEASE_VERSION }}
32+
33+
if [ "$actual_tag" = "$expected_tag" ]; then
34+
echo "Git tag release string is as expected."
35+
else
36+
echo "Error: Versions are not equal. Actual: $actual_tag, Expected: $expected_tag"
37+
exit 1
38+
fi
39+
2540
- name: setup go ${{ env.GO_VERSION }}
2641
uses: actions/setup-go@v2
2742
with:
2843
go-version: '${{ env.GO_VERSION }}'
2944

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

0 commit comments

Comments
 (0)