Skip to content

Commit d02fcc3

Browse files
committed
ci: Set Go version consistently via .go-version
Ensure Go version is determined consistently for CI and Docker builds rather than spread across several different files. The intent is to eventually replace this with use of the `toolchain` directive in Go 1.21.
1 parent 44dfbe7 commit d02fcc3

22 files changed

+235
-83
lines changed

.github/workflows/build-artifacts.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,13 @@ jobs:
3030
name: Setup outputs
3131
run: ./.github/scripts/get_runner_classes.sh
3232

33+
get-go-version:
34+
uses: ./.github/workflows/reusable-get-go-version.yml
35+
3336
dev-build-push:
34-
needs: setup
37+
needs:
38+
- setup
39+
- get-go-version
3540
runs-on: ${{ fromJSON(needs.setup.outputs.compute-large) }}
3641
permissions:
3742
id-token: write # NOTE: this permission is explicitly required for Vault auth.
@@ -65,7 +70,7 @@ jobs:
6570

6671
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
6772
with:
68-
go-version-file: 'go.mod'
73+
go-version: ${{ needs.get-go-version.outputs.go-version }}
6974

7075
- run: go env
7176

.github/workflows/build-distros.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,25 @@ jobs:
3636
name: Setup outputs
3737
run: ./.github/scripts/get_runner_classes.sh
3838

39+
get-go-version:
40+
uses: ./.github/workflows/reusable-get-go-version.yml
41+
3942
check-go-mod:
4043
needs:
4144
- setup
45+
- get-go-version
4246
uses: ./.github/workflows/reusable-check-go-mod.yml
4347
with:
4448
runs-on: ${{ needs.setup.outputs.compute-medium }}
4549
repository-name: ${{ github.repository }}
50+
go-version: ${{ needs.get-go-version.outputs.go-version }}
4651
secrets:
4752
elevated-github-token: ${{ secrets.ELEVATED_GITHUB_TOKEN }}
4853

4954
build-386:
5055
needs:
5156
- setup
57+
- get-go-version
5258
- check-go-mod
5359
env:
5460
XC_OS: "freebsd linux windows"
@@ -63,7 +69,7 @@ jobs:
6369

6470
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
6571
with:
66-
go-version-file: 'go.mod'
72+
go-version: ${{ needs.get-go-version.outputs.go-version }}
6773
- name: Build
6874
run: |
6975
for os in $XC_OS; do
@@ -73,6 +79,7 @@ jobs:
7379
build-amd64:
7480
needs:
7581
- setup
82+
- get-go-version
7683
- check-go-mod
7784
env:
7885
XC_OS: "darwin freebsd linux solaris windows"
@@ -87,7 +94,7 @@ jobs:
8794

8895
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
8996
with:
90-
go-version-file: 'go.mod'
97+
go-version: ${{ needs.get-go-version.outputs.go-version }}
9198
- name: Build
9299
run: |
93100
for os in $XC_OS; do
@@ -97,6 +104,7 @@ jobs:
97104
build-arm:
98105
needs:
99106
- setup
107+
- get-go-version
100108
- check-go-mod
101109
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
102110
env:
@@ -113,7 +121,7 @@ jobs:
113121

114122
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
115123
with:
116-
go-version-file: 'go.mod'
124+
go-version: ${{ needs.get-go-version.outputs.go-version }}
117125
- run: |
118126
sudo apt-get update --allow-releaseinfo-change-suite --allow-releaseinfo-change-version && sudo apt-get install -y gcc-arm-linux-gnueabi gcc-arm-linux-gnueabihf gcc-aarch64-linux-gnu
119127
@@ -126,6 +134,7 @@ jobs:
126134
if: ${{ endsWith(github.repository, '-enterprise') }}
127135
needs:
128136
- setup
137+
- get-go-version
129138
- check-go-mod
130139
runs-on: ${{ fromJSON(needs.setup.outputs.compute-xl) }}
131140
steps:
@@ -137,7 +146,7 @@ jobs:
137146

138147
- uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753 # v4.0.1
139148
with:
140-
go-version-file: 'go.mod'
149+
go-version: ${{ needs.get-go-version.outputs.go-version }}
141150
- name: Build
142151
run: GOOS=linux GOARCH=s390x CGO_ENABLED=0 go build -tags "${{ env.GOTAGS }}"
143152

.github/workflows/build.yml

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ env:
1818
GOPRIVATE: github.com/hashicorp # Required for enterprise deps
1919

2020
jobs:
21+
get-go-version:
22+
uses: ./.github/workflows/reusable-get-go-version.yml
23+
2124
set-product-version:
2225
runs-on: ubuntu-latest
2326
outputs:
@@ -81,32 +84,25 @@ jobs:
8184
path: ${{ steps.generate-metadata-file.outputs.filepath }}
8285

8386
build:
84-
needs: set-product-version
87+
needs:
88+
- set-product-version
89+
- get-go-version
8590
runs-on: ubuntu-latest
8691
strategy:
8792
matrix:
8893
include:
89-
- {go: "1.20.12",
90-
goos: "linux", goarch: "386"}
91-
- {go: "1.20.12",
92-
goos: "linux", goarch: "amd64"}
93-
- {go: "1.20.12",
94-
goos: "linux", goarch: "arm"}
95-
- {go: "1.20.12",
96-
goos: "linux", goarch: "arm64"}
97-
- {go: "1.20.12",
98-
goos: "freebsd", goarch: "386"}
99-
- {go: "1.20.12",
100-
goos: "freebsd", goarch: "amd64"}
101-
- {go: "1.20.12",
102-
goos: "windows", goarch: "386"}
103-
- {go: "1.20.12",
104-
goos: "windows", goarch: "amd64"}
105-
- {go: "1.20.12",
106-
goos: "solaris", goarch: "amd64"}
94+
- {goos: "linux", goarch: "386"}
95+
- {goos: "linux", goarch: "amd64"}
96+
- {goos: "linux", goarch: "arm"}
97+
- {goos: "linux", goarch: "arm64"}
98+
- {goos: "freebsd", goarch: "386"}
99+
- {goos: "freebsd", goarch: "amd64"}
100+
- {goos: "windows", goarch: "386"}
101+
- {goos: "windows", goarch: "amd64"}
102+
- {goos: "solaris", goarch: "amd64"}
107103
fail-fast: true
108104

109-
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
105+
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
110106
steps:
111107
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
112108

@@ -140,7 +136,7 @@ jobs:
140136
with:
141137
product_name: ${{ env.PKG_NAME }}
142138
product_version: ${{ needs.set-product-version.outputs.product-version }}
143-
go_version: ${{ matrix.go }}
139+
go_version: ${{ needs.get-go-version.outputs.go-version }}
144140
os: ${{ matrix.goos }}
145141
arch: ${{ matrix.goarch }}
146142
reproducible: report
@@ -186,17 +182,18 @@ jobs:
186182
path: out/${{ env.DEB_PACKAGE }}
187183

188184
build-s390x:
189-
needs: set-product-version
185+
needs:
186+
- set-product-version
187+
- get-go-version
190188
if: ${{ endsWith(github.repository, '-enterprise') }}
191189
runs-on: ubuntu-latest
192190
strategy:
193191
matrix:
194192
include:
195-
- {go: "1.20.12",
196-
goos: "linux", goarch: "s390x"}
193+
- {goos: "linux", goarch: "s390x"}
197194
fail-fast: true
198195

199-
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
196+
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
200197
steps:
201198
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
202199

@@ -230,24 +227,25 @@ jobs:
230227
with:
231228
product_name: ${{ env.PKG_NAME }}
232229
product_version: ${{ needs.set-product-version.outputs.product-version }}
233-
go_version: ${{ matrix.go }}
230+
go_version: ${{ needs.get-go-version.outputs.go-version }}
234231
os: ${{ matrix.goos }}
235232
arch: ${{ matrix.goarch }}
236233
reproducible: report
237234
instructions: |-
238235
go build -ldflags="$GOLDFLAGS" -o "$BIN_PATH" -trimpath -buildvcs=false
239236
240237
build-darwin:
241-
needs: set-product-version
238+
needs:
239+
- set-product-version
240+
- get-go-version
242241
runs-on: macos-latest
243242
strategy:
244243
matrix:
245244
goos: [ darwin ]
246245
goarch: [ "amd64", "arm64" ]
247-
go: [ "1.20.12" ]
248246
fail-fast: true
249247

250-
name: Go ${{ matrix.go }} ${{ matrix.goos }} ${{ matrix.goarch }} build
248+
name: Go ${{ needs.get-go-version.outputs.go-version }} ${{ matrix.goos }} ${{ matrix.goarch }} build
251249
steps:
252250
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
253251

@@ -279,7 +277,7 @@ jobs:
279277
with:
280278
product_name: ${{ env.PKG_NAME }}
281279
product_version: ${{ needs.set-product-version.outputs.product-version }}
282-
go_version: ${{ matrix.go }}
280+
go_version: ${{ needs.get-go-version.outputs.go-version }}
283281
os: ${{ matrix.goos }}
284282
arch: ${{ matrix.goarch }}
285283
reproducible: report

0 commit comments

Comments
 (0)