Skip to content

Commit 4fcf314

Browse files
committed
Add check for go version matching across CI
Change-Id: Ife77a1f7718b94a71e4162218dff809435cf779f Signed-off-by: Ian Meyer <[email protected]>
1 parent a0be954 commit 4fcf314

File tree

4 files changed

+31
-6
lines changed

4 files changed

+31
-6
lines changed

.github/workflows/golangci-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- uses: actions/checkout@v4
2121
- uses: actions/setup-go@v5
2222
with:
23-
go-version: '1.23.0'
23+
go-version: '1.23.1'
2424
cache: false
2525
- name: golangci-lint
2626
uses: golangci/golangci-lint-action@v6

.github/workflows/release.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,15 @@ jobs:
2121
- name: Set up Go
2222
uses: actions/setup-go@v5
2323
with:
24-
go-version: '1.22.5' # Adjust the Go version as needed
24+
go-version: '1.23.1' # Adjust the Go version as needed
2525

2626
- name: Get Git Commit SHA
2727
id: git_info
2828
run: echo "::set-output name=sha::$(git rev-parse --short HEAD)"
2929

3030
- name: Build the project
3131
run: |
32-
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
33-
go build -ldflags "-X main.version=${{ github.ref_name }} -X main.gitCommit=${{ steps.git_info.outputs.sha }}" \
34-
-o tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }} cmd/tdiscuss/main.go
32+
bazelisk build --stamp --workspace_status_command="${PWD}/status.sh" //:tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }}
3533
3634
- name: Create GitHub Release
3735
id: create_release
@@ -54,4 +52,3 @@ jobs:
5452
asset_path: ./tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }}
5553
asset_name: tdiscuss-${{ matrix.goos }}-${{ matrix.goarch }}
5654
asset_content_type: application/octet-stream
57-

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,6 @@ clean-db:
7272

7373
clean:
7474
$(BAZEL) clean
75+
76+
check-go-versions:
77+
@bash check_go_versions.sh

check-go-versions.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
set -x
6+
7+
# Everything should match what's in go.mod
8+
GV=$(grep "^go" go.mod | awk '{print $2}' | tr -d 'v')
9+
10+
# There are only two places where version is defined so far but this should
11+
# catch most others as they're added as 'go-version'
12+
readarray -t versions < <(grep -h -r --include="*.yml" --include="*.yaml" go-version . | \
13+
awk '{print $2}' | \
14+
tr -d "'" | \
15+
uniq)
16+
17+
if [[ "${#versions[@]}" != 1 ]]; then
18+
printf "error: go-version mismatch in .github/workflows: "
19+
printf "have(%s), want(%s)\n" "${versions}" "${GV}" && exit 1
20+
fi
21+
22+
if [[ "${GV}" != "${versions[@]}" ]]; then
23+
printf "error: go-version mismatch in go.mod: "
24+
printf "have(%s), want(%s)\n" "$GV" "${versions}" && exit 1
25+
fi

0 commit comments

Comments
 (0)