Skip to content

Commit 554e547

Browse files
jasonrclarkCopilot
andauthored
Validate version on release (#22)
Fixes github/spark#2259 Our typical release process for this component is just to set a tagged release and let that go. This has the downside that our binary also thinks it knows its version over in cmd/version.go. Rather than do something elaborate when we're not releasing this often, this PR simply adds a guardrail that will fail the release if the versions don't align. In that case, the move is to remove the partial release/tag, commit the updated version, and then release. This should be sufficient for the moment, and if we get working on this more often to where it's an annoyance, we can put a more thorough system in place. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent fd97ceb commit 554e547

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

.github/workflows/check-version.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
TAG="${GITHUB_REF_NAME:-${GITHUB_REF#refs/tags/}}"
6+
if [ -z "$TAG" ] || [ "$TAG" = "$GITHUB_REF" ]; then
7+
echo "Unable to determine tag from GitHub Actions environment"
8+
exit 1
9+
fi
10+
FILE_VERSION=$(sed -nE 's/var Version = "(.*)"/\1/p' cmd/version.go)
11+
12+
if [ "$TAG" != "v$FILE_VERSION" ]; then
13+
echo "Version mismatch: tag is $TAG but version.go has $FILE_VERSION"
14+
exit 1
15+
fi

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16+
17+
- name: Confirm tag and code versions match
18+
run: |
19+
.github/workflows/check-version.sh
20+
1621
- uses: cli/gh-extension-precompile@v2
1722
with:
1823
generate_attestations: true

cmd/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
)
99

1010
// Version of the CLI app.
11-
var Version = "0.1.0"
11+
var Version = "0.0.10"
1212

1313
// The command prints out the version of the CLI app.
1414
func init() {

0 commit comments

Comments
 (0)