Skip to content

Commit

Permalink
Add weekly update script
Browse files Browse the repository at this point in the history
  • Loading branch information
willie-yao committed Nov 1, 2023
1 parent 8bef2f3 commit 7ce977e
Show file tree
Hide file tree
Showing 6 changed files with 310 additions and 37 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,11 @@ release-alias-tag: ## Add the release alias tag to the last build tag

.PHONY: release-notes-tool
release-notes-tool:
go build -o bin/notes hack/tools/release/notes.go
go build -o bin/notes hack/tools/release/notes/main.go

.PHONY: release-weekly-update-tool
release-weekly-update-tool:
go build -o bin/weekly hack/tools/release/weekly/main.go

.PHONY: promote-images
promote-images: $(KPROMO)
Expand Down
13 changes: 13 additions & 0 deletions docs/release/release-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,19 @@ The goal of this task to make the book for the current release available under e
3. Update references in introduction.md only on the main branch (drop unsupported versions, add the new release version).
<br>Prior art: [Add release 1.2 book link](https://github.com/kubernetes-sigs/cluster-api/pull/6697)
#### Generate weekly PR updates to post in Slack
The goal of this task is to keep the CAPI community updated on recent PRs that have been merged. This is done by using the weekly update tool in `hack/tools/release/weekly/main.go`. Here is how to use it:
1. Checkout the latest commit on the release branch, e.g. `release-1.4`, or the main branch if the release branch doesn't yet exist (e.g. beta release).
2. Build the release weekly update tools binary.
```bash
make release-weekly-update-tool
```
3. Generate the weekly update with the following command:
```bash
./bin/weekly --from YYYY-MM-DD --to YYYY-MM-DD --milestone v1.x
```
4. Paste the output into a new Slack message in the [`#cluster-api`](https://kubernetes.slack.com/archives/C8TSNPY4T) channel. Currently, we post separate messages in a thread for `main` and the two most recent release branches (e.g. `release-1.5` and `release-1.4`).
#### Create PR for release notes
1. Checkout the `main` branch.
1. Build the release note tools binary.
Expand Down
42 changes: 42 additions & 0 deletions hack/tools/release/internal/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2021 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.
*/

// Package release is the package for the release notes generator.
package release

// Common tags used by PRs.
const (
// Features is the tag used for PRs that add new features.
Features = ":sparkles: New Features"

// Bugs is the tag used for PRs that fix bugs.
Bugs = ":bug: Bug Fixes"

// Documentation is the tag used for PRs that update documentation.
Documentation = ":book: Documentation"

// Proposals is the tag used for PRs that add new proposals.
Proposals = ":memo: Proposals"

// Warning is the tag used for PRs that add breaking changes.
Warning = ":warning: Breaking Changes"

// Other is the tag used for PRs that don't fit in any other category.
Other = ":seedling: Others"

// Unknown is the tag used for PRs that need to be sorted by hand.
Unknown = ":question: Sort these by hand"
)
64 changes: 28 additions & 36 deletions hack/tools/release/notes.go → hack/tools/release/notes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import (
"strings"
"sync"
"time"

release "sigs.k8s.io/cluster-api/hack/tools/release/internal"
)

/*
Expand All @@ -42,25 +44,15 @@ This needs to be run *before* a tag is created.
Use these as the base of your release notes.
*/

const (
features = ":sparkles: New Features"
bugs = ":bug: Bug Fixes"
documentation = ":book: Documentation"
proposals = ":memo: Proposals"
warning = ":warning: Breaking Changes"
other = ":seedling: Others"
unknown = ":question: Sort these by hand"
)

var (
outputOrder = []string{
proposals,
warning,
features,
bugs,
other,
documentation,
unknown,
release.Proposals,
release.Warning,
release.Features,
release.Bugs,
release.Other,
release.Documentation,
release.Unknown,
}

repo = flag.String("repository", "kubernetes-sigs/cluster-api", "The repo to run the tool from.")
Expand Down Expand Up @@ -239,12 +231,12 @@ func run() int {
}

merges := map[string][]string{
features: {},
bugs: {},
documentation: {},
warning: {},
other: {},
unknown: {},
release.Features: {},
release.Bugs: {},
release.Documentation: {},
release.Warning: {},
release.Other: {},
release.Unknown: {},
}
out, err := cmd.CombinedOutput()
if err != nil {
Expand Down Expand Up @@ -308,7 +300,7 @@ func run() int {
continue
}

if result.prEntry.section == documentation {
if result.prEntry.section == release.Documentation {
merges[result.prEntry.section] = append(merges[result.prEntry.section], result.prEntry.prNumber)
} else {
merges[result.prEntry.section] = append(merges[result.prEntry.section], result.prEntry.title)
Expand Down Expand Up @@ -354,17 +346,17 @@ REPLACE ME: A couple sentences describing the deprecation, including links to do
} else if count > 1 {
fmt.Printf("- %d new commits merged\n", count)
}
if count := len(merges[warning]); count == 1 {
if count := len(merges[release.Warning]); count == 1 {
fmt.Println("- 1 breaking change :warning:")
} else if count > 1 {
fmt.Printf("- %d breaking changes :warning:\n", count)
}
if count := len(merges[features]); count == 1 {
if count := len(merges[release.Features]); count == 1 {
fmt.Println("- 1 feature addition ✨")
} else if count > 1 {
fmt.Printf("- %d feature additions ✨\n", count)
}
if count := len(merges[bugs]); count == 1 {
if count := len(merges[release.Bugs]); count == 1 {
fmt.Println("- 1 bug fixed 🐛")
} else if count > 1 {
fmt.Printf("- %d bugs fixed 🐛\n", count)
Expand All @@ -378,7 +370,7 @@ REPLACE ME: A couple sentences describing the deprecation, including links to do
}

switch key {
case documentation:
case release.Documentation:
sort.Strings(mergeslice)
if len(mergeslice) == 1 {
fmt.Printf(
Expand Down Expand Up @@ -507,37 +499,37 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {

switch {
case strings.HasPrefix(entry.title, ":sparkles:"), strings.HasPrefix(entry.title, "✨"):
entry.section = features
entry.section = release.Features
entry.title = removePrefixes(entry.title, []string{":sparkles:", "✨"})
case strings.HasPrefix(entry.title, ":bug:"), strings.HasPrefix(entry.title, "🐛"):
entry.section = bugs
entry.section = release.Bugs
entry.title = removePrefixes(entry.title, []string{":bug:", "🐛"})
case strings.HasPrefix(entry.title, ":book:"), strings.HasPrefix(entry.title, "📖"):
entry.section = documentation
entry.section = release.Documentation
entry.title = removePrefixes(entry.title, []string{":book:", "📖"})
if strings.Contains(entry.title, "CAEP") || strings.Contains(entry.title, "proposal") {
entry.section = proposals
entry.section = release.Proposals
}
case strings.HasPrefix(entry.title, ":warning:"), strings.HasPrefix(entry.title, "⚠️"):
entry.section = warning
entry.section = release.Warning
entry.title = removePrefixes(entry.title, []string{":warning:", "⚠️"})
case strings.HasPrefix(entry.title, "🚀"), strings.HasPrefix(entry.title, "🌱 Release v1."):
// TODO(g-gaston): remove the second condition using 🌱 prefix once 1.6 is released
// Release trigger PRs from previous releases are not included in the release notes
return nil, nil
case strings.HasPrefix(entry.title, ":seedling:"), strings.HasPrefix(entry.title, "🌱"):
entry.section = other
entry.section = release.Other
entry.title = removePrefixes(entry.title, []string{":seedling:", "🌱"})
default:
entry.section = unknown
entry.section = release.Unknown
}

// If the area label indicates documentation, use documentation as the section
// no matter what was the emoji used. This takes into account that the area label
// tends to be more accurate than the emoji (data point observed by the release team).
// We handle this after the switch statement to make sure we remove all emoji prefixes.
if area == documentationAreaLabel {
entry.section = documentation
entry.section = release.Documentation
}

entry.title = strings.TrimSpace(entry.title)
Expand Down
File renamed without changes.
Loading

0 comments on commit 7ce977e

Please sign in to comment.