Skip to content

chore: script to update golang; update go to 1.23.5 #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion applylib/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/applylib

go 1.22.0

toolchain go1.23.1
toolchain go1.23.5

// Sometimes handy for development, but breaks usage as a library
// Instead, please break apart commits to this module
Expand Down
58 changes: 58 additions & 0 deletions dev/codebots/update-golang-version
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

# Copyright 2022 The Kubernetes Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


# Helper script to update golang to latest version

set -o errexit
set -o nounset
set -o pipefail

REPO_ROOT=$(git rev-parse --show-toplevel)
cd ${REPO_ROOT}

# TODO: Should we update to the latest go, or the latest go in a particular minor?
GO_TOOLCHAIN=$(curl https://go.dev/dl/?mode=json | jq -r '[.[] | select(.stable == true)] | .[0].version')
echo "GO_TOOLCHAIN=$GO_TOOLCHAIN"

git switch --force-create codebot-update-golang-version-${GO_TOOLCHAIN}

# GO_VERSION is the GO_TOOLCHAIN without the go prefix
GO_VERSION=${GO_TOOLCHAIN#go}
echo "GO_VERSION=$GO_VERSION"

# Update go.mod files
# Tidy each individual go.mod
for gomod_file in $(find "${REPO_ROOT}" -name "go.mod"); do
dir=$(dirname ${gomod_file})
cd "${dir}"
echo "Updating $gomod_file to toolchain $GO_TOOLCHAIN"
go mod edit -toolchain=${GO_TOOLCHAIN}
done

# Update Docker images
for dockerfile in $(find "${REPO_ROOT}" -name "Dockerfile*"); do
echo "Updating Dockerfile $dockerfile to go image $GO_VERSION"
sed -i -e "s/FROM golang:[0-9.]*/FROM golang:$GO_VERSION/g" $dockerfile
done

if $(git diff --quiet); then
echo "No changes"
else
cd ${REPO_ROOT}
git add .
git commit -m "codebot: update go to ${GO_VERSION}"
fi
2 changes: 1 addition & 1 deletion examples/guestbook-operator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.17 as builder
FROM golang:1.23.5 as builder

# Copy in the go src
WORKDIR /workspace
Expand Down
2 changes: 1 addition & 1 deletion examples/guestbook-operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/examples/guestbook-operator

go 1.22.0

toolchain go1.22.4
toolchain go1.23.5

require (
github.com/go-logr/logr v1.4.2
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern

go 1.22.0

toolchain go1.22.4
toolchain go1.23.5

// Sometimes handy for development, but breaks usage as a library
// Instead, please break apart commits to this module
Expand Down
2 changes: 1 addition & 1 deletion ktest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/ktest

go 1.22.0

toolchain go1.23.1
toolchain go1.23.5

require (
github.com/google/go-cmp v0.6.0
Expand Down
2 changes: 1 addition & 1 deletion mockkubeapiserver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module sigs.k8s.io/kubebuilder-declarative-pattern/mockkubeapiserver

go 1.22.0

toolchain go1.23.1
toolchain go1.23.5

require (
github.com/google/go-cmp v0.6.0
Expand Down
Loading