Skip to content

Commit f234a3e

Browse files
dmitshurgopherbot
authored andcommitted
internal/relui: support communicating about a single minor release
CL 418789 added workflows to do a single minor release. This adds corresponding support to the comm tasks. Deal with the fact that the new single minor release kinds need more communication parameters (for security information) in a verbose way for now, and consider it as motivation to refactor the comm task API to better fit relui's current needs in a followup change. For golang/go#53537. Change-Id: I99db09969151a3e83676ed2b59109011b53041c5 Reviewed-on: https://go-review.googlesource.com/c/build/+/419516 Run-TryBot: Dmitri Shuralyov <[email protected]> Auto-Submit: Dmitri Shuralyov <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> Reviewed-by: Heschi Kreinick <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent adb9707 commit f234a3e

File tree

8 files changed

+187
-62
lines changed

8 files changed

+187
-62
lines changed

internal/relui/workflows.go

Lines changed: 83 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,9 @@ The version string must use the same format as Go tags.`,
128128
minorVersion.Example = "go1.18.2"
129129
v1 := wd.Parameter(minorVersion)
130130
v2 := wd.Parameter(workflow.Parameter{
131-
Name: "Secondary Version",
132-
Doc: `Secondary Version is an older Go version that was also released.`,
131+
Name: "Secondary Version (optional)",
132+
Doc: `Secondary Version is an older Go version that was also released,
133+
or the empty string if only one minor release was made.`,
133134
Example: "go1.17.10",
134135
})
135136
securitySummary := wd.Parameter(securitySummaryParameter)
@@ -334,8 +335,9 @@ This is CVE-2022-24675 and Go issue https://go.dev/issue/51853.`,
334335
minorVersion := version
335336
minorVersion.Example = "go1.18.2"
336337
secondaryVersion := workflow.Parameter{
337-
Name: "SecondaryVersion",
338-
Doc: `SecondaryVersion is an older Go version that was also released.`,
338+
Name: "SecondaryVersion (optional)",
339+
Doc: `SecondaryVersion is an older Go version that was also released,
340+
or the empty string if only one minor release was made.`,
339341
Example: "go1.17.10",
340342
}
341343

@@ -418,8 +420,9 @@ It's applicable to all release types other than major
418420
minorVersion := version
419421
minorVersion.Example = "go1.18.2"
420422
secondaryVersion := workflow.Parameter{
421-
Name: "SecondaryVersion",
422-
Doc: `SecondaryVersion is an older Go version that was also released.`,
423+
Name: "SecondaryVersion (optional)",
424+
Doc: `SecondaryVersion is an older Go version that was also released,
425+
or the empty string if only one minor release was made.`,
423426
Example: "go1.17.10",
424427
}
425428

