From e883950d77cd10ad1f5fe46a798e594ea4e91420 Mon Sep 17 00:00:00 2001 From: Medya Gh Date: Mon, 26 Jul 2021 15:56:21 -0700 Subject: [PATCH] add a bot to bump golang version atuomatically --- .github/workflows/update-golang-version.yml | 43 +++++++++++++++++++ Makefile | 8 +++- .../golang_version/update_golang_version.go | 26 +++++------ 3 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/update-golang-version.yml diff --git a/.github/workflows/update-golang-version.yml b/.github/workflows/update-golang-version.yml new file mode 100644 index 0000000000..7cfbd1317f --- /dev/null +++ b/.github/workflows/update-golang-version.yml @@ -0,0 +1,43 @@ +name: "update-golang-versions" +on: + workflow_dispatch: + schedule: + # every Monday at around 2 am pacific/9 am UTC + - cron: "0 9 * * 1" +env: + GOPROXY: https://proxy.golang.org + GO_VERSION: 1.16.4 +jobs: + bump-k8s-versions: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-go@v2 + with: + go-version: ${{env.GO_VERSION}} + stable: true + - name: Bump Golang Versions + id: bumGolang + run: | + make update-golang-version + echo "::set-output name=changes::$(git status --porcelain)" + - name: Create PR + if: ${{ steps.bumpGolang.outputs.changes != '' }} + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.MINIKUBE_BOT_PAT }} + commit-message: bump golang versions + committer: minikube-bot + author: minikube-bot + branch: auto_bump_golang_version + push-to-fork: minikube-bot/minikube + base: master + delete-branch: true + title: 'bump golang version' + labels: ok-to-test + body: | + This PR was auto-generated by `make update-golang-version` using [update-golang-versions.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-golang-version.yml) CI Workflow. + Please only merge if all the tests pass and if kubernetes pushed an image for this golang https://github.com/kubernetes/kubernetes/blob/master/build/build-image/cross/VERSION + + ${{ steps.bumpk8s.outputs.changes }} + diff --git a/Makefile b/Makefile index 5fce61484c..2d27162b33 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ RPM_VERSION ?= $(DEB_VERSION) RPM_REVISION ?= 0 # used by hack/jenkins/release_build_and_upload.sh and KVM_BUILD_IMAGE, see also BUILD_IMAGE below -GO_VERSION ?= 1.16.4 +GO_VERSION ?= 1.16.6 # replace "x.y.0" => "x.y". kube-cross and golang.org/dl use different formats for x.y.0 go versions KVM_GO_VERSION ?= $(GO_VERSION:.0=) @@ -958,6 +958,12 @@ help: @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' + +.PHONY: update-golang-version +update-golang-version: + (cd hack/update/golang_version && \ + go run update_golang_version.go) + .PHONY: update-kubernetes-version update-kubernetes-version: (cd hack/update/kubernetes_version && \ diff --git a/hack/update/golang_version/update_golang_version.go b/hack/update/golang_version/update_golang_version.go index 15ec5691db..28710884e4 100644 --- a/hack/update/golang_version/update_golang_version.go +++ b/hack/update/golang_version/update_golang_version.go @@ -80,7 +80,17 @@ var ( `GO_VERSION: '.*`: `GO_VERSION: '{{.StableVersion}}'`, }, }, - ".github/workflows/update_k8s_versions.yml": { + ".github/workflows/update-k8s-versions.yml": { + Replace: map[string]string{ + `GO_VERSION: '.*`: `GO_VERSION: '{{.StableVersion}}'`, + }, + }, + ".github/workflows/update-golang-version.yml": { + Replace: map[string]string{ + `GO_VERSION: '.*`: `GO_VERSION: '{{.StableVersion}}'`, + }, + }, + ".github/workflows/time-to-k8s-public-chart.yml": { Replace: map[string]string{ `GO_VERSION: '.*`: `GO_VERSION: '{{.StableVersion}}'`, }, @@ -90,17 +100,6 @@ var ( `GO_VERSION: '.*`: `GO_VERSION: '{{.StableVersion}}'`, }, }, - ".github/workflows/time-to-k8s-public-chart.yaml": { - Replace: map[string]string{ - `GO_VERSION: '.*`: `GO_VERSION: '{{.StableVersion}}'`, - }, - }, - ".travis.yml": { - Replace: map[string]string{ - `go:\n - .*`: `go:{{printf "\n - %s" .StableVersion}}`, - `go: .*`: `go: {{.StableVersion}}`, - }, - }, "go.mod": { Replace: map[string]string{ `(?m)^go .*`: `go {{.StableVersionMM}}`, @@ -113,7 +112,8 @@ var ( }, "Makefile": { Replace: map[string]string{ - `GO_VERSION \?= .*`: `GO_VERSION ?= {{.StableVersion}}`, + // searching for 1.* so it does NOT match "KVM_GO_VERSION ?= $(GO_VERSION:.0=)" in the Makefile + `GO_VERSION \?= 1.*`: `GO_VERSION ?= {{.StableVersion}}`, }, }, }