mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore(scripts): fix stable release promote script (#13204)
This commit is contained in:
@@ -62,9 +62,9 @@ func main() {
|
||||
Value: serpent.BoolOf(&r.debug),
|
||||
},
|
||||
{
|
||||
Flag: "gh-token",
|
||||
Flag: "github-token",
|
||||
Description: "GitHub personal access token.",
|
||||
Env: "GH_TOKEN",
|
||||
Env: "GITHUB_TOKEN",
|
||||
Value: serpent.StringOf(&r.ghToken),
|
||||
},
|
||||
{
|
||||
@@ -245,7 +245,7 @@ func (r *releaseCommand) promoteVersionToStable(ctx context.Context, inv *serpen
|
||||
updatedNewStable.Prerelease = github.Bool(false)
|
||||
updatedNewStable.Draft = github.Bool(false)
|
||||
if !r.dryRun {
|
||||
_, _, err = client.Repositories.EditRelease(ctx, owner, repo, newStable.GetID(), newStable)
|
||||
_, _, err = client.Repositories.EditRelease(ctx, owner, repo, newStable.GetID(), updatedNewStable)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("edit release failed: %w", err)
|
||||
}
|
||||
@@ -268,6 +268,10 @@ func cloneRelease(r *github.RepositoryRelease) *github.RepositoryRelease {
|
||||
//
|
||||
// > ## Stable (since April 23, 2024)
|
||||
func addStableSince(date time.Time, body string) string {
|
||||
// Protect against adding twice.
|
||||
if strings.Contains(body, "> ## Stable (since") {
|
||||
return body
|
||||
}
|
||||
return fmt.Sprintf("> ## Stable (since %s)\n\n", date.Format("January 02, 2006")) + body
|
||||
}
|
||||
|
||||
|
||||
@@ -131,12 +131,19 @@ func Test_addStableSince(t *testing.T) {
|
||||
date := time.Date(2024, time.April, 23, 0, 0, 0, 0, time.UTC)
|
||||
body := "## Changelog"
|
||||
|
||||
expected := "> ## Stable (since April 23, 2024)\n\n## Changelog"
|
||||
result := addStableSince(date, body)
|
||||
want := "> ## Stable (since April 23, 2024)\n\n## Changelog"
|
||||
got := addStableSince(date, body)
|
||||
|
||||
if diff := cmp.Diff(expected, result); diff != "" {
|
||||
if diff := cmp.Diff(want, got); diff != "" {
|
||||
require.Fail(t, "addStableSince() mismatch (-want +got):\n%s", diff)
|
||||
}
|
||||
|
||||
// Test that it doesn't add twice.
|
||||
got = addStableSince(date, got)
|
||||
|
||||
if diff := cmp.Diff(want, got); diff != "" {
|
||||
require.Fail(t, "addStableSince() mismatch (-want +got):\n%s", diff, "addStableSince() should not add twice")
|
||||
}
|
||||
}
|
||||
|
||||
func Test_release_autoversion(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user