Skip to content

Commit 3088791

Browse files
mboersmabryan-cox
authored andcommitted
Use "make go-version" in GitHub Actions (kubernetes-sigs#5865)
* Use "make go-version" in GitHub Actions * Get GO_VERSION from toolchain statment
1 parent 6969f60 commit 3088791

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

.github/workflows/cover.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@ jobs:
1717
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
1818
with:
1919
egress-policy: audit
20-
2120
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
22-
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
21+
- name: Get Go version
22+
id: vars
23+
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
24+
- name: Set up Go
25+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
2326
with:
24-
go-version: '1.24'
27+
go-version: ${{ steps.vars.outputs.go_version }}
2528
- run: "PATH=/usr/local/go/bin:$PATH make test-cover"
2629
- uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 # v5.5.1
2730
env:

.github/workflows/dependabot-code-gen.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ jobs:
2323
uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
2424
with:
2525
egress-policy: audit
26-
- name: Set up Go 1.x
26+
- name: Get Go version
27+
id: vars
28+
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
29+
- name: Set up Go
2730
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
2831
with:
29-
go-version: '1.24'
32+
go-version: ${{ steps.vars.outputs.go_version }}
3033
id: go
3134
- name: Check out code into the Go module directory
3235
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

.github/workflows/pr-golangci-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
steps:
2121
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
2222

23-
- name: Calculate go version
23+
- name: Get Go version
2424
id: vars
2525
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
2626

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
with:
105105
fetch-depth: 0
106106
ref: ${{ env.RELEASE_TAG }}
107-
- name: Calculate go version
107+
- name: Get Go version
108108
run: echo "go_version=$(make go-version)" >> $GITHUB_ENV
109109
- name: Set up Go
110110
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # tag=v6.0.0

.github/workflows/weekly-security-scan.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
2222
with:
2323
ref: ${{ matrix.branch }}
24-
- name: Calculate go version
24+
- name: Get Go version
2525
id: vars
2626
run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT
2727
- name: Set up Go

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ SHELL:=/usr/bin/env bash
2020

2121
.DEFAULT_GOAL:=help
2222

23-
GO_VERSION ?= $(shell sed -n 's/^go //p' go.mod)
23+
GO_VERSION ?= $(shell sed -n 's/^toolchain go//p' go.mod)
2424
GOPATH := $(shell go env GOPATH)
2525
GOARCH := $(shell go env GOARCH)
2626
GOOS := $(shell go env GOOS)

0 commit comments

Comments
 (0)