feat(release): allow creation of multiple patch release events (#63034)

* allow creation of multiple patch release events

* skip old month releases

* update config
This commit is contained in:
Bolaji Olajide 2024-06-03 16:14:24 +01:00 committed by GitHub
parent 7c8668c455
commit 9e2b56119f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 51 additions and 34 deletions

View File

@ -24,10 +24,10 @@ import (
)
type Event struct {
Name string `json:"name"`
BranchCutDate time.Time `json:"branchCutDate"`
MonthlyReleaseDate time.Time `json:"monthlyReleaseDate"`
PatchReleaseDate time.Time `json:"patchReleaseDate"`
Name string `json:"name"`
BranchCutDate time.Time `json:"branchCutDate"`
MonthlyReleaseDate time.Time `json:"monthlyReleaseDate"`
PatchReleaseDates []time.Time `json:"patchReleaseDates"`
}
type CalendarConfig struct {
@ -60,8 +60,23 @@ func generateCalendarEvents(cctx *cli.Context) error {
now := time.Now()
for _, e := range cc.Events {
p := std.Out.Pending(output.Styledf(output.StylePending, "Processing Calendar event: %q", e.Name))
if e.MonthlyReleaseDate.Before(now) || e.PatchReleaseDate.Before(now) {
p.Complete(output.Linef(output.EmojiWarning, output.StyleWarning, "Skipping event: %q because the date is in the past.", e.Name))
patchEventsToCreate := make([]time.Time, len(e.PatchReleaseDates))
if e.MonthlyReleaseDate.Before(now) {
p.Complete(output.Linef(output.EmojiWarning, output.StyleWarning, "Skipping event: %q because the monthly release date is in the past.", e.Name))
continue
}
for i, patchReleaseDate := range e.PatchReleaseDates {
if patchReleaseDate.Before(now) {
continue
}
patchEventsToCreate[i] = patchReleaseDate
}
if len(patchEventsToCreate) == 0 {
p.Complete(output.Linef(output.EmojiWarning, output.StyleWarning, "Skipping event: %q because there are no patch release dates for the month.", e.Name))
continue
}
@ -81,12 +96,14 @@ func generateCalendarEvents(cctx *cli.Context) error {
return errors.Wrapf(err, "Failed to create monthly release event for %q", e.Name)
}
p.Updatef("Creating Patch Release event for %q", e.Name)
patchReleaseEvt := createReleaseEvent(cc.TeamEmail, fmt.Sprintf("Patch Release: (%s)", e.Name), e.PatchReleaseDate)
_, err = client.Events.Insert("primary", patchReleaseEvt).Context(cctx.Context).Do()
if err != nil {
p.Destroy()
return errors.Wrapf(err, "Failed to create patch release event for %q", e.Name)
p.Updatef("Creating Patch Release events for %q", e.Name)
for _, prd := range patchEventsToCreate {
patchReleaseEvt := createReleaseEvent(cc.TeamEmail, fmt.Sprintf("Patch Release: (%s)", e.Name), prd)
_, err = client.Events.Insert("primary", patchReleaseEvt).Context(cctx.Context).Do()
if err != nil {
p.Destroy()
return errors.Wrapf(err, "Failed to create patch release event for %q. Patch release date: %s", e.Name, prd)
}
}
p.Complete(output.Linef(output.EmojiSuccess, output.StyleSuccess, "Sent and created event: %q", e.Name))

View File

@ -1,37 +1,37 @@
{
"teamEmail": "team@sourcegraph.com",
// these dates should always be in sync with the Sourcegraph Handbook release schedule
// https://handbook.sourcegraph.com/departments/engineering/dev/process/releases/#release-schedule
// https://www.notion.so/sourcegraph/Sourcegraph-Releases-eee2a5384b0a4555adb51b439ddde35f?pvs=4
"events": [
{
"name": "March 2024 Release",
"branchCutDate": "2024-03-06T09:00:00-07:00",
"monthlyReleaseDate": "2024-03-08T09:00:00-07:00",
"patchReleaseDate": "2024-03-20T09:00:00-07:00"
},
{
"name": "April 2024 Release",
"branchCutDate": "2024-04-03T09:00:00-07:00",
"monthlyReleaseDate": "2024-04-05T09:00:00-07:00",
"patchReleaseDate": "2024-04-22T09:00:00-07:00"
},
{
"name": "May 2024 Release",
"branchCutDate": "2024-05-02T09:00:00-07:00",
"monthlyReleaseDate": "2024-05-06T09:00:00-07:00",
"patchReleaseDate": "2024-05-27T09:00:00-07:00"
"name": "July 2024 Release",
"branchCutDate": "2024-07-02T09:00:00-07:00",
"monthlyReleaseDate": "2024-07-05T09:00:00-07:00",
"patchReleaseDates": ["2024-07-22T09:00:00-07:00"]
},
{
"name": "June 2024 Release",
"branchCutDate": "2024-06-02T09:00:00-07:00",
"monthlyReleaseDate": "2024-06-05T09:00:00-07:00",
"patchReleaseDate": "2024-06-20T09:00:00-07:00"
"patchReleaseDates": ["2024-06-20T09:00:00-07:00"]
},
{
"name": "July 2024 Release",
"branchCutDate": "2024-07-02T09:00:00-07:00",
"monthlyReleaseDate": "2024-07-05T09:00:00-07:00",
"patchReleaseDate": "2024-07-22T09:00:00-07:00"
"name": "May 2024 Release",
"branchCutDate": "2024-05-02T09:00:00-07:00",
"monthlyReleaseDate": "2024-05-06T09:00:00-07:00",
"patchReleaseDates": ["2024-05-27T09:00:00-07:00"]
},
{
"name": "April 2024 Release",
"branchCutDate": "2024-04-03T09:00:00-07:00",
"monthlyReleaseDate": "2024-04-05T09:00:00-07:00",
"patchReleaseDates": ["2024-04-22T09:00:00-07:00"]
},
{
"name": "March 2024 Release",
"branchCutDate": "2024-03-06T09:00:00-07:00",
"monthlyReleaseDate": "2024-03-08T09:00:00-07:00",
"patchReleaseDates": ["2024-03-20T09:00:00-07:00"]
}
]
}