Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit523b686

Browse files
committed
update body instead of title, stable since
1 parent0e2e866 commit523b686

File tree

2 files changed

+29
-18
lines changed

2 files changed

+29
-18
lines changed

‎scripts/release/main.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ package main
33
import (
44
"context"
55
"errors"
6+
"fmt"
67
"os"
78
"slices"
89
"strings"
10+
"time"
911

1012
"github.com/google/go-cmp/cmp"
1113
"github.com/google/go-github/v61/github"
@@ -154,8 +156,9 @@ func promoteVersionToStable(ctx context.Context, inv *serpent.Invocation, logger
154156
// Update the release to latest.
155157
updatedNewStable:=cloneRelease(newStable)
156158

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)
159162
updatedNewStable.Prerelease=github.Bool(false)
160163
updatedNewStable.Draft=github.Bool(false)
161164
if!dryRun {
@@ -168,22 +171,6 @@ func promoteVersionToStable(ctx context.Context, inv *serpent.Invocation, logger
168171
logger.Info(ctx,"dry-run: release not updated","uncommitted_changes",cmp.Diff(newStable,updatedNewStable))
169172
}
170173

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-
iferr!=nil {
180-
returnerr
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-
187174
returnnil
188175
}
189176

@@ -192,6 +179,15 @@ func cloneRelease(r *github.RepositoryRelease) *github.RepositoryRelease {
192179
return&rr
193180
}
194181

182+
// addStableSince adds a stable since note to the release body.
183+
//
184+
// Example:
185+
//
186+
//> ## Stable (since April 23, 2024)
187+
funcaddStableSince(date time.Time,bodystring)string {
188+
returnfmt.Sprintf("> ## Stable (since %s)\n\n",date.Format("January 02, 2006"))+body
189+
}
190+
195191
// removeMainlineBlurb removes the mainline blurb from the release body.
196192
//
197193
// Example:

‎scripts/release/main_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package main
22

33
import (
44
"testing"
5+
"time"
56

67
"github.com/google/go-cmp/cmp"
78
)
@@ -99,3 +100,17 @@ Refer to our docs to [install](https://coder.com/docs/v2/latest/install) or [upg
99100
})
100101
}
101102
}
103+
104+
funcTest_addStableSince(t*testing.T) {
105+
t.Parallel()
106+
107+
date:=time.Date(2024,time.April,23,0,0,0,0,time.UTC)
108+
body:="## Changelog"
109+
110+
expected:="> ## Stable (since April 23, 2024)\n\n## Changelog"
111+
result:=addStableSince(date,body)
112+
113+
ifdiff:=cmp.Diff(expected,result);diff!="" {
114+
t.Errorf("addStableSince() mismatch (-want +got):\n%s",diff)
115+
}
116+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp