@@ -3,9 +3,11 @@ package main
3
3
import (
4
4
"context"
5
5
"errors"
6
+ "fmt"
6
7
"os"
7
8
"slices"
8
9
"strings"
10
+ "time"
9
11
10
12
"github.com/google/go-cmp/cmp"
11
13
"github.com/google/go-github/v61/github"
@@ -154,8 +156,9 @@ func promoteVersionToStable(ctx context.Context, inv *serpent.Invocation, logger
154
156
// Update the release to latest.
155
157
updatedNewStable := cloneRelease (newStable )
156
158
157
- updatedNewStable .Name = github .String (newStable .GetName () + " (Stable)" )
158
- updatedNewStable .Body = github .String (removeMainlineBlurb (newStable .GetBody ()))
159
+ updatedBody := removeMainlineBlurb (newStable .GetBody ())
160
+ updatedBody = addStableSince (time .Now ().UTC (), updatedBody )
161
+ updatedNewStable .Body = github .String (updatedBody )
159
162
updatedNewStable .Prerelease = github .Bool (false )
160
163
updatedNewStable .Draft = github .Bool (false )
161
164
if ! dryRun {
@@ -168,22 +171,6 @@ func promoteVersionToStable(ctx context.Context, inv *serpent.Invocation, logger
168
171
logger .Info (ctx , "dry-run: release not updated" , "uncommitted_changes" , cmp .Diff (newStable , updatedNewStable ))
169
172
}
170
173
171
- logger .Info (ctx , "updating title of the previous stable release (remove stable suffix)" )
172
-
173
- // Update the previous stable release to a regular release.
174
- updatedOldStable := cloneRelease (currentStable )
175
- currentStable .Name = github .String (strings .TrimSuffix (currentStable .GetName (), " (Stable)" ))
176
-
177
- if ! dryRun {
178
- _ , _ , err = client .Repositories .EditRelease (ctx , owner , repo , currentStable .GetID (), currentStable )
179
- if err != nil {
180
- return err
181
- }
182
- logger .Info (ctx , "title of the previous stable release updated" )
183
- } else {
184
- logger .Info (ctx , "dry-run: previous release not updated" , "uncommitted_changes" , cmp .Diff (currentStable , updatedOldStable ))
185
- }
186
-
187
174
return nil
188
175
}
189
176
@@ -192,6 +179,15 @@ func cloneRelease(r *github.RepositoryRelease) *github.RepositoryRelease {
192
179
return & rr
193
180
}
194
181
182
+ // addStableSince adds a stable since note to the release body.
183
+ //
184
+ // Example:
185
+ //
186
+ // > ## Stable (since April 23, 2024)
187
+ func addStableSince (date time.Time , body string ) string {
188
+ return fmt .Sprintf ("> ## Stable (since %s)\n \n " , date .Format ("January 02, 2006" )) + body
189
+ }
190
+
195
191
// removeMainlineBlurb removes the mainline blurb from the release body.
196
192
//
197
193
// Example:
0 commit comments