Skip to content

Commit f8c8cc4

Browse files
authored
Merge pull request kubernetes-csi#237 from msau42/prow
Add script to generate patch release notes
2 parents b36b5bf + 2c625d4 commit f8c8cc4

File tree

2 files changed

+140
-43
lines changed

2 files changed

+140
-43
lines changed

SIDECAR_RELEASE_PROCESS.md

+34-43
Original file line numberDiff line numberDiff line change
@@ -46,54 +46,45 @@ naming convention `<hostpath-deployment-version>-on-<kubernetes-version>`.
4646
## Release Process
4747
1. Identify all issues and ongoing PRs that should go into the release, and
4848
drive them to resolution.
49-
1. Download the latest version of the
50-
[K8s release notes generator](https://github.com/kubernetes/release/tree/HEAD/cmd/release-notes)
51-
1. Create a
52-
[Github personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
53-
with `repo:public_repo` access
54-
1. Generate release notes for the release. Replace arguments with the relevant
55-
information.
56-
* Clean up old cached information (also needed if you are generating release
57-
notes for multiple repos)
58-
```bash
59-
rm -rf /tmp/k8s-repo
60-
```
61-
* For new minor releases on master:
62-
```bash
63-
GITHUB_TOKEN=<token> release-notes \
64-
--discover=mergebase-to-latest \
65-
--org=kubernetes-csi \
66-
--repo=external-provisioner \
67-
--required-author="" \
68-
--markdown-links \
69-
--output out.md
70-
```
71-
* For new patch releases on a release branch:
72-
```bash
73-
GITHUB_TOKEN=<token> release-notes \
74-
--discover=patch-to-latest \
75-
--branch=release-1.1 \
76-
--org=kubernetes-csi \
77-
--repo=external-provisioner \
78-
--required-author="" \
79-
--markdown-links \
80-
--output out.md
81-
```
82-
1. Compare the generated output to the new commits for the release to check if
83-
any notable change missed a release note.
84-
1. Reword release notes as needed. Make sure to check notes for breaking
85-
changes and deprecations.
86-
1. If release is a new major/minor version, create a new `CHANGELOG-<major>.<minor>.md`
87-
file. Otherwise, add the release notes to the top of the existing CHANGELOG
88-
file for that minor version.
89-
1. Submit a PR for the CHANGELOG changes.
90-
1. Submit a PR for README changes, in particular, Compatibility, Feature status,
91-
and any other sections that may need updating.
9249
1. Check that all [canary CI
9350
jobs](https://testgrid.k8s.io/sig-storage-csi-ci) are passing,
9451
and that test coverage is adequate for the changes that are going into the release.
9552
1. Check that the post-\<sidecar\>-push-images builds are succeeding.
9653
[Example](https://testgrid.k8s.io/sig-storage-image-build#post-external-snapshotter-push-images)
54+
1. Generate release notes.
55+
1. Download the latest version of the [K8s release notes generator](https://github.com/kubernetes/release/tree/HEAD/cmd/release-notes)
56+
1. Create a
57+
[Github personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token)
58+
with `repo:public_repo` access
59+
1. For patch release, use the script generate_patch_release_notes.sh. Read the instructions at the top of the
60+
script. The script also creates PRs for each branch.
61+
1. For new minor releases, follow these steps and replace arguments with the relevant
62+
information.
63+
* Clean up old cached information (also needed if you are generating release
64+
notes for multiple repos)
65+
```bash
66+
rm -rf /tmp/k8s-repo
67+
```
68+
* For new minor releases on master:
69+
```bash
70+
GITHUB_TOKEN=<token> release-notes \
71+
--discover=mergebase-to-latest \
72+
--org=kubernetes-csi \
73+
--repo=external-provisioner \
74+
--required-author="" \
75+
--markdown-links \
76+
--output out.md
77+
```
78+
1. Compare the generated output to the new commits for the release to check if
79+
any notable change missed a release note.
80+
1. Reword release notes as needed, ideally in the original PRs so that the
81+
release notes can be regnerated. Make sure to check notes for breaking
82+
changes and deprecations.
83+
1. If release is a new major/minor version, create a new `CHANGELOG-<major>.<minor>.md`
84+
file.
85+
1. Submit a PR for the CHANGELOG changes.
86+
1. Submit a PR for README changes, in particular, Compatibility, Feature status,
87+
and any other sections that may need updating.
9788
1. Make sure that no new PRs have merged in the meantime, and no PRs are in
9889
flight and soon to be merged.
9990
1. Create a new release following a previous release as a template. Be sure to select the correct

generate_patch_release_notes.sh

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash
2+
3+
# Copyright 2023 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+
# Usage: generate_patch_release_notes.sh
19+
#
20+
# Generates and creates PRs for kubernetes-csi patch releases.
21+
#
22+
# Required environment variables
23+
# CSI_RELEASE_TOKEN: Github token needed for generating release notes
24+
# GITHUB_USER: Github username to create PRs with
25+
#
26+
# Instructions:
27+
# 1. Login with "gh auth login"
28+
# 2. Copy this script to the kubernetes-csi directory (one directory above the
29+
# repos)
30+
# 3. Update the repos and versions in the $releases array
31+
# 4. Set environment variables
32+
# 5. Run script from the kubernetes-csi directory
33+
#
34+
# Caveats:
35+
# - This script doesn't handle regenerating and updating existing PRs yet.
36+
# It might work if you comment out the PR creation line
37+
38+
set -e
39+
set -x
40+
41+
releases=(
42+
# "external-attacher 4.4.1"
43+
# "external-provisioner 3.6.1"
44+
# "external-snapshotter 6.2.3"
45+
)
46+
47+
function gen_patch_relnotes() {
48+
rm out.md || true
49+
rm -rf /tmp/k8s-repo || true
50+
GITHUB_TOKEN="$CSI_RELEASE_TOKEN" \
51+
release-notes --discover=patch-to-latest --branch="$2" \
52+
--org=kubernetes-csi --repo="$1" \
53+
--required-author="" --markdown-links --output out.md
54+
}
55+
56+
for rel in "${releases[@]}"; do
57+
read -r repo version <<< "$rel"
58+
59+
# Parse minor version
60+
minorPattern="(^[[:digit:]]+\.[[:digit:]]+)\."
61+
[[ "$version" =~ $minorPattern ]]
62+
minor="${BASH_REMATCH[1]}"
63+
64+
echo "$repo" "$version" "$minor"
65+
66+
pushd "$repo/CHANGELOG"
67+
68+
git fetch upstream
69+
70+
# Create branch
71+
branch="changelog-release-$minor"
72+
git checkout master
73+
git branch -D "$branch" || true
74+
git checkout --track "upstream/release-$minor" -b "$branch"
75+
76+
# Generate release notes
77+
gen_patch_relnotes "$repo" "release-$minor"
78+
cat > tmp.md <<EOF
79+
# Release notes for v$version
80+
81+
[Documentation](https://kubernetes-csi.github.io)
82+
83+
EOF
84+
85+
cat out.md >> tmp.md
86+
echo >> tmp.md
87+
88+
file="CHANGELOG-$minor.md"
89+
cat "$file" >> tmp.md
90+
mv tmp.md "$file"
91+
92+
git add -u
93+
git commit -m "Add changelog for $version"
94+
git push -f origin "$branch"
95+
96+
# Create PR
97+
prbody=$(cat <<EOF
98+
\`\`\`release-note
99+
NONE
100+
\`\`\`
101+
EOF
102+
)
103+
gh pr create --title="Changelog for v$version" --body "$prbody" --head "$GITHUB_USER:$branch" --base "release-$minor" --repo="kubernetes-csi/$repo"
104+
105+
popd
106+
done

0 commit comments

Comments
 (0)