From edd1230767baefed4ef882f28d768fca0ff5d544 Mon Sep 17 00:00:00 2001 From: Sharif Elgamal Date: Thu, 13 May 2021 09:40:55 -0700 Subject: [PATCH] add script to automatically release storage provisioner --- Makefile | 2 + hack/jenkins/storage_provisioner.sh | 67 +++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 hack/jenkins/storage_provisioner.sh diff --git a/Makefile b/Makefile index 7f7015be97..3ac8ec8fa4 100644 --- a/Makefile +++ b/Makefile @@ -736,7 +736,9 @@ TAG = $(STORAGE_PROVISIONER_TAG) .PHONY: push-storage-provisioner-manifest push-storage-provisioner-manifest: $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~storage\-provisioner\-image\-&~g") ## Push multi-arch storage-provisioner image +ifndef CIBUILD docker login gcr.io/k8s-minikube +endif set -x; for arch in $(ALL_ARCH); do docker push ${IMAGE}-$${arch}:${TAG}; done docker manifest create --amend $(IMAGE):$(TAG) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(TAG)~g") set -x; for arch in $(ALL_ARCH); do docker manifest annotate --arch $${arch} ${IMAGE}:${TAG} ${IMAGE}-$${arch}:${TAG}; done diff --git a/hack/jenkins/storage_provisioner.sh b/hack/jenkins/storage_provisioner.sh new file mode 100644 index 0000000000..f1abdc3ce2 --- /dev/null +++ b/hack/jenkins/storage_provisioner.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Copyright 2021 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. + +set -x -o pipefail + +# Make sure docker is installed and configured +./hack/jenkins/installers/check_install_docker.sh +yes|gcloud auth configure-docker + +# Make sure gh is installed and configured +./hack/jenkins/installers/check_install_gh.sh + +# Grab current storage provisioner version and bump it +SP_VERSION=$(egrep "STORAGE_PROVISIONER_TAG \?=" Makefile | cut -d ' ' -f 3) + +# SP_VERSION is going to be of the form "v4", grab that number, increment it, and tack the v back on +RAW_VERSION=${SP_VERSION:1} +RAW_VERSION=$((RAW_VERSION+1)) +SP_VERSION=v${RAW_VERSION} + +SED="sed -i" +if [ "$(uname)" == "Darwin" ]; then + SED="sed -i ''" +fi + +# Write the new version back into the Makefile +${SED} "s/STORAGE_PROVISIONER_TAG ?= .*/STORAGE_PROVISIONER_TAG ?= ${SP_VERSION}/" Makefile + +# Build the new image +CIBUILD=yes make push-storage-provisioner-manifest + +ec=$? +if [ $ec -gt 0 ]; then + exit $ec +fi + +# Bump the preload version +PLV=$(egrep "PreloadVersion =" pkg/minikube/download/preload.go | cut -d \" -f 2) +RAW=${PLV:1} +RAW=$((RAW+1)) +PLV=v${RAW} + +${SED} "s/PreloadVersion = .*/PreloadVersion = \"${PLV}\"/" pkg/minikube/download/preload.go + +# Open a PR with the changes +branch=storage-provisioner-${SP_VERSION} +git checkout -b ${branch} + +git add Makefile pkg/minikube/download/preload.go +git commit -m "Update storage provisioner to ${SP_VERSION}" +git remote add minikube-bot git@github.com:minikube-bot/minikube.git +git push -f minikube-bot ${branch} + +gh pr create --fill --base master --head minikube-bot:${branch}