add workflow to update gh version

pull/15393/head
Steven Powell 2022-11-22 09:52:40 -08:00
parent 07324c6188
commit e83741569a
9 changed files with 146 additions and 10 deletions

50
.github/workflows/update-gh-version.yml vendored Normal file
View File

@ -0,0 +1,50 @@
name: "update-gh-version"
on:
workflow_dispatch:
schedule:
# every Monday at around 3 am pacific/10 am UTC
- cron: "0 10 * * 1"
env:
GOPROXY: https://proxy.golang.org
GO_VERSION: '1.19.3'
permissions:
contents: read
jobs:
bump-gh-version:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
- uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f
with:
go-version: ${{env.GO_VERSION}}
- name: Bump gh version
id: bumpGh
run: |
make update-gh-version
# The following is to support multiline with GITHUB_OUTPUT, see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
echo "changes<<EOF" >> $GITHUB_OUTPUT
echo "$(git status --porcelain)" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create PR
if: ${{ steps.bumpGh.outputs.changes != '' }}
uses: peter-evans/create-pull-request@b4d51739f96fca8047ad065eccef63442d8e99f7
with:
token: ${{ secrets.MINIKUBE_BOT_PAT }}
commit-message: bump gh versions
committer: minikube-bot <minikube-bot@google.com>
author: minikube-bot <minikube-bot@google.com>
branch: auto_bump_gh_version
push-to-fork: minikube-bot/minikube
base: master
delete-branch: true
title: 'bump gh version'
labels: ok-to-test
body: |
gh project released a [new version](https://github.com/cli/cli/releases),
This PR was auto-generated by `make update-gh-version` using [update-gh-version.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-gh-version.yml) CI Workflow.

View File

@ -41,7 +41,7 @@ jobs:
title: 'bump golint version'
labels: ok-to-test
body: |
Golangci-lint Project release a [new version](https://github.com/golangci/golangci-lint/releases),
Golangci-lint Project released a [new version](https://github.com/golangci/golangci-lint/releases),
This PR was auto-generated by `make update-golint-version` using [update-golint-version.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-golint-version.yml) CI Workflow.

View File

@ -41,6 +41,6 @@ jobs:
title: 'bump gotestsum version'
labels: ok-to-test
body: |
Gotestsum Project release a [new version](https://github.com/gotestyourself/gotestsum/releases),
Gotestsum Project released a [new version](https://github.com/gotestyourself/gotestsum/releases),
This PR was auto-generated by `make update-gotestsum-version` using [update-gotestsum-version.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-gotestsum-version.yml) CI Workflow.

View File

@ -1056,6 +1056,11 @@ update-gotestsum-version:
(cd hack/update/gotestsum_version && \
go run update_gotestsum_version.go)
.PHONY: update-gh-version
update-gh-version:
(cd hack/update/gh_version && \
go run update_gh_version.go)
.PHONY: generate-licenses
generate-licenses:
./hack/generate_licenses.sh

View File

@ -16,12 +16,14 @@
set -eux -o pipefail
GH_VERSION="2.18.1"
echo "Installing latest version of gh"
curl -qLO "https://github.com/cli/cli/releases/download/v2.18.1/gh_2.18.1_linux_amd64.tar.gz"
tar -xf gh_2.18.1_linux_amd64.tar.gz &&
sudo mv gh_2.18.1_linux_amd64/bin/gh /usr/local/bin/gh
rm gh_2.18.1_linux_amd64.tar.gz
rm -rf gh_2.18.1_linux_amd64
curl -qLO "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz"
tar -xf "gh_${GH_VERSION}_linux_amd64.tar.gz" &&
sudo mv "gh_${GH_VERSION}_linux_amd64/bin/gh" /usr/local/bin/gh
rm "gh_${GH_VERSION}_linux_amd64.tar.gz"
rm -rf "gh_${GH_VERSION}_linux_amd64"
echo "Authorizing bot with gh"
echo "${access_token}" | gh auth login --with-token

View File

@ -57,7 +57,7 @@ var (
}
)
// Data holds stable gotestsum version in semver format.
// Data holds stable cri-dockerd version in semver format.
type Data struct {
FullCommit string
ShortCommit string
@ -76,7 +76,7 @@ func main() {
update.Apply(schema, data)
if out, err := exec.Command("./update_cri_dockerd.sh", commit, archs).CombinedOutput(); err != nil {
log.Fatalf("failed to build and upload cri-docker binaries: %s", string(out))
log.Fatalf("failed to build and upload cri-dockerd binaries: %s", string(out))
}
fmt.Println("Don't forget you still need to update the hash files!")

View File

@ -0,0 +1,74 @@
/*
Copyright 2022 The Kubernetes Authors All rights reserved.
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.
*/
package main
import (
"context"
"strings"
"time"
"golang.org/x/mod/semver"
"k8s.io/klog/v2"
"k8s.io/minikube/hack/update"
)
const (
// default context timeout
cxTimeout = 5 * time.Minute
)
var (
schema = map[string]update.Item{
"hack/jenkins/installers/check_install_gh.sh": {
Replace: map[string]string{
`GH_VERSION=".*"`: `GH_VERSION="{{.StableVersion}}"`,
},
},
}
)
// Data holds stable gh version in semver format.
type Data struct {
StableVersion string
}
func main() {
// set a context with defined timeout
ctx, cancel := context.WithTimeout(context.Background(), cxTimeout)
defer cancel()
// get gh stable version
stable, err := ghVersion(ctx, "cli", "cli")
if err != nil {
klog.Fatalf("Unable to get gh stable version: %v", err)
}
data := Data{StableVersion: stable}
klog.Infof("gh stable version: %s", data.StableVersion)
update.Apply(schema, data)
}
// ghVersion returns stable version in semver format.
func ghVersion(ctx context.Context, owner, repo string) (stable string, err error) {
// get Kubernetes versions from GitHub Releases
stable, _, _, err = update.GHReleases(ctx, owner, repo)
if err != nil || !semver.IsValid(stable) {
return "", err
}
return strings.TrimPrefix(stable, "v"), nil
}

View File

@ -93,6 +93,11 @@ var (
`GO_VERSION: .*`: `GO_VERSION: '{{.StableVersion}}'`,
},
},
".github/workflows/update-gh-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}}'`,

View File

@ -41,7 +41,7 @@ var (
}
)
// Data holds stable gopogh version in semver format.
// Data holds stable golint version in semver format.
type Data struct {
StableVersion string
}