From ae49affcb6929c08bfc956db64f1b08fd77a26dd Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Thu, 26 Jan 2023 14:11:07 +0100 Subject: [PATCH] actions: use go version from Makefile --- .github/ISSUE_TEMPLATE/kubernetes_bump.md | 2 +- .github/workflows/dependabot.yml | 12 +++++++----- .github/workflows/golangci-lint.yml | 8 ++++++-- .github/workflows/release.yml | 7 +++++-- .github/workflows/scan.yml | 11 +++++++---- Makefile | 9 +++++++++ 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/kubernetes_bump.md b/.github/ISSUE_TEMPLATE/kubernetes_bump.md index b00d6a799a6f..3c01705803e0 100644 --- a/.github/ISSUE_TEMPLATE/kubernetes_bump.md +++ b/.github/ISSUE_TEMPLATE/kubernetes_bump.md @@ -57,7 +57,7 @@ run the Cluster API controllers on the new Kubernetes version. * Prior art: periodic jobs: https://github.com/kubernetes/test-infra/pull/27326 * [ ] Bump the Go version in Cluster API: (if Kubernetes is using a new Go minor version) * Search for the currently used Go version across the repository and update it - * We have to at least modify it in: `.github/workflows`, `hack/ensure-go.sh`, `.golangci.yml`, `cloudbuild*.yaml`, `go.mod`, `Makefile`, `netlify.toml`, `Tiltfile` + * We have to at least modify it in: `hack/ensure-go.sh`, `.golangci.yml`, `cloudbuild*.yaml`, `go.mod`, `Makefile`, `netlify.toml`, `Tiltfile` * Prior art: #7135 * [ ] Bump controller-runtime * [ ] Bump controller-tools diff --git a/.github/workflows/dependabot.yml b/.github/workflows/dependabot.yml index 9df43336cd7e..574547bac543 100644 --- a/.github/workflows/dependabot.yml +++ b/.github/workflows/dependabot.yml @@ -17,13 +17,15 @@ jobs: name: Build runs-on: ubuntu-latest steps: - - name: Set up Go 1.x - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # tag=v3.5.0 - with: - go-version: '1.19' - id: go - name: Check out code into the Go module directory uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag=v3.3.0 + - name: Calculate go version + id: vars + run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT + - name: Set up Go + uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # tag=v3.5.0 + with: + go-version: ${{ steps.vars.outputs.go_version }} - uses: actions/cache@58c146cc91c5b9e778e71775dfe9bf1442ad9a12 # tag=v3.2.3 name: Restore go cache with: diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 45559a17d214..fd78e3675338 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -19,9 +19,13 @@ jobs: - hack/tools steps: - uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag=v3.3.0 - - uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # tag=v3.5.0 + - name: Calculate go version + id: vars + run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT + - name: Set up Go + uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # tag=v3.5.0 with: - go-version: 1.19 + go-version: ${{ steps.vars.outputs.go_version }} - name: golangci-lint uses: golangci/golangci-lint-action@08e2f20817b15149a52b5b3ebe7de50aff2ba8c5 # tag=v3.4.0 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dcdd45114dca..88469b64a46d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,10 +20,13 @@ jobs: uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag=v3.3.0 with: fetch-depth: 0 - - name: Install go + - name: Calculate go version + id: vars + run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT + - name: Set up Go uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # tag=v3.5.0 with: - go-version: '^1.19' + go-version: ${{ steps.vars.outputs.go_version }} - name: generate release artifacts run: | make release diff --git a/.github/workflows/scan.yml b/.github/workflows/scan.yml index abc86e2d2ebd..696da22b1d33 100644 --- a/.github/workflows/scan.yml +++ b/.github/workflows/scan.yml @@ -19,9 +19,12 @@ jobs: uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # tag=v3.3.0 with: ref: ${{ matrix.branch }} - - name: Setup go - uses: actions/setup-go@d0a58c1c4d2b25278816e339b944508c875f3613 # tag=v3.4.0 + - name: Calculate go version + id: vars + run: echo "go_version=$(make go-version)" >> $GITHUB_OUTPUT + - name: Set up Go + uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # tag=v3.5.0 with: - go-version: 1.19 + go-version: ${{ steps.vars.outputs.go_version }} - name: Run verify container script - run: make verify-container-images \ No newline at end of file + run: make verify-container-images diff --git a/Makefile b/Makefile index 5d1e138d8725..0e52362554c5 100644 --- a/Makefile +++ b/Makefile @@ -1208,3 +1208,12 @@ $(GOLANGCI_LINT): .github/workflows/golangci-lint.yml # Download golangci-lint u $(GINKGO): # Build ginkgo from tools folder. GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GINKGO_PKG) $(GINKGO_BIN) $(GINGKO_VER) + +## -------------------------------------- +## Helpers +## -------------------------------------- + +##@ helpers: + +go-version: ## Print the go version we use to compile our binaries and images + @echo $(GO_VERSION)