diff --git a/devtasks/automation/create_release/create_release.sh b/devtasks/automation/create_release/create_release.sh new file mode 100755 index 0000000000000..07fdec6724d33 --- /dev/null +++ b/devtasks/automation/create_release/create_release.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# Copyright 2024 The Kubernetes 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 + +set -x + +if [[ -z "${VERSION:-}" ]]; then + echo "Must specify VERSION" + exit 1 +fi + +GITHUB_USER=$(gh api user | jq -r '.login') + +MAJOR=$(echo $VERSION | cut -d. -f1) +MINOR=$(echo $VERSION | cut -d. -f2) +PATCH=$(echo $VERSION | cut -d. -f3-) + +RELEASE_BRANCH="release-${MAJOR}.${MINOR}" + +PR_BRANCH_NAME=create_release_${VERSION} + +# If first beta (.0-beta.1) +if [[ "${PATCH}" == "0-beta.1" ]]; then + RELEASE_BRANCH="master" +fi + +WORKDIR=$(mktemp -d -t workflow.XXXXXXXX) +echo "WORKDIR is ${WORKDIR}" + +git clone https://github.com/kubernetes/kops ${WORKDIR}/kops -b ${RELEASE_BRANCH} --depth=10 +cd ${WORKDIR}/kops +gh repo set-default kubernetes/kops + +git checkout ${RELEASE_BRANCH} +git checkout -b ${PR_BRANCH_NAME} + +hack/set-version ${VERSION} + +hack/update-expected.sh || true # Expected to fail first time because there will be updates +find . -name "*.bak" -delete +hack/update-expected.sh 2>&1 # Expected to succeed second time because there should be no updates +find . -name "*.bak" -delete + +VERSION=$(tools/get_version.sh | grep VERSION | awk '{print $2}') +git add . && git commit -m "Release ${VERSION}" + +git remote add fork https://github.com/${GITHUB_USER}/kops +git push fork --force + +pwd +gh pr create -l tide/merge-method-squash \ + --base ${RELEASE_BRANCH} --head ${GITHUB_USER}:${PR_BRANCH_NAME} \ + --title "Release ${VERSION}" \ + --body "Release ${VERSION}" \ No newline at end of file diff --git a/devtasks/automation/publish_artifacts/publish_artifacts.sh b/devtasks/automation/publish_artifacts/publish_artifacts.sh new file mode 100755 index 0000000000000..e61cc02080d32 --- /dev/null +++ b/devtasks/automation/publish_artifacts/publish_artifacts.sh @@ -0,0 +1,76 @@ +#!/bin/bash + +# Copyright 2024 The Kubernetes 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 + +set -x + +if [[ -z "${VERSION:-}" ]]; then + echo "Must specify VERSION" + exit 1 +fi + +GITHUB_USER=$(gh api user | jq -r '.login') + +kpromo="go run sigs.k8s.io/promo-tools/v4/cmd/kpromo@v4.0.4" + +WORKDIR=$(mktemp -d -t workflow.XXXXXXXX) +echo "WORKDIR is ${WORKDIR}" + +git clone https://github.com/kubernetes/k8s.io ${WORKDIR}/k8s.io --depth=8 +cd ${WORKDIR}/k8s.io +gh repo set-default kubernetes/k8s.io + +git remote add fork https://github.com/${GITHUB_USER}/k8s.io + +# Promote images +cd ${WORKDIR}/k8s.io + +git checkout main +git pull origin main +git checkout -b kops_images_${VERSION} + +echo "" >> registry.k8s.io/images/k8s-staging-kops/images.yaml +echo "# ${VERSION}" >> registry.k8s.io/images/k8s-staging-kops/images.yaml +${kpromo} cip run --snapshot gcr.io/k8s-staging-kops --snapshot-tag ${VERSION} >> registry.k8s.io/images/k8s-staging-kops/images.yaml + +git add registry.k8s.io/images/k8s-staging-kops/images.yaml +git commit -m "Promote kOps $VERSION images" + +git push fork --force +gh pr create --fill --base main --head ${GITHUB_USER}:kops_images_${VERSION} + + +# Promote binary artifacts +cd ${WORKDIR}/k8s.io + +git checkout main +git pull origin main +git checkout -b kops_artifacts_${VERSION} + +rm -rf ./k8s-staging-kops/kops/releases +mkdir -p ./k8s-staging-kops/kops/releases/${VERSION}/ +gsutil rsync -r gs://k8s-staging-kops/kops/releases/${VERSION}/ ./k8s-staging-kops/kops/releases/${VERSION}/ + +${kpromo} manifest files --src k8s-staging-kops/kops/releases/ >> artifacts/manifests/k8s-staging-kops/${VERSION}.yaml + +git add artifacts/manifests/k8s-staging-kops/${VERSION}.yaml +git commit -m "Promote kOps $VERSION binary artifacts" + +git push fork --force +gh pr create --fill --base main --head ${GITHUB_USER}:kops_artifacts_${VERSION} diff --git a/devtasks/automation/smoke_test_release/smoke_test_release.sh b/devtasks/automation/smoke_test_release/smoke_test_release.sh new file mode 100755 index 0000000000000..2433a61a07602 --- /dev/null +++ b/devtasks/automation/smoke_test_release/smoke_test_release.sh @@ -0,0 +1,54 @@ +# Copyright 2024 The Kubernetes 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. + +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +set -x + +if [[ -z "${VERSION:-}" ]]; then + echo "Must specify VERSION" + exit 1 +fi + +WORKDIR=$(mktemp -d -t workflow.XXXXXXXX) +echo "WORKDIR is ${WORKDIR}" + +cd "${WORKDIR}" +wget https://artifacts.k8s.io/binaries/kops/${VERSION}/linux/amd64/kops + +chmod +x kops + +# Verify version works +./kops version + +# Verify version matches the version we expect +./kops version | grep ${VERSION} + +GCP_PROJECT=$(gcloud config get project) +export KOPS_STATE_STORE="gs://kops-state-${GCP_PROJECT}/" + +./kops get cluster || true # ignore error if cluster doesn't exist + +# TEMP HACK +./kops delete cluster smoketest.k8s.local --yes || true + +./kops create cluster smoketest.k8s.local --zones us-east4-a +./kops update cluster smoketest.k8s.local --yes --admin +./kops validate cluster --wait=10m + +./kops delete cluster smoketest.k8s.local --yes diff --git a/devtasks/automation/stage_github_release/stage_github_release.sh b/devtasks/automation/stage_github_release/stage_github_release.sh new file mode 100755 index 0000000000000..54cf6f8c1ed6a --- /dev/null +++ b/devtasks/automation/stage_github_release/stage_github_release.sh @@ -0,0 +1,42 @@ +# Copyright 2024 The Kubernetes 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. + +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +set -x + +if [[ -z "${VERSION:-}" ]]; then + echo "Must specify VERSION" + exit 1 +fi + +shipbot="go run github.com/kopeio/shipbot/cmd/shipbot@master" + +WORKDIR=$(mktemp -d -t workflow.XXXXXXXX) +echo "WORKDIR is ${WORKDIR}" + +git clone https://github.com/kubernetes/kops ${WORKDIR}/kops +cd ${WORKDIR}/kops +gh repo set-default kubernetes/kops + +rm -rf ${WORKDIR}/releases +mkdir -p ${WORKDIR}/releases/${VERSION}/ +gsutil rsync -r gs://k8s-staging-kops/kops/releases/${VERSION}/ ${WORKDIR}/releases/${VERSION}/ + +git checkout v$VERSION +${shipbot} -tag v${VERSION} -config .shipbot.yaml -src ${WORKDIR}/releases/${VERSION}/