Skip to content

WIP: scripts for common devtasks #17390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions devtasks/automation/create_release/create_release.sh
Original file line number Diff line number Diff line change
@@ -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}"
76 changes: 76 additions & 0 deletions devtasks/automation/publish_artifacts/publish_artifacts.sh
Original file line number Diff line number Diff line change
@@ -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/[email protected]"

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}
54 changes: 54 additions & 0 deletions devtasks/automation/smoke_test_release/smoke_test_release.sh
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions devtasks/automation/stage_github_release/stage_github_release.sh
Original file line number Diff line number Diff line change
@@ -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}/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a bug in shipbot - The 1.32.0 release notes include PRs going back to Kops 1.19 like #10049

Loading