Skip to content

Commit

Permalink
Merge pull request #17704 from spowelljr/autoUpdateNerdctld
Browse files Browse the repository at this point in the history
CI: Auto update nerdctld
  • Loading branch information
medyagh committed Dec 6, 2023
2 parents c4ae734 + 4329ff0 commit f386f3f
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/update-iso-image-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
OLD_CRICTL=$(DEP=crictl make get-dependency-version)
OLD_DOCKER=$(DEP=docker make get-dependency-version)
OLD_NERDCTL=$(DEP=nerdctl make get-dependency-version)
OLD_NERDCTLD=$(DEP=nerdctld make get-dependency-version)
OLD_RUNC=$(DEP=runc make get-dependency-version)
OLD_UBUNTU=$(DEP=ubuntu make get-dependency-version)
make update-buildkit-version
Expand All @@ -32,6 +33,7 @@ jobs:
make update-crictl-version
make update-docker-version
make update-nerdctl-version
make update-nerdctld-version
make update-runc-version
make update-ubuntu-version
NEW_BUILDKIT=$(DEP=buildkit make get-dependency-version)
Expand All @@ -40,6 +42,7 @@ jobs:
NEW_CRICTL=$(DEP=crictl make get-dependency-version)
NEW_DOCKER=$(DEP=docker make get-dependency-version)
NEW_NERDCTL=$(DEP=nerdctl make get-dependency-version)
NEW_NERDCTLD=$(DEP=nerdctld make get-dependency-version)
NEW_RUNC=$(DEP=runc make get-dependency-version)
NEW_UBUNTU=$(DEP=ubuntu make get-dependency-version)
if [ "$OLD_BUILDKIT" != "$NEW_BUILDKIT" ]; then
Expand All @@ -60,6 +63,9 @@ jobs:
if [ "$OLD_NERDCTL" != "$NEW_NERDCTL" ]; then
echo "changelog=https://github.com/containerd/nerdctl/releases/tag/v$NEW_NERDCTL" >> $GITHUB_OUTPUT
fi
if [ "$OLD_NERDCTLD" != "$NEW_NERDCTLD" ]; then
echo "changelog=https://github.com/afbjorklund/nerdctld/releases/tag/v$NEW_NERDCTL" >> $GITHUB_OUTPUT
fi
if [ "$OLD_RUNC" != "$NEW_RUNC" ]; then
echo "changelog=https://github.com/opencontainers/runc/releases/tag/$NEW_RUNC" >> $GITHUB_OUTPUT
fi
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/update-nerdctld-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: "update-nerdctld-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.21.4'
permissions:
contents: read

jobs:
bump-nerdctld-version:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe
with:
go-version: ${{env.GO_VERSION}}
cache-dependency-path: ./go.sum
- name: Bump nerdctld Version
id: bumpNerdctld
run: |
echo "OLD_VERSION=$(DEP=nerdctld make get-dependency-version)" >> $GITHUB_OUTPUT
make update-nerdctld-version
echo "NEW_VERSION=$(DEP=nerdctld make get-dependency-version)" >> $GITHUB_OUTPUT
# 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.bumpNerdctld.outputs.changes != '' }}
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
with:
token: ${{ secrets.MINIKUBE_BOT_PAT }}
commit-message: 'Kicbase: Update nerdctld from ${{ steps.bumpNerdctld.outputs.OLD_VERSION }} to ${{ steps.bumpNerdctld.outputs.NEW_VERSION }}'
committer: minikube-bot <minikube-bot@google.com>
author: minikube-bot <minikube-bot@google.com>
branch: auto_bump_nerdctld_version
branch-suffix: short-commit-hash
push-to-fork: minikube-bot/minikube
base: master
delete-branch: true
title: 'Kicbase: Update nerdctld from ${{ steps.bumpNerdctld.outputs.OLD_VERSION }} to ${{ steps.bumpNerdctld.outputs.NEW_VERSION }}'
body: |
The nerdctld project released a [new version](https://github.com/afbjorklund/nerdctld/releases)
This PR was auto-generated by `make update-nerdctld-version` using [update-nerdctld-version.yml](https://github.com/kubernetes/minikube/tree/master/.github/workflows/update-nerdctld-version.yml) CI Workflow.
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
if: ${{ steps.bumpNerdctld.outputs.changes != '' }}
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'
})
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,11 @@ update-nvidia-device-plugin-version:
(cd hack/update/nvidia_device_plugin_version && \
go run update_nvidia_device_plugin_version.go)

.PHONY: update-nerctld-version
update-nerdctld-version:
(cd hack/update/nerdctld_version && \
go run update_nerdctld_version.go)

.PHONY: get-dependency-verison
get-dependency-version:
@(cd hack/update/get_version && \
Expand Down
1 change: 1 addition & 0 deletions hack/update/get_version/get_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var dependencies = map[string]dependency{
"kong-ingress-controller": {addonsFile, `kong/kubernetes-ingress-controller:(.*)@`},
"metrics-server": {addonsFile, `metrics-server/metrics-server:(.*)@`},
"nerdctl": {"deploy/kicbase/Dockerfile", `NERDCTL_VERSION="(.*)"`},
"nerdctld": {"deploy/kicbase/Dockerfile", `NERDCTLD_VERSION="(.*)"`},
"nvidia-device-plugin": {addonsFile, `nvidia/k8s-device-plugin:(.*)@`},
"registry": {addonsFile, `registry:(.*)@`},
"runc": {"deploy/iso/minikube-iso/package/runc-master/runc-master.mk", `RUNC_MASTER_VERSION = (.*)`},
Expand Down
56 changes: 56 additions & 0 deletions hack/update/nerdctld_version/update_nerdctld_version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
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"
"strings"
"time"

"k8s.io/klog/v2"
"k8s.io/minikube/hack/update"
)

var (
schema = map[string]update.Item{
"deploy/kicbase/Dockerfile": {
Replace: map[string]string{
`NERDCTLD_VERSION=.*`: `NERDCTLD_VERSION="{{.Version}}"`,
},
},
}
)

type Data struct {
Version string
}

func main() {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
defer cancel()

stable, _, _, err := update.GHReleases(ctx, "afbjorklund", "nerdctld")
if err != nil {
klog.Fatalf("Unable to get stable version: %v", err)
}

version := strings.TrimPrefix(stable.Tag, "v")

data := Data{Version: version}

update.Apply(schema, data)
}

0 comments on commit f386f3f

Please sign in to comment.