Skip to content

Commit

Permalink
🌱 Migrate to go 1.21 (#3387)
Browse files Browse the repository at this point in the history
* Bump dockerfiles to 1.21
* Go minimum version should match our go.mod
* Bump GitHub action go version to 1.21 and ensure all workflows use env variable.

---------

Signed-off-by: Spencer Schrock <sschrock@google.com>
  • Loading branch information
spencerschrock committed Aug 14, 2023
1 parent 198aa96 commit 5ec66fa
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
- main

env:
GO_VERSION_FILE: go.mod # no good way of getting a mutual version between go.mod and tools/go.mod
GO_VERSION: 1.21

jobs:
docs_only_check:
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:
if: (needs.docs_only_check.outputs.docs_only != 'true')
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
go-version: ${{ env.GO_VERSION }}
check-latest: true
cache: false # the building happens in Docker, so saving this cache would negatively impact other builds
- name: docker build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gitlab.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ on:
- main

env:
GO_VERSION_FILE: go.mod # no good way of getting a mutual version between go.mod and tools/go.mod
GO_VERSION: 1.21

jobs:
gitlab-integration-trusted:
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
go-version: ${{ env.GO_VERSION }}
check-latest: true
cache: false # we manually manage caches below
- id: go-cache-paths
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ on:
permissions:
contents: read

env:
GO_VERSION: 1.21

jobs:
goreleaser:
outputs:
Expand All @@ -42,7 +45,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v2.2.0
with:
go-version: 1.19
go-version: ${{ env.GO_VERSION }}
check-latest: true
- name: Configure ldflags
id: ldflags
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ permissions:
contents: read

env:
GO_VERSION_FILE: go.mod # no good way of getting a mutual version between go.mod and tools/go.mod
GO_VERSION: 1.21

jobs:
approve:
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: ${{ env.GO_VERSION_FILE }}
go-version: ${{ env.GO_VERSION }}
check-latest: true
cache: false # we manually manage caches below
- id: go-cache-paths
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ permissions:
contents: read
pull-requests: read # Use with `only-new-issues` option.

env:
GO_VERSION: 1.21

jobs:
golangci:
name: check-linter
Expand All @@ -22,7 +25,7 @@ jobs:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version-file: 'go.mod'
go-version: ${{ env.GO_VERSION }}
cache: false # golangci-lint maintains its own cache
- name: set golangci-lint version # keep in sync with tools/go.mod
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ on:

env:
PROTOC_VERSION: 3.17.3
GO_VERSION: 1.19
GO_VERSION: 1.21

jobs:
unit-test:
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/publishimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ on:
branches:
- main

env:
GO_VERSION: 1.21

jobs:
publishimage:
runs-on: ubuntu-latest
Expand All @@ -43,7 +46,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
with:
go-version-file: go.mod # use version from go.mod so it stays in sync
go-version: ${{ env.GO_VERSION }}
check-latest: true
- name: install ko
uses: ko-build/setup-ko@ace48d793556083a76f1e3e6068850c1f4a369aa # v0.6
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/slsa-goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ on:

permissions: read-all

env:
GO_VERSION: 1.21

jobs:
# Generate ldflags dynamically.
args:
Expand All @@ -31,7 +34,7 @@ jobs:
needs: args
uses: slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml@v1.8.0 #7f4fdb871876c23e455853d694197440c5a91506
with:
go-version: 1.19
go-version: ${{ env.GO_VERSION }}
evaluated-envs: "VERSION_LDFLAGS:${{needs.args.outputs.ldflags}}"

verification:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ You must install these tools:
1. [`git`](https://help.github.com/articles/set-up-git/): For source control

1. [`go`](https://golang.org/doc/install): You need go version
[v1.17](https://golang.org/dl/) or higher.
[v1.19](https://golang.org/dl/) or higher.

1. [`docker`](https://docs.docker.com/engine/install/): `v18.9` or higher.

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.19@sha256:6b3fa4b908676231b50acbbc00e84d8cee9c6ce072b1175c0ff352c57d8a612f AS base
FROM golang:1.21@sha256:ec457a2fcd235259273428a24e09900c496d0c52207266f96a330062a01e3622 AS base
WORKDIR /src
ENV CGO_ENABLED=0
COPY go.* ./
Expand Down
2 changes: 1 addition & 1 deletion attestor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.19@sha256:6b3fa4b908676231b50acbbc00e84d8cee9c6ce072b1175c0ff352c57d8a612f AS base
FROM golang:1.21@sha256:ec457a2fcd235259273428a24e09900c496d0c52207266f96a330062a01e3622 AS base
WORKDIR /src/scorecard
COPY . ./

Expand Down
2 changes: 1 addition & 1 deletion clients/githubrepo/roundtripper/tokens/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.19@sha256:6b3fa4b908676231b50acbbc00e84d8cee9c6ce072b1175c0ff352c57d8a612f AS base
FROM golang:1.21@sha256:ec457a2fcd235259273428a24e09900c496d0c52207266f96a330062a01e3622 AS base
WORKDIR /src
ENV CGO_ENABLED=0
COPY go.* ./
Expand Down
2 changes: 1 addition & 1 deletion cron/internal/bq/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.19@sha256:6b3fa4b908676231b50acbbc00e84d8cee9c6ce072b1175c0ff352c57d8a612f AS base
FROM golang:1.21@sha256:ec457a2fcd235259273428a24e09900c496d0c52207266f96a330062a01e3622 AS base
WORKDIR /src
ENV CGO_ENABLED=0
COPY go.* ./
Expand Down
2 changes: 1 addition & 1 deletion cron/internal/cii/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.19@sha256:6b3fa4b908676231b50acbbc00e84d8cee9c6ce072b1175c0ff352c57d8a612f AS base
FROM golang:1.21@sha256:ec457a2fcd235259273428a24e09900c496d0c52207266f96a330062a01e3622 AS base
WORKDIR /src
ENV CGO_ENABLED=0
COPY go.* ./
Expand Down
2 changes: 1 addition & 1 deletion cron/internal/controller/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.19@sha256:6b3fa4b908676231b50acbbc00e84d8cee9c6ce072b1175c0ff352c57d8a612f AS base
FROM golang:1.21@sha256:ec457a2fcd235259273428a24e09900c496d0c52207266f96a330062a01e3622 AS base
WORKDIR /src
ENV CGO_ENABLED=0
COPY go.* ./
Expand Down
2 changes: 1 addition & 1 deletion cron/internal/webhook/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.19@sha256:6b3fa4b908676231b50acbbc00e84d8cee9c6ce072b1175c0ff352c57d8a612f AS base
FROM golang:1.21@sha256:ec457a2fcd235259273428a24e09900c496d0c52207266f96a330062a01e3622 AS base
WORKDIR /src
ENV CGO_ENABLED=0
COPY go.* ./
Expand Down
2 changes: 1 addition & 1 deletion cron/internal/worker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM golang:1.19@sha256:6b3fa4b908676231b50acbbc00e84d8cee9c6ce072b1175c0ff352c57d8a612f AS base
FROM golang:1.21@sha256:ec457a2fcd235259273428a24e09900c496d0c52207266f96a330062a01e3622 AS base
WORKDIR /src
ENV CGO_ENABLED=0
COPY go.* ./
Expand Down

0 comments on commit 5ec66fa

Please sign in to comment.