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

Commitcb9f2d1

Browse files
committed
chore(scripts): fix stable release promote script
1 parent06dd656 commitcb9f2d1

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

‎scripts/release/main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ func main() {
6262
Value:serpent.BoolOf(&r.debug),
6363
},
6464
{
65-
Flag:"gh-token",
65+
Flag:"github-token",
6666
Description:"GitHub personal access token.",
67-
Env:"GH_TOKEN",
67+
Env:"GITHUB_TOKEN",
6868
Value:serpent.StringOf(&r.ghToken),
6969
},
7070
{
@@ -245,7 +245,7 @@ func (r *releaseCommand) promoteVersionToStable(ctx context.Context, inv *serpen
245245
updatedNewStable.Prerelease=github.Bool(false)
246246
updatedNewStable.Draft=github.Bool(false)
247247
if!r.dryRun {
248-
_,_,err=client.Repositories.EditRelease(ctx,owner,repo,newStable.GetID(),newStable)
248+
_,_,err=client.Repositories.EditRelease(ctx,owner,repo,newStable.GetID(),updatedNewStable)
249249
iferr!=nil {
250250
returnxerrors.Errorf("edit release failed: %w",err)
251251
}
@@ -268,6 +268,10 @@ func cloneRelease(r *github.RepositoryRelease) *github.RepositoryRelease {
268268
//
269269
//> ## Stable (since April 23, 2024)
270270
funcaddStableSince(date time.Time,bodystring)string {
271+
// Protect against adding twice.
272+
ifstrings.Contains(body,"> ## Stable (since") {
273+
returnbody
274+
}
271275
returnfmt.Sprintf("> ## Stable (since %s)\n\n",date.Format("January 02, 2006"))+body
272276
}
273277

‎scripts/release/main_internal_test.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,19 @@ func Test_addStableSince(t *testing.T) {
131131
date:=time.Date(2024,time.April,23,0,0,0,0,time.UTC)
132132
body:="## Changelog"
133133

134-
expected:="> ## Stable (since April 23, 2024)\n\n## Changelog"
135-
result:=addStableSince(date,body)
134+
want:="> ## Stable (since April 23, 2024)\n\n## Changelog"
135+
got:=addStableSince(date,body)
136136

137-
ifdiff:=cmp.Diff(expected,result);diff!="" {
137+
ifdiff:=cmp.Diff(want,got);diff!="" {
138138
require.Fail(t,"addStableSince() mismatch (-want +got):\n%s",diff)
139139
}
140+
141+
// Test that it doesn't add twice.
142+
got=addStableSince(date,got)
143+
144+
ifdiff:=cmp.Diff(want,got);diff!="" {
145+
require.Fail(t,"addStableSince() mismatch (-want +got):\n%s",diff,"addStableSince() should not add twice")
146+
}
140147
}
141148

142149
funcTest_release_autoversion(t*testing.T) {

‎scripts/release_promote_stable.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ set -euo pipefail
44
# shellcheck source=scripts/lib.sh
55
source"$(dirname"${BASH_SOURCE[0]}")/lib.sh"
66

7+
# Make sure GITHUB_TOKEN is set for the release command.
8+
gh_auth
9+
710
# This script is a convenience wrapper around the release promote command.
811
#
912
# Sed hack to make help text look like this script.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp