Skip to content

Commit d727027

Browse files
committed
explicitly set and use Go toolchain version specified in go.mod
1 parent 4f40a58 commit d727027

File tree

9 files changed

+21
-78
lines changed

9 files changed

+21
-78
lines changed

.github/constants.env

-3
This file was deleted.

.github/workflows/check-generated.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,10 @@ jobs:
2020
- name: Checkout code
2121
uses: actions/checkout@v3
2222

23-
- name: Export constant environmental variables
24-
uses: cardinalby/export-env-action@v2
25-
with:
26-
envFile: .github/constants.env
27-
2823
- name: Install Go
2924
uses: actions/setup-go@v4
3025
with:
31-
go-version: ${{ env.GO_VERSION }}.x
32-
check-latest: true
26+
go-version-file: go.mod
3327

3428
# Install any tools 'go generate' uses here
3529

.github/workflows/codeql.yml

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ jobs:
4949
with:
5050
languages: ${{ matrix.language }}
5151

52+
# TODO: remove once https://github.com/github/codeql/issues/13992 is fixed
53+
- name: Install Go
54+
uses: actions/setup-go@v4
55+
with:
56+
go-version-file: go.mod
57+
5258
- name: Autobuild
5359
uses: github/codeql-action/autobuild@v2
5460

.github/workflows/lint-actions.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,10 @@ jobs:
1515
- name: Checkout code
1616
uses: actions/checkout@v3
1717

18-
- name: Export constant environmental variables
19-
uses: cardinalby/export-env-action@v2
20-
with:
21-
envFile: .github/constants.env
22-
2318
- name: Install Go
2419
uses: actions/setup-go@v4
2520
with:
26-
go-version: ${{ env.GO_VERSION }}.x
27-
check-latest: true
21+
go-version-file: go.mod
2822

2923
- name: Lint workflow files
3024
run: |

.github/workflows/lint-go.yml

+5-22
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,15 @@ jobs:
1818
- name: Checkout code
1919
uses: actions/checkout@v3
2020

21-
- name: Export constant environmental variables
22-
uses: cardinalby/export-env-action@v2
23-
with:
24-
envFile: .github/constants.env
25-
2621
- name: Install Go
22+
id: install-go
2723
uses: actions/setup-go@v4
2824
with:
29-
go-version: ${{ env.GO_VERSION }}.x
30-
check-latest: true
25+
go-version-file: go.mod
3126

3227
- name: Ensure go.mod was tidied
3328
run: |
34-
go mod tidy -compat ${{ env.GO_VERSION }}
29+
go mod tidy -compat ${{ steps.install-go.outputs.go-version }}
3530
STATUS=$(git status --porcelain go.mod go.sum)
3631
if [ -n "$STATUS" ]; then
3732
echo "Running 'go mod tidy' modified go.mod and/or go.sum"
@@ -46,16 +41,10 @@ jobs:
4641
- name: Checkout code
4742
uses: actions/checkout@v3
4843

49-
- name: Export constant environmental variables
50-
uses: cardinalby/export-env-action@v2
51-
with:
52-
envFile: .github/constants.env
53-
5444
- name: Install Go
5545
uses: actions/setup-go@v4
5646
with:
57-
go-version: ${{ env.GO_VERSION }}.x
58-
check-latest: true
47+
go-version-file: go.mod
5948

6049
- name: Lint with staticcheck
6150
uses: dominikh/[email protected]
@@ -71,16 +60,10 @@ jobs:
7160
- name: Checkout code
7261
uses: actions/checkout@v3
7362

74-
- name: Export constant environmental variables
75-
uses: cardinalby/export-env-action@v2
76-
with:
77-
envFile: .github/constants.env
78-
7963
- name: Install Go
8064
uses: actions/setup-go@v4
8165
with:
82-
go-version: ${{ env.GO_VERSION }}.x
83-
check-latest: true
66+
go-version-file: go.mod
8467

8568
- name: Lint with golangci-lint
8669
uses: golangci/[email protected]

.github/workflows/release.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,13 @@ jobs:
2121
with:
2222
fetch-depth: 0
2323

24-
- name: Export constant environmental variables
25-
uses: cardinalby/export-env-action@v2
26-
with:
27-
envFile: .github/constants.env
28-
2924
- name: Checkout tags
3025
run: git fetch --force --tags
3126

3227
- name: Install Go
3328
uses: actions/setup-go@v4
3429
with:
35-
go-version: ${{ env.GO_VERSION }}.x
36-
check-latest: true
30+
go-version-file: go.mod
3731

3832
- name: Install cosign
3933
uses: sigstore/cosign-installer@main

.github/workflows/test.yml

+2-14
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,10 @@ jobs:
1818
- name: Checkout code
1919
uses: actions/checkout@v3
2020

21-
- name: Export constant environmental variables
22-
uses: cardinalby/export-env-action@v2
23-
with:
24-
envFile: .github/constants.env
25-
2621
- name: Install Go
2722
uses: actions/setup-go@v4
2823
with:
29-
go-version: ${{ env.GO_VERSION }}.x
30-
check-latest: true
24+
go-version-file: go.mod
3125

3226
- name: Ensure main package builds
3327
run: |
@@ -45,16 +39,10 @@ jobs:
4539
- name: Checkout code
4640
uses: actions/checkout@v3
4741

48-
- name: Export constant environmental variables
49-
uses: cardinalby/export-env-action@v2
50-
with:
51-
envFile: .github/constants.env
52-
5342
- name: Install Go
5443
uses: actions/setup-go@v4
5544
with:
56-
go-version: ${{ env.GO_VERSION }}.x
57-
check-latest: true
45+
go-version-file: go.mod
5846

5947
- name: Fuzz code for 10 minutes
6048
run: |

.github/workflows/vuln.yml

+2-17
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,6 @@ jobs:
1717
runs-on: ubuntu-latest
1818
timeout-minutes: 10
1919
steps:
20-
- name: Checkout code
21-
uses: actions/checkout@v3
22-
23-
- name: Export constant environmental variables
24-
uses: cardinalby/export-env-action@v2
25-
with:
26-
envFile: .github/constants.env
27-
28-
- name: Install Go
29-
uses: actions/setup-go@v4
20+
- uses: golang/govulncheck-action@v1
3021
with:
31-
go-version: ${{ env.GO_VERSION }}.x
32-
check-latest: true
33-
34-
- name: Scan for known vulnerable dependencies
35-
run: |
36-
go install golang.org/x/vuln/cmd/govulncheck@latest
37-
govulncheck ./...
22+
go-version-file: go.mod

go.mod

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/capnspacehook/go-project-template
22

3-
go 1.19
3+
go 1.21.0
4+
5+
toolchain go1.21.1
46

57
require go.uber.org/zap v1.25.0
68

0 commit comments

Comments
 (0)