Skip to content

Commit 3a0b5cf

Browse files
authored
Merge pull request kubernetes-sigs#9343 from willie-yao/weekly-update
🌱 hack: add weekly update script for Slack
2 parents dec1667 + 7ce977e commit 3a0b5cf

File tree

6 files changed

+310
-37
lines changed

6 files changed

+310
-37
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,11 @@ release-alias-tag: ## Add the release alias tag to the last build tag
11001100

11011101
.PHONY: release-notes-tool
11021102
release-notes-tool:
1103-
go build -o bin/notes hack/tools/release/notes.go
1103+
go build -o bin/notes hack/tools/release/notes/main.go
1104+
1105+
.PHONY: release-weekly-update-tool
1106+
release-weekly-update-tool:
1107+
go build -o bin/weekly hack/tools/release/weekly/main.go
11041108

11051109
.PHONY: promote-images
11061110
promote-images: $(KPROMO)

docs/release/release-tasks.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,19 @@ The goal of this task to make the book for the current release available under e
318318
3. Update references in introduction.md only on the main branch (drop unsupported versions, add the new release version).
319319
<br>Prior art: [Add release 1.2 book link](https://github.com/kubernetes-sigs/cluster-api/pull/6697)
320320
321+
#### Generate weekly PR updates to post in Slack
322+
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:
323+
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).
324+
2. Build the release weekly update tools binary.
325+
```bash
326+
make release-weekly-update-tool
327+
```
328+
3. Generate the weekly update with the following command:
329+
```bash
330+
./bin/weekly --from YYYY-MM-DD --to YYYY-MM-DD --milestone v1.x
331+
```
332+
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`).
333+
321334
#### Create PR for release notes
322335
1. Checkout the `main` branch.
323336
1. Build the release note tools binary.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
Copyright 2021 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
// Package release is the package for the release notes generator.
18+
package release
19+
20+
// Common tags used by PRs.
21+
const (
22+
// Features is the tag used for PRs that add new features.
23+
Features = ":sparkles: New Features"
24+
25+
// Bugs is the tag used for PRs that fix bugs.
26+
Bugs = ":bug: Bug Fixes"
27+
28+
// Documentation is the tag used for PRs that update documentation.
29+
Documentation = ":book: Documentation"
30+
31+
// Proposals is the tag used for PRs that add new proposals.
32+
Proposals = ":memo: Proposals"
33+
34+
// Warning is the tag used for PRs that add breaking changes.
35+
Warning = ":warning: Breaking Changes"
36+
37+
// Other is the tag used for PRs that don't fit in any other category.
38+
Other = ":seedling: Others"
39+
40+
// Unknown is the tag used for PRs that need to be sorted by hand.
41+
Unknown = ":question: Sort these by hand"
42+
)

hack/tools/release/notes.go renamed to hack/tools/release/notes/main.go

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import (
3333
"strings"
3434
"sync"
3535
"time"
36+
37+
release "sigs.k8s.io/cluster-api/hack/tools/release/internal"
3638
)
3739

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

45-
const (
46-
features = ":sparkles: New Features"
47-
bugs = ":bug: Bug Fixes"
48-
documentation = ":book: Documentation"
49-
proposals = ":memo: Proposals"
50-
warning = ":warning: Breaking Changes"
51-
other = ":seedling: Others"
52-
unknown = ":question: Sort these by hand"
53-
)
54-
5547
var (
5648
outputOrder = []string{
57-
proposals,
58-
warning,
59-
features,
60-
bugs,
61-
other,
62-
documentation,
63-
unknown,
49+
release.Proposals,
50+
release.Warning,
51+
release.Features,
52+
release.Bugs,
53+
release.Other,
54+
release.Documentation,
55+
release.Unknown,
6456
}
6557

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

241233
merges := map[string][]string{
242-
features: {},
243-
bugs: {},
244-
documentation: {},
245-
warning: {},
246-
other: {},
247-
unknown: {},
234+
release.Features: {},
235+
release.Bugs: {},
236+
release.Documentation: {},
237+
release.Warning: {},
238+
release.Other: {},
239+
release.Unknown: {},
248240
}
249241
out, err := cmd.CombinedOutput()
250242
if err != nil {
@@ -308,7 +300,7 @@ func run() int {
308300
continue
309301
}
310302

311-
if result.prEntry.section == documentation {
303+
if result.prEntry.section == release.Documentation {
312304
merges[result.prEntry.section] = append(merges[result.prEntry.section], result.prEntry.prNumber)
313305
} else {
314306
merges[result.prEntry.section] = append(merges[result.prEntry.section], result.prEntry.title)
@@ -354,17 +346,17 @@ REPLACE ME: A couple sentences describing the deprecation, including links to do
354346
} else if count > 1 {
355347
fmt.Printf("- %d new commits merged\n", count)
356348
}
357-
if count := len(merges[warning]); count == 1 {
349+
if count := len(merges[release.Warning]); count == 1 {
358350
fmt.Println("- 1 breaking change :warning:")
359351
} else if count > 1 {
360352
fmt.Printf("- %d breaking changes :warning:\n", count)
361353
}
362-
if count := len(merges[features]); count == 1 {
354+
if count := len(merges[release.Features]); count == 1 {
363355
fmt.Println("- 1 feature addition ✨")
364356
} else if count > 1 {
365357
fmt.Printf("- %d feature additions ✨\n", count)
366358
}
367-
if count := len(merges[bugs]); count == 1 {
359+
if count := len(merges[release.Bugs]); count == 1 {
368360
fmt.Println("- 1 bug fixed 🐛")
369361
} else if count > 1 {
370362
fmt.Printf("- %d bugs fixed 🐛\n", count)
@@ -378,7 +370,7 @@ REPLACE ME: A couple sentences describing the deprecation, including links to do
378370
}
379371

380372
switch key {
381-
case documentation:
373+
case release.Documentation:
382374
sort.Strings(mergeslice)
383375
if len(mergeslice) == 1 {
384376
fmt.Printf(
@@ -507,37 +499,37 @@ func generateReleaseNoteEntry(c *commit) (*releaseNoteEntry, error) {
507499

508500
switch {
509501
case strings.HasPrefix(entry.title, ":sparkles:"), strings.HasPrefix(entry.title, "✨"):
510-
entry.section = features
502+
entry.section = release.Features
511503
entry.title = removePrefixes(entry.title, []string{":sparkles:", "✨"})
512504
case strings.HasPrefix(entry.title, ":bug:"), strings.HasPrefix(entry.title, "🐛"):
513-
entry.section = bugs
505+
entry.section = release.Bugs
514506
entry.title = removePrefixes(entry.title, []string{":bug:", "🐛"})
515507
case strings.HasPrefix(entry.title, ":book:"), strings.HasPrefix(entry.title, "📖"):
516-
entry.section = documentation
508+
entry.section = release.Documentation
517509
entry.title = removePrefixes(entry.title, []string{":book:", "📖"})
518510
if strings.Contains(entry.title, "CAEP") || strings.Contains(entry.title, "proposal") {
519-
entry.section = proposals
511+
entry.section = release.Proposals
520512
}
521513
case strings.HasPrefix(entry.title, ":warning:"), strings.HasPrefix(entry.title, "⚠️"):
522-
entry.section = warning
514+
entry.section = release.Warning
523515
entry.title = removePrefixes(entry.title, []string{":warning:", "⚠️"})
524516
case strings.HasPrefix(entry.title, "🚀"), strings.HasPrefix(entry.title, "🌱 Release v1."):
525517
// TODO(g-gaston): remove the second condition using 🌱 prefix once 1.6 is released
526518
// Release trigger PRs from previous releases are not included in the release notes
527519
return nil, nil
528520
case strings.HasPrefix(entry.title, ":seedling:"), strings.HasPrefix(entry.title, "🌱"):
529-
entry.section = other
521+
entry.section = release.Other
530522
entry.title = removePrefixes(entry.title, []string{":seedling:", "🌱"})
531523
default:
532-
entry.section = unknown
524+
entry.section = release.Unknown
533525
}
534526

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

543535
entry.title = strings.TrimSpace(entry.title)

0 commit comments

Comments
 (0)