@@ -556,8 +559,12 @@ func RegisterReleaseWorkflows(ctx context.Context, h *DefinitionHolder, build *B
556559
for _, r := range releases {
557560
wd := workflow.New()
558561

559-
var names workflow.Value
562+
var securitySummary, securityFixes, names workflow.Value
560563
if mergeCommTasksIntoReleaseWorkflows {
564+
if r.kind == task.KindCurrentMinor || r.kind == task.KindPrevMinor {
565+
securitySummary = wd.Parameter(securitySummaryParameter)
566+
securityFixes = wd.Parameter(securityFixesParameter)
567+
}
561568
names = wd.Parameter(releaseCoordinatorNames)
562569
}
563570

@@ -567,37 +574,7 @@ func RegisterReleaseWorkflows(ctx context.Context, h *DefinitionHolder, build *B
567574
}
568575

569576
if mergeCommTasksIntoReleaseWorkflows {
570-
okayToAnnounceAndTweet := wd.Action("Wait to Announce", build.ApproveAction, wd.After(versionPublished))
571-
572-
// Announce that a new Go release has been published.
573-
sentMail := wd.Task("mail-announcement", func(ctx *workflow.TaskContext, v string, names []string) (task.SentMail, error) {
574-
switch r.kind {
575-
case task.KindMajor:
576-
return comm.AnnounceMajorRelease(ctx, task.ReleaseAnnouncement{Version: v, Names: names})
577-
case task.KindRC:
578-
return comm.AnnounceRCRelease(ctx, task.ReleaseAnnouncement{Version: v, Names: names})
579-
case task.KindBeta:
580-
return comm.AnnounceBetaRelease(ctx, task.ReleaseAnnouncement{Version: v, Names: names})
581-
default:
582-
return task.SentMail{}, fmt.Errorf("unknown release kind %v", r.kind)
583-
}
584-
}, versionPublished, names, wd.After(okayToAnnounceAndTweet))
585-
announcementURL := wd.Task("await-announcement", comm.AwaitAnnounceMail, sentMail)
586-
tweetURL := wd.Task("post-tweet", func(ctx *workflow.TaskContext, v, ann string) (string, error) {
587-
switch r.kind {
588-
case task.KindMajor:
589-
return comm.TweetMajorRelease(ctx, task.ReleaseTweet{Version: v})
590-
case task.KindRC:
591-
return comm.TweetRCRelease(ctx, task.ReleaseTweet{Version: v, Announcement: ann})
592-
case task.KindBeta:
593-
return comm.TweetBetaRelease(ctx, task.ReleaseTweet{Version: v, Announcement: ann})
594-
default:
595-
return "", fmt.Errorf("unknown release kind %v", r.kind)
596-
}
597-
}, versionPublished, announcementURL, wd.After(okayToAnnounceAndTweet))
598-
599-
wd.Output("Announcement URL", announcementURL)
600-
wd.Output("Tweet URL", tweetURL)
577+
addCommTasksForSingleRelease(wd, build, comm, r.kind, versionPublished, securitySummary, securityFixes, names)
601578
}
602579

603580
h.RegisterDefinition(fmt.Sprintf("Go 1.%d %s", r.major, r.suffix), wd)
@@ -654,22 +631,78 @@ func createMinorReleaseWorkflow(build *BuildReleaseTasks, milestone *task.Milest
654631
}
655632

656633
if mergeCommTasksIntoReleaseWorkflows {
657-
okayToAnnounceAndTweet := wd.Action("Wait to Announce", build.ApproveAction, wd.After(v1Published, v2Published))
634+
addCommTasksForDoubleMinorRelease(wd, build, comm, v1Published, v2Published, securitySummary, securityFixes, names)
635+
}
658636

659-
// Announce that a new Go release has been published.
660-
sentMail := wd.Task("mail-announcement", func(ctx *workflow.TaskContext, v1, v2 string, sec, names []string) (task.SentMail, error) {
661-
return comm.AnnounceMinorRelease(ctx, task.ReleaseAnnouncement{Version: v1, SecondaryVersion: v2, Security: sec, Names: names})
662-
}, v1Published, v2Published, securityFixes, names, wd.After(okayToAnnounceAndTweet))
663-
announcementURL := wd.Task("await-announcement", comm.AwaitAnnounceMail, sentMail)
664-
tweetURL := wd.Task("post-tweet", func(ctx *workflow.TaskContext, v1, v2, sec, ann string) (string, error) {
665-
return comm.TweetMinorRelease(ctx, task.ReleaseTweet{Version: v1, SecondaryVersion: v2, Security: sec, Announcement: ann})
666-
}, v1Published, v2Published, securitySummary, announcementURL, wd.After(okayToAnnounceAndTweet))
637+
return wd, nil
638+
}
667639

668-
wd.Output("Announcement URL", announcementURL)
669-
wd.Output("Tweet URL", tweetURL)
640+
func addCommTasksForDoubleMinorRelease(
641+
wd *workflow.Definition, build *BuildReleaseTasks, comm task.CommunicationTasks,
642+
v1Published, v2Published, securitySummary, securityFixes, names workflow.Value,
643+
) {
644+
okayToAnnounceAndTweet := wd.Action("Wait to Announce", build.ApproveAction, wd.After(v1Published, v2Published))
645+
646+
// Announce that a new Go release has been published.
647+
sentMail := wd.Task("mail-announcement", func(ctx *workflow.TaskContext, v1, v2 string, sec, names []string) (task.SentMail, error) {
648+
return comm.AnnounceMinorRelease(ctx, task.ReleaseAnnouncement{Version: v1, SecondaryVersion: v2, Security: sec, Names: names})
649+
}, v1Published, v2Published, securityFixes, names, wd.After(okayToAnnounceAndTweet))
650+
announcementURL := wd.Task("await-announcement", comm.AwaitAnnounceMail, sentMail)
651+
tweetURL := wd.Task("post-tweet", func(ctx *workflow.TaskContext, v1, v2, sec, ann string) (string, error) {
652+
return comm.TweetMinorRelease(ctx, task.ReleaseTweet{Version: v1, SecondaryVersion: v2, Security: sec, Announcement: ann})
653+
}, v1Published, v2Published, securitySummary, announcementURL, wd.After(okayToAnnounceAndTweet))
654+
655+
wd.Output("Announcement URL", announcementURL)
656+
wd.Output("Tweet URL", tweetURL)
657+
}
658+
func addCommTasksForSingleRelease(
659+
wd *workflow.Definition, build *BuildReleaseTasks, comm task.CommunicationTasks,
660+
kind task.ReleaseKind, versionPublished, securitySummary, securityFixes, names workflow.Value,
661+
) {
662+
okayToAnnounceAndTweet := wd.Action("Wait to Announce", build.ApproveAction, wd.After(versionPublished))
663+
664+
// Announce that a new Go release has been published.
665+
var announcementURL, tweetURL workflow.Value
666+
if kind == task.KindCurrentMinor || kind == task.KindPrevMinor {
667+
sentMail := wd.Task("mail-announcement", func(ctx *workflow.TaskContext, v string, sec, names []string) (task.SentMail, error) {
668+
return comm.AnnounceMinorRelease(ctx, task.ReleaseAnnouncement{Version: v, Security: sec, Names: names})
669+
}, versionPublished, securityFixes, names, wd.After(okayToAnnounceAndTweet))
670+
announcementURL = wd.Task("await-announcement", comm.AwaitAnnounceMail, sentMail)
671+
tweetURL = wd.Task("post-tweet", func(ctx *workflow.TaskContext, v, sec, ann string) (string, error) {
672+
return comm.TweetMinorRelease(ctx, task.ReleaseTweet{Version: v, Security: sec, Announcement: ann})
673+
}, versionPublished, securitySummary, announcementURL, wd.After(okayToAnnounceAndTweet))
674+
} else {
675+
// TODO(dmitshur): This can be simplified on this side by deleting older things that use this API,
676+
// and then merging all the Announce{Kind}Release variants into a single AnnounceRelease entrypoint.
677+
sentMail := wd.Task("mail-announcement", func(ctx *workflow.TaskContext, v string, names []string) (task.SentMail, error) {
678+
switch kind {
679+
case task.KindMajor:
680+
return comm.AnnounceMajorRelease(ctx, task.ReleaseAnnouncement{Version: v, Names: names})
681+
case task.KindRC:
682+
return comm.AnnounceRCRelease(ctx, task.ReleaseAnnouncement{Version: v, Names: names})
683+
case task.KindBeta:
684+
return comm.AnnounceBetaRelease(ctx, task.ReleaseAnnouncement{Version: v, Names: names})
685+
default:
686+
return task.SentMail{}, fmt.Errorf("unknown release kind %v", kind)
687+
}
688+
}, versionPublished, names, wd.After(okayToAnnounceAndTweet))
689+
announcementURL = wd.Task("await-announcement", comm.AwaitAnnounceMail, sentMail)
690+
tweetURL = wd.Task("post-tweet", func(ctx *workflow.TaskContext, v, ann string) (string, error) {
691+
switch kind {
692+
case task.KindMajor:
693+
return comm.TweetMajorRelease(ctx, task.ReleaseTweet{Version: v})
694+
case task.KindRC:
695+
return comm.TweetRCRelease(ctx, task.ReleaseTweet{Version: v, Announcement: ann})
696+
case task.KindBeta:
697+
return comm.TweetBetaRelease(ctx, task.ReleaseTweet{Version: v, Announcement: ann})
698+
default:
699+
return "", fmt.Errorf("unknown release kind %v", kind)
700+
}
701+
}, versionPublished, announcementURL, wd.After(okayToAnnounceAndTweet))
670702
}
671703

672-
return wd, nil
704+
wd.Output("Announcement URL", announcementURL)
705+
wd.Output("Tweet URL", tweetURL)
673706
}
674707

675708
func addSingleReleaseWorkflow(

internal/task/announce.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ type ReleaseAnnouncement struct {
3939
// • "go1.18beta1" or "go1.18rc1" for a pre-release
4040
Version string
4141
// SecondaryVersion is an older Go version that was also released.
42-
// This only applies to minor releases. For example, "go1.16.10".
42+
// This only applies to minor releases when two releases are made.
43+
// For example, "go1.16.10".
4344
SecondaryVersion string
4445

4546
// Security is a list of descriptions, one for each distinct
@@ -77,7 +78,9 @@ type SentMail struct {
7778

7879
// AnnounceMinorRelease sends an email announcing a minor Go release to Google Groups.
7980
func (t AnnounceMailTasks) AnnounceMinorRelease(ctx *workflow.TaskContext, r ReleaseAnnouncement) (SentMail, error) {
80-
if err := verifyGoVersions(r.Version, r.SecondaryVersion); err != nil {
81+
if err := verifyGoVersions(r.Version); err != nil {
82+
return SentMail{}, err
83+
} else if err := verifyGoVersions(r.SecondaryVersion); r.SecondaryVersion != "" && err != nil {
8184
return SentMail{}, err
8285
}
8386

internal/task/announce_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ This is CVE-2022-27536 and https://go.dev/issue/51759.`,
8080
},
8181
wantSubject: "[security] Go 1.18.1 and Go 1.17.9 are released",
8282
},
83+
{
84+
name: "minor-solo",
85+
in: ReleaseAnnouncement{
86+
Version: "go1.11.1",
87+
Security: []string{"abc: security fix 1", "xyz: security fix 2"},
88+
Names: []string{"Alice"},
89+
},
90+
wantSubject: "[security] Go 1.11.1 is released",
91+
},
8392
{
8493
name: "beta",
8594
in: ReleaseAnnouncement{

internal/task/template/announce-minor.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
Subject: {{subjectPrefix .}}
2-
Go {{short .Version}} and Go {{short .SecondaryVersion}} are released
2+
Go {{short .Version}} {{with .SecondaryVersion}}and Go {{. | short}} are{{else}}is{{end}} released
33

44
Hello gophers,
55

6+
{{if .SecondaryVersion -}}
67
We have just released Go versions {{short .Version}} and {{short .SecondaryVersion}}, minor point releases.
7-
8-
{{with .Security}}These minor releases include {{len .}} security fixes following the [security policy](https://go.dev/security):
9-
{{range .}}
8+
{{- else -}}
9+
We have just released Go version {{short .Version}}, a minor point release.
10+
{{- end}}
11+
12+
{{if .Security}}{{if .SecondaryVersion -}}
13+
These minor releases include
14+
{{- else -}}
15+
This minor release includes{{end}} {{len .Security}} security fixes following the [security policy](https://go.dev/security):
16+
{{range .Security}}
1017
-{{indent .}}
1118
{{end}}
1219
{{end -}}
@@ -20,7 +27,7 @@ https://go.dev/dl/
2027
To compile from source using a Git clone, update to the release with
2128
`git checkout {{.Version}}` and build as usual.
2229

23-
Thanks to everyone who contributed to the releases.
30+
Thanks to everyone who contributed to the release{{if .SecondaryVersion}}s{{end}}.
2431

2532
Cheers,
2633
{{with .Names}}{{join .}} for the{{else}}The{{end}} Go team
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<p>Hello gophers,</p>
2+
<p>We have just released Go version 1.11.1, a minor point release.</p>
3+
<p>This minor release includes 2 security fixes following the <a href="https://go.dev/security">security policy</a>:</p>
4+
<ul>
5+
<li>
6+
<p>abc: security fix 1</p>
7+
</li>
8+
<li>
9+
<p>xyz: security fix 2</p>
10+
</li>
11+
</ul>
12+
<p>View the release notes for more information:<br>
13+
<a href="https://go.dev/doc/devel/release#go1.11.1">https://go.dev/doc/devel/release#go1.11.1</a></p>
14+
<p>You can download binary and source distributions from the Go website:<br>
15+
<a href="https://go.dev/dl/">https://go.dev/dl/</a></p>
16+
<p>To compile from source using a Git clone, update to the release with<br>
17+
<code>git checkout go1.11.1</code> and build as usual.</p>
18+
<p>Thanks to everyone who contributed to the release.</p>
19+
<p>Cheers,<br>
20+
Alice for the Go team</p>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Hello gophers,
2+
3+
We have just released Go version 1.11.1, a minor point release.
4+
5+
This minor release includes 2 security fixes following the security policy <https://go.dev/security>:
6+
7+
- abc: security fix 1
8+
9+
- xyz: security fix 2
10+
11+
View the release notes for more information:
12+
https://go.dev/doc/devel/release#go1.11.1
13+
14+
You can download binary and source distributions from the Go website:
15+
https://go.dev/dl/
16+
17+
To compile from source using a Git clone, update to the release with
18+
git checkout go1.11.1 and build as usual.
19+
20+
Thanks to everyone who contributed to the release.
21+
22+
Cheers,
23+
Alice for the Go team

internal/task/tweet.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ type ReleaseTweet struct {
4343
// • "go1.18beta1" or "go1.18rc1" for a pre-release
4444
Version string
4545
// SecondaryVersion is an older Go version that was also released.
46-
// This only applies to minor releases. For example, "go1.16.10".
46+
// This only applies to minor releases when two releases are made.
47+
// For example, "go1.16.10".
4748
SecondaryVersion string
4849

4950
// Security is an optional sentence describing security fixes
@@ -93,7 +94,9 @@ type TweetTasks struct {
9394
// TweetMinorRelease posts a tweet announcing a minor Go release.
9495
// ErrTweetTooLong is returned if the inputs result in a tweet that's too long.
9596
func (t TweetTasks) TweetMinorRelease(ctx *workflow.TaskContext, r ReleaseTweet) (tweetURL string, _ error) {
96-
if err := verifyGoVersions(r.Version, r.SecondaryVersion); err != nil {
97+
if err := verifyGoVersions(r.Version); err != nil {
98+
return "", err
99+
} else if err := verifyGoVersions(r.SecondaryVersion); r.SecondaryVersion != "" && err != nil {
97100
return "", err
98101
}
99102
if !strings.HasPrefix(r.Announcement, announcementPrefix) {
@@ -241,7 +244,7 @@ func tweetText(r ReleaseTweet, rnd *rand.Rand) (string, error) {
241244
ReleaseTweet
242245
}{
243246
Curr: r.Version[len("go"):],
244-
Prev: r.SecondaryVersion[len("go"):],
247+
Prev: strings.TrimPrefix(r.SecondaryVersion, "go"),
245248
ReleaseTweet: r,
246249
}
247250
} else {
@@ -256,7 +259,7 @@ func tweetText(r ReleaseTweet, rnd *rand.Rand) (string, error) {
256259
}
257260

258261
const tweetTextTmpl = `{{define "minor" -}}
259-
{{emoji "release"}} Go {{.Curr}} and {{.Prev}} are released!
262+
{{emoji "release"}} Go {{.Curr}} {{with .Prev}}and {{.}} are{{else}}is{{end}} released!
260263
261264
{{with .Security}}{{emoji "security"}} Security: {{.}}{{"\n\n"}}{{end -}}
262265
@@ -441,7 +444,7 @@ func fetchRandomArchive(goVer string, rnd *rand.Rand) (archive golangorgDLFile,
441444
func fetchReleaseArchives(goVer string) (archives []golangorgDLFile, _ error) {
442445
url := "https://go.dev/dl/?mode=json"
443446
if strings.Contains(goVer, "beta") || strings.Contains(goVer, "rc") ||
444-
goVer == "go1.17" || goVer == "go1.17.1" /* For TestTweetRelease. */ {
447+
goVer == "go1.17" || goVer == "go1.17.1" || goVer == "go1.11.1" /* For TestTweetRelease. */ {
445448

446449
url += "&include=all"
447450
}

internal/task/tweet_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,33 @@ Unpacking go1.17.1.linux-arm64.tar.gz ...
6565
Success. You may now run 'go1.17.1'
6666
$ go1.17.1 version
6767
go version go1.17.1 linux/arm64` + "\n",
68+
},
69+
{
70+
name: "minor-solo",
71+
taskFn: TweetTasks.TweetMinorRelease,
72+
in: ReleaseTweet{
73+
Version: "go1.11.1",
74+
Announcement: "https://groups.google.com/g/golang-announce/c/pFXKAfoVJqw",
75+
RandomSeed: 23,
76+
},
77+
wantLog: `tweet text:
78+
🎆 Go 1.11.1 is released!
79+
80+
📣 Announcement: https://groups.google.com/g/golang-announce/c/pFXKAfoVJqw
81+
82+
📦 Download: https://go.dev/dl/#go1.11.1
83+
84+
#golang
85+
tweet image:
86+
$ go install golang.org/dl/go1.11.1@latest
87+
$ go1.11.1 download
88+
Downloaded 0.0% ( 0 / 124181190 bytes) ...
89+
Downloaded 50.0% ( 62090595 / 124181190 bytes) ...
90+
Downloaded 100.0% (124181190 / 124181190 bytes)
91+
Unpacking go1.11.1.darwin-amd64.tar.gz ...
92+
Success. You may now run 'go1.11.1'
93+
$ go1.11.1 version
94+
go version go1.11.1 darwin/amd64` + "\n",
6895
},
6996
{
7097
name: "beta",

0 commit comments

Comments
 (0)