Skip to content

Commit a5f6c5c

Browse files
committed
WIP: scripts for common devtasks
1 parent abdc58d commit a5f6c5c

File tree

4 files changed

+243
-0
lines changed

4 files changed

+243
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
# Copyright 2024 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
set -o errexit
19+
set -o nounset
20+
set -o pipefail
21+
22+
set -x
23+
24+
if [[ -z "${VERSION:-}" ]]; then
25+
echo "Must specify VERSION"
26+
exit 1
27+
fi
28+
29+
GITHUB_USER=$(gh api user | jq -r '.login')
30+
31+
MAJOR=$(echo $VERSION | cut -d. -f1)
32+
MINOR=$(echo $VERSION | cut -d. -f2)
33+
PATCH=$(echo $VERSION | cut -d. -f3-)
34+
35+
RELEASE_BRANCH="release-${MAJOR}.${MINOR}"
36+
37+
PR_BRANCH_NAME=create_release_${VERSION}
38+
39+
# If first beta (.0-beta.1)
40+
if [[ "${PATCH}" == "0-beta.1" ]]; then
41+
RELEASE_BRANCH="master"
42+
fi
43+
44+
WORKDIR=$(mktemp -d -t workflow.XXXXXXXX)
45+
echo "WORKDIR is ${WORKDIR}"
46+
47+
git clone https://github.com/kubernetes/kops ${WORKDIR}/kops -b ${RELEASE_BRANCH} --depth=10
48+
cd ${WORKDIR}/kops
49+
gh repo set-default kubernetes/kops
50+
51+
git checkout ${RELEASE_BRANCH}
52+
git checkout -b ${PR_BRANCH_NAME}
53+
54+
hack/set-version ${VERSION}
55+
56+
hack/update-expected.sh || true # Expected to fail first time because there will be updates
57+
find . -name "*.bak" -delete
58+
hack/update-expected.sh 2>&1 # Expected to succeed second time because there should be no updates
59+
find . -name "*.bak" -delete
60+
61+
VERSION=$(tools/get_version.sh | grep VERSION | awk '{print $2}')
62+
git add . && git commit -m "Release ${VERSION}"
63+
64+
git remote add fork https://github.com/${GITHUB_USER}/kops
65+
git push fork --force
66+
67+
pwd
68+
gh pr create -l tide/merge-method-squash \
69+
--base ${RELEASE_BRANCH} --head ${GITHUB_USER}:${PR_BRANCH_NAME} \
70+
--title "Release ${VERSION}" \
71+
--body "Release ${VERSION}"
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
# Copyright 2024 The Kubernetes Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
set -x
22+
23+
if [[ -z "${VERSION:-}" ]]; then
24+
echo "Must specify VERSION"
25+
exit 1
26+
fi
27+
28+
GITHUB_USER=$(gh api user | jq -r '.login')
29+
30+
kpromo="go run sigs.k8s.io/promo-tools/v4/cmd/kpromo@v4.0.4"
31+
32+
WORKDIR=$(mktemp -d -t workflow.XXXXXXXX)
33+
echo "WORKDIR is ${WORKDIR}"
34+
35+
git clone https://github.com/kubernetes/k8s.io ${WORKDIR}/k8s.io --depth=8
36+
cd ${WORKDIR}/k8s.io
37+
gh repo set-default kubernetes/k8s.io
38+
39+
git remote add fork https://github.com/${GITHUB_USER}/k8s.io
40+
41+
# Promote images
42+
cd ${WORKDIR}/k8s.io
43+
44+
git checkout main
45+
git pull origin main
46+
git checkout -b kops_images_${VERSION}
47+
48+
echo "" >> registry.k8s.io/images/k8s-staging-kops/images.yaml
49+
echo "# ${VERSION}" >> registry.k8s.io/images/k8s-staging-kops/images.yaml
50+
${kpromo} cip run --snapshot gcr.io/k8s-staging-kops --snapshot-tag ${VERSION} >> registry.k8s.io/images/k8s-staging-kops/images.yaml
51+
52+
git add registry.k8s.io/images/k8s-staging-kops/images.yaml
53+
git commit -m "Promote kOps $VERSION images"
54+
55+
git push fork --force
56+
gh pr create --fill --base main --head ${GITHUB_USER}:kops_images_${VERSION}
57+
58+
59+
# Promote binary artifacts
60+
cd ${WORKDIR}/k8s.io
61+
62+
git checkout main
63+
git pull origin main
64+
git checkout -b kops_artifacts_${VERSION}
65+
66+
rm -rf ./k8s-staging-kops/kops/releases
67+
mkdir -p ./k8s-staging-kops/kops/releases/${VERSION}/
68+
gsutil rsync -r gs://k8s-staging-kops/kops/releases/${VERSION}/ ./k8s-staging-kops/kops/releases/${VERSION}/
69+
70+
${kpromo} manifest files --src k8s-staging-kops/kops/releases/ >> artifacts/manifests/k8s-staging-kops/${VERSION}.yaml
71+
72+
git add artifacts/manifests/k8s-staging-kops/${VERSION}.yaml
73+
git commit -m "Promote kOps $VERSION binary artifacts"
74+
75+
git push fork --force
76+
gh pr create --fill --base main --head ${GITHUB_USER}:kops_artifacts_${VERSION}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2024 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#!/bin/bash
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
set -x
22+
23+
if [[ -z "${VERSION:-}" ]]; then
24+
echo "Must specify VERSION"
25+
exit 1
26+
fi
27+
28+
WORKDIR=$(mktemp -d -t workflow.XXXXXXXX)
29+
echo "WORKDIR is ${WORKDIR}"
30+
31+
cd "${WORKDIR}"
32+
wget https://artifacts.k8s.io/binaries/kops/${VERSION}/linux/amd64/kops
33+
34+
chmod +x kops
35+
36+
# Verify version works
37+
./kops version
38+
39+
# Verify version matches the version we expect
40+
./kops version | grep ${VERSION}
41+
42+
GCP_PROJECT=$(gcloud config get project)
43+
export KOPS_STATE_STORE="gs://kops-state-${GCP_PROJECT}/"
44+
45+
./kops get cluster || true # ignore error if cluster doesn't exist
46+
47+
# TEMP HACK
48+
./kops delete cluster smoketest.k8s.local --yes || true
49+
50+
./kops create cluster smoketest.k8s.local --zones us-east4-a
51+
./kops update cluster smoketest.k8s.local --yes --admin
52+
./kops validate cluster --wait=10m
53+
54+
./kops delete cluster smoketest.k8s.local --yes
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Copyright 2024 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
#!/bin/bash
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
set -x
22+
23+
if [[ -z "${VERSION:-}" ]]; then
24+
echo "Must specify VERSION"
25+
exit 1
26+
fi
27+
28+
shipbot="go run github.com/kopeio/shipbot/cmd/shipbot@master"
29+
30+
WORKDIR=$(mktemp -d -t workflow.XXXXXXXX)
31+
echo "WORKDIR is ${WORKDIR}"
32+
33+
git clone https://github.com/kubernetes/kops ${WORKDIR}/kops
34+
cd ${WORKDIR}/kops
35+
gh repo set-default kubernetes/kops
36+
37+
rm -rf ${WORKDIR}/releases
38+
mkdir -p ${WORKDIR}/releases/${VERSION}/
39+
gsutil rsync -r gs://k8s-staging-kops/kops/releases/${VERSION}/ ${WORKDIR}/releases/${VERSION}/
40+
41+
git checkout v$VERSION
42+
${shipbot} -tag v${VERSION} -config .shipbot.yaml -src ${WORKDIR}/releases/${VERSION}/

0 commit comments

Comments
 (0)