Skip to content

Commit 1784105

Browse files
authored
Merge pull request #15702 from spowelljr/improveGoVersionUpdating
CI: Improve automated golang version updating
2 parents a777c22 + 04fa4dc commit 1784105

File tree

7 files changed

+45
-6
lines changed

7 files changed

+45
-6
lines changed

.github/workflows/update_docsy_version.yml renamed to .github/workflows/update-docsy-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- cron: "0 10 * * 1"
77
env:
88
GOPROXY: https://proxy.golang.org
9-
GO_VERSION: '1.19.3'
9+
GO_VERSION: '1.19.5'
1010
permissions:
1111
contents: read
1212

.github/workflows/update-hugo-version.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- cron: "0 10 * * 1"
77
env:
88
GOPROXY: https://proxy.golang.org
9-
GO_VERSION: '1.19.3'
9+
GO_VERSION: '1.19.5'
1010
permissions:
1111
contents: read
1212

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ KVM_GO_VERSION ?= $(GO_VERSION:.0=)
4545
INSTALL_SIZE ?= $(shell du out/minikube-windows-amd64.exe | cut -f1)
4646
BUILDROOT_BRANCH ?= 2021.02.12
4747
# the go version on the line below is for the ISO and does not need to be updated often
48-
GOLANG_OPTIONS = GO_VERSION=1.19.3 GO_HASH_FILE=$(PWD)/deploy/iso/minikube-iso/go.hash
48+
GOLANG_OPTIONS = GO_VERSION=1.19.5 GO_HASH_FILE=$(PWD)/deploy/iso/minikube-iso/go.hash
4949
BUILDROOT_OPTIONS = BR2_EXTERNAL=../../deploy/iso/minikube-iso $(GOLANG_OPTIONS)
5050
REGISTRY ?= gcr.io/k8s-minikube
5151

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
FROM golang:1.19.3
1+
FROM golang:1.19.5
22
ADD auto-pause-hook /auto-pause-hook

deploy/iso/minikube-iso/go.hash

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# From https://go.dev/dl/
2+
sha256 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 LICENSE
23
sha256 3a70e5055509f347c0fb831ca07a2bf3b531068f349b14a3c652e9b5b67beb5d go1.17.src.tar.gz
34
sha256 0012386ddcbb5f3350e407c679923811dbd283fcdc421724931614a842ecbc2d go1.18.3.src.tar.gz
45
sha256 27871baa490f3401414ad793fba49086f6c855b1c584385ed7771e1204c7e179 go1.19.1.src.tar.gz
56
sha256 2ce930d70a931de660fdaf271d70192793b1b240272645bf0275779f6704df6b go1.19.2.src.tar.gz
67
sha256 18ac263e39210bcf68d85f4370e97fb1734166995a1f63fb38b4f6e07d90d212 go1.19.3.src.tar.gz
7-
sha256 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 LICENSE
8+
sha256 8e486e8e85a281fc5ce3f0bedc5b9d2dbf6276d7db0b25d3ec034f313da0375f go1.19.5.src.tar.gz

deploy/kicbase/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
# multi-stage docker build so we can build auto-pause for arm64
22-
FROM golang:1.19.3 as auto-pause
22+
FROM golang:1.19.5 as auto-pause
2323
WORKDIR /src
2424
# auto-pause depends on core minikube code so we need to pass the whole source code as the context
2525
# copy in the minimal amount of source code possible

hack/update/golang_version/update_golang_version.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ limitations under the License.
1717
package main
1818

1919
import (
20+
"fmt"
2021
"io"
2122
"net/http"
23+
"os"
2224
"strings"
2325

2426
"k8s.io/klog/v2"
@@ -138,6 +140,7 @@ var (
138140
// searching for 1.* so it does NOT match "KVM_GO_VERSION ?= $(GO_VERSION:.0=)" in the Makefile
139141
`GO_VERSION \?= 1.*`: `GO_VERSION ?= {{.StableVersion}}`,
140142
`GO_K8S_VERSION_PREFIX \?= v1.*`: `GO_K8S_VERSION_PREFIX ?= {{.K8SVersion}}`,
143+
`GO_VERSION=[0-9.]+`: `GO_VERSION={{.StableVersion}}`,
141144
},
142145
},
143146
"hack/jenkins/installers/check_install_golang.sh": {
@@ -150,6 +153,16 @@ var (
150153
`GoVersion = ".*"`: `GoVersion = "{{.StableVersion}}"`,
151154
},
152155
},
156+
"deploy/kicbase/Dockerfile": {
157+
Replace: map[string]string{
158+
`golang:[0-9.]+`: `golang:{{.StableVersion}}`,
159+
},
160+
},
161+
"deploy/addons/auto-pause/Dockerfile": {
162+
Replace: map[string]string{
163+
`golang:.*`: `golang:{{.StableVersion}}`,
164+
},
165+
},
153166
}
154167
)
155168

@@ -176,6 +189,10 @@ func main() {
176189
klog.Infof("Golang stable version: %s", data.StableVersion)
177190

178191
update.Apply(schema, data)
192+
193+
if err := updateGoHashFile(stable); err != nil {
194+
klog.Fatalf("failed to update go hash file: %v", err)
195+
}
179196
}
180197

181198
// goVersions returns Golang stable version.
@@ -198,3 +215,24 @@ func goVersions() (stable, stableMM, k8sVersion string, err error) {
198215
stableMM = strings.Join(mmp[0:2], ".") // <major>.<minor> version
199216
return stable, stableMM, k8sVersion, nil
200217
}
218+
219+
func updateGoHashFile(version string) error {
220+
r, err := http.Get(fmt.Sprintf("https://dl.google.com/go/go%s.src.tar.gz.sha256", version))
221+
if err != nil {
222+
return fmt.Errorf("failed to download golang sha256 file: %v", err)
223+
}
224+
defer r.Body.Close()
225+
sha, err := io.ReadAll(r.Body)
226+
if err != nil {
227+
return fmt.Errorf("failed to read response body: %v", err)
228+
}
229+
f, err := os.OpenFile("../../../deploy/iso/minikube-iso/go.hash", os.O_APPEND|os.O_WRONLY, 0644)
230+
if err != nil {
231+
return fmt.Errorf("failed to open go.hash file: %v", err)
232+
}
233+
defer f.Close()
234+
if _, err := f.WriteString(fmt.Sprintf("sha256 %s go%s.src.tar.gz\n", sha, version)); err != nil {
235+
return fmt.Errorf("failed to write to go.hash file: %v", err)
236+
}
237+
return nil
238+
}

0 commit comments

Comments
 (0)