From dcf3d757242619987207ca335f20aed93f442f67 Mon Sep 17 00:00:00 2001 From: Erik Godding Boye Date: Sat, 6 Sep 2025 14:29:35 +0200 Subject: [PATCH] Use Renovate to suggest Go upgrades Signed-off-by: Erik Godding Boye --- .github/workflows/go-auto-upgrade.yaml | 89 -------------------------- Makefile | 5 -- modules/tools/00_mod.mk | 1 + scripts/patch_go_version.sh | 70 -------------------- 4 files changed, 1 insertion(+), 164 deletions(-) delete mode 100644 .github/workflows/go-auto-upgrade.yaml delete mode 100755 scripts/patch_go_version.sh diff --git a/.github/workflows/go-auto-upgrade.yaml b/.github/workflows/go-auto-upgrade.yaml deleted file mode 100644 index 6ca58aac..00000000 --- a/.github/workflows/go-auto-upgrade.yaml +++ /dev/null @@ -1,89 +0,0 @@ -name: auto-go-upgrade -concurrency: auto-go-upgrade -on: - workflow_dispatch: {} - schedule: - # 10pm daily - - cron: '0 22 * * *' - -permissions: - contents: read - -jobs: - go_upgrade_pr: - runs-on: ubuntu-latest - - permissions: - contents: write - pull-requests: write - - env: - SOURCE_BRANCH: "${{ github.ref_name }}" - SELF_UPGRADE_BRANCH: "go-version-bump-${{ github.ref_name }}" - - steps: - - name: Fail if branch is not head of branch. - if: ${{ !startsWith(github.ref, 'refs/heads/') && env.SOURCE_BRANCH != '' && env.SELF_UPGRADE_BRANCH != '' }} - run: | - echo "This workflow should not be run on a non-branch-head." - exit 1 - - - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - - - run: | - git checkout -B "$SELF_UPGRADE_BRANCH" - - - run: | - make patch-go-version - - - id: is-up-to-date - shell: bash - run: | - git_status=$(git status -s) - is_up_to_date="true" - if [ -n "$git_status" ]; then - is_up_to_date="false" - echo "The following changes will be committed:" - echo "$git_status" - fi - echo "result=$is_up_to_date" >> "$GITHUB_OUTPUT" - - - if: ${{ steps.is-up-to-date.outputs.result != 'true' }} - run: | - git config --global user.name "cert-manager-bot" - git config --global user.email "cert-manager-bot@users.noreply.github.com" - git add -A && git commit -m "BOT: run 'make upgrade-klone' and 'make generate'" --signoff - git push -f origin "$SELF_UPGRADE_BRANCH" - - - if: ${{ steps.is-up-to-date.outputs.result != 'true' }} - uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 - with: - script: | - const { repo, owner } = context.repo; - - const pulls = await github.rest.pulls.list({ - owner: owner, - repo: repo, - head: owner + ':' + process.env.SELF_UPGRADE_BRANCH, - base: process.env.SOURCE_BRANCH, - state: 'open', - }); - - if (pulls.data.length < 1) { - const result = await github.rest.pulls.create({ - title: '[CI] Bump vendored Go version to latest patch version on ' + process.env.SOURCE_BRANCH, - owner: owner, - repo: repo, - head: process.env.SELF_UPGRADE_BRANCH, - base: process.env.SOURCE_BRANCH, - body: [ - 'This PR is auto-generated to bump the vendored go version in the tools module to the latest available patch version', - ].join('\n'), - }); - await github.rest.issues.addLabels({ - owner, - repo, - issue_number: result.data.number, - labels: ['skip-review'] - }); - } diff --git a/Makefile b/Makefile index 5fa8a307..0e0603a6 100644 --- a/Makefile +++ b/Makefile @@ -63,10 +63,6 @@ include modules/tools/00_mod.mk ## Upgrade targets -.PHONY: patch-go-version -patch-go-version: - @./scripts/patch_go_version.sh - .PHONY: upgrade-base-images upgrade-base-images: | $(NEEDS_CRANE) @CRANE=$(CRANE) \ @@ -112,7 +108,6 @@ test-e2e: help: ## Show this help @echo "Usage: make [target] ..." @echo - @echo "make patch-go-version" @echo "make upgrade-base-images" @echo "make upgrade-kind-images" @echo diff --git a/modules/tools/00_mod.mk b/modules/tools/00_mod.mk index 32639bd8..514869da 100644 --- a/modules/tools/00_mod.mk +++ b/modules/tools/00_mod.mk @@ -216,6 +216,7 @@ ADDITIONAL_TOOLS ?= tools += $(ADDITIONAL_TOOLS) # https://go.dev/dl/ +# renovate: datasource=golang-version packageName=go VENDORED_GO_VERSION := 1.24.7 # Print the go version which can be used in GH actions diff --git a/scripts/patch_go_version.sh b/scripts/patch_go_version.sh deleted file mode 100755 index 72e60c8e..00000000 --- a/scripts/patch_go_version.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -# Copyright 2022 The cert-manager 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. - -set -o errexit -set -o nounset -set -o pipefail - -# This script detects patch version updates for Go and updates the vendored -# Go version in the tools Makefile module. It also updates the SHA256 checksum -# for the vendored Go download. - -tools_makefile=../modules/tools/00_mod.mk - -script_dir=$(dirname "$(realpath "$0")") - -# Create a temporary directory to store the downloaded go version json file -tmp_dir=$(mktemp -d) -trap '{ rm -rf "$tmp_dir"; echo "> Deleted temp dir $tmp_dir"; }' EXIT - -# Download version data -curl --silent --show-error --fail --location --retry 10 --retry-connrefused https://go.dev/dl/?mode=json > "${tmp_dir}/version.json" - -LOCAL_VERSION=$(<"${script_dir}/${tools_makefile}" grep "VENDORED_GO_VERSION := " | sed "s/VENDORED_GO_VERSION := //") - -echo "current go version is $LOCAL_VERSION" - -MAJOR_MINOR_VERSION=$(echo "$LOCAL_VERSION" | grep -Eo "[0-9]+.[0-9]+") - -NEW_VERSION=$(<"${tmp_dir}/version.json" jq -r ".[] | select(.version? | match(\"$MAJOR_MINOR_VERSION.*\")) | .version | sub(\"go\";\"\")") - -# Don't want to update a minor version - only want to update patch versions! -if [[ $NEW_VERSION == "" ]]; then - echo "failed to fetch the latest version of go $MAJOR_MINOR_VERSION.*" - echo "this could mean the go version is very old or that go versioning has changed" - echo "this is likely to require manual intervention" - exit 1 -fi - -# Check if there's nothing to do -if [[ "$NEW_VERSION" == "$LOCAL_VERSION" ]]; then - echo "go version is up to date" - exit 0 -fi - -echo "updating go version to $NEW_VERSION in $tools_makefile" - -# see https://stackoverflow.com/a/53408233 -sed_args='-i''' -if [[ $(uname -s) == "Darwin" ]]; then - sed_args=(-i '') -fi - -sed "${sed_args[@]}" "s/^VENDORED_GO_VERSION := $LOCAL_VERSION$/VENDORED_GO_VERSION := $NEW_VERSION/" "${script_dir}/${tools_makefile}" - -echo "update go sha" - -"${script_dir}/learn_tools_shas.sh" _bin/tools/go