CI: cron to auto update runc
parent
87f0bd60af
commit
13afd5f0d8
|
@ -0,0 +1,68 @@
|
|||
name: "update-runc-version"
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# every Tuesday at around 3 am pacific/10 am UTC
|
||||
- cron: "0 10 * * 2"
|
||||
env:
|
||||
GOPROXY: https://proxy.golang.org
|
||||
GO_VERSION: '1.20.2'
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
bump-runc-version:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@8f4b7f84864484a7bf31766abe9204da3cbe65b3
|
||||
- uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
|
||||
with:
|
||||
go-version: ${{env.GO_VERSION}}
|
||||
cache-dependency-path: ./go.sum
|
||||
- name: Bump runc Version
|
||||
id: bumpRunc
|
||||
run: |
|
||||
make update-runc-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
|
||||
id: createPR
|
||||
if: ${{ steps.bumpRunc.outputs.changes != '' }}
|
||||
uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54
|
||||
with:
|
||||
token: ${{ secrets.MINIKUBE_BOT_PAT }}
|
||||
commit-message: bump runc version
|
||||
committer: minikube-bot <minikube-bot@google.com>
|
||||
author: minikube-bot <minikube-bot@google.com>
|
||||
branch: auto_bump_runc_version
|
||||
branch-suffix: short-commit-hash
|
||||
push-to-fork: minikube-bot/minikube
|
||||
base: master
|
||||
delete-branch: true
|
||||
title: 'bump runc version'
|
||||
body: |
|
||||
runc Project released a [new version](https://github.com/opencontainers/runc/releases),
|
||||
|
||||
This PR was auto-generated by `make update-runc-version` using [update-runc-version.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-runc-version.yml) CI Workflow.
|
||||
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
|
||||
with:
|
||||
github-token: ${{ secrets.MINIKUBE_BOT_PAT }}
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: ${{ steps.createPR.outputs.pull-request-number }},
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: 'ok-to-build-image'
|
||||
})
|
||||
- uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975
|
||||
with:
|
||||
github-token: ${{ secrets.MINIKUBE_BOT_PAT }}
|
||||
script: |
|
||||
github.rest.issues.createComment({
|
||||
issue_number: ${{ steps.createPR.outputs.pull-request-number }},
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: 'ok-to-build-iso'
|
||||
})
|
5
Makefile
5
Makefile
|
@ -1097,6 +1097,11 @@ update-metrics-server-version:
|
|||
(cd hack/update/metrics_server_version && \
|
||||
go run update_metrics_server_version.go)
|
||||
|
||||
.PHONY: update-runc-version
|
||||
update-runc-version:
|
||||
(cd hack/update/runc_version && \
|
||||
go run update_runc_version.go)
|
||||
|
||||
.PHONY: generate-licenses
|
||||
generate-licenses:
|
||||
./hack/generate_licenses.sh
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#
|
||||
################################################################################
|
||||
|
||||
# As of 2022-08-25, v1.1.4
|
||||
RUNC_MASTER_VERSION = 5fd4c4d144137e991c4acebb2146ab1483a97925
|
||||
RUNC_MASTER_VERSION = v1.1.4
|
||||
RUNC_MASTER_COMMIT = 5fd4c4d144137e991c4acebb2146ab1483a97925
|
||||
RUNC_MASTER_SITE = https://github.com/opencontainers/runc/archive
|
||||
RUNC_MASTER_SOURCE = $(RUNC_MASTER_VERSION).tar.gz
|
||||
RUNC_MASTER_LICENSE = Apache-2.0
|
||||
|
@ -40,7 +40,7 @@ define RUNC_MASTER_CONFIGURE_CMDS
|
|||
endef
|
||||
|
||||
define RUNC_MASTER_BUILD_CMDS
|
||||
PWD=$(RUNC_MASTER_COMPILE_SRC) $(RUNC_MASTER_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) BUILDTAGS="$(RUNC_MASTER_GOTAGS)" COMMIT_NO=$(RUNC_MASTER_VERSION) COMMIT=$(RUNC_MASTER_VERSION) PREFIX=/usr
|
||||
PWD=$(RUNC_MASTER_COMPILE_SRC) $(RUNC_MASTER_MAKE_ENV) $(MAKE) $(TARGET_CONFIGURE_OPTS) -C $(@D) BUILDTAGS="$(RUNC_MASTER_GOTAGS)" COMMIT_NO=$(RUNC_MASTER_COMMIT) COMMIT=$(RUNC_MASTER_COMMIT) PREFIX=/usr
|
||||
endef
|
||||
|
||||
define RUNC_MASTER_INSTALL_TARGET_CMDS
|
||||
|
|
|
@ -150,6 +150,11 @@ var (
|
|||
`GO_VERSION: .*`: `GO_VERSION: '{{.StableVersion}}'`,
|
||||
},
|
||||
},
|
||||
".github/workflows/update-runc-version.yml": {
|
||||
Replace: map[string]string{
|
||||
`GO_VERSION: .*`: `GO_VERSION: '{{.StableVersion}}'`,
|
||||
},
|
||||
},
|
||||
".github/workflows/sync-minikube.yml": {
|
||||
Replace: map[string]string{
|
||||
`GO_VERSION: .*`: `GO_VERSION: '{{.StableVersion}}'`,
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
Copyright 2023 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"
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"k8s.io/klog/v2"
|
||||
"k8s.io/minikube/hack/update"
|
||||
)
|
||||
|
||||
const cxTimeout = 5 * time.Minute
|
||||
|
||||
var (
|
||||
schema = map[string]update.Item{
|
||||
"deploy/iso/minikube-iso/package/runc-master/runc-master.mk": {
|
||||
Replace: map[string]string{
|
||||
`RUNC_MASTER_VERSION = .*`: `RUNC_MASTER_VERSION = {{.Version}}`,
|
||||
`RUNC_MASTER_COMMIT = .*`: `RUNC_MASTER_COMMIT = {{.Commit}}`,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
Version string
|
||||
Commit string
|
||||
}
|
||||
|
||||
func main() {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), cxTimeout)
|
||||
defer cancel()
|
||||
|
||||
stable, _, _, err := update.GHReleases(ctx, "opencontainers", "runc")
|
||||
if err != nil {
|
||||
klog.Fatalf("Unable to get runc stable version: %v", err)
|
||||
}
|
||||
|
||||
data := Data{Version: stable.Tag, Commit: stable.Commit}
|
||||
|
||||
update.Apply(schema, data)
|
||||
|
||||
if err := updateHashFiles(data.Version); err != nil {
|
||||
klog.Fatalf("failed to update hash files: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func updateHashFiles(version string) error {
|
||||
r, err := http.Get(fmt.Sprintf("https://github.com/opencontainers/runc/archive/%s.tar.gz", version))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to download source code: %v", err)
|
||||
}
|
||||
defer r.Body.Close()
|
||||
b, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read response body: %v", err)
|
||||
}
|
||||
sum := sha256.Sum256(b)
|
||||
filePath := "../../../deploy/iso/minikube-iso/package/runc-master/runc-master.hash"
|
||||
b, err = os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read hash file: %v", err)
|
||||
}
|
||||
if strings.Contains(string(b), version) {
|
||||
klog.Infof("hash file already contains %q", version)
|
||||
return nil
|
||||
}
|
||||
f, err := os.OpenFile(filePath, os.O_APPEND|os.O_WRONLY, 0644)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to open hash file: %v", err)
|
||||
}
|
||||
defer f.Close()
|
||||
if _, err := f.WriteString(fmt.Sprintf("sha256 %x %s.tar.gz\n", sum, version)); err != nil {
|
||||
return fmt.Errorf("failed to write to hash file: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Reference in New Issue