Skip to content

Commit eeac73b

Browse files
fix: make historical GitHub release backfills idempotent (#165)
1 parent 358717f commit eeac73b

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

.github/workflows/node-github-release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,10 @@ jobs:
499499
"repos/$GITHUB_REPOSITORY/releases/generate-notes"
500500
-f "tag_name=$RELEASE_TAG"
501501
-f "target_commitish=$RELEASE_SHA"
502-
-f "configuration_file_path=.github/release.yml"
503502
)
503+
if git cat-file -e "$RELEASE_SHA:.github/release.yml" 2>/dev/null; then
504+
notes_args+=(-f "configuration_file_path=.github/release.yml")
505+
fi
504506
if [[ -n "$PREVIOUS_TAG" ]]; then
505507
notes_args+=(-f "previous_tag_name=$PREVIOUS_TAG")
506508
fi

sdk/typescript/tests-ts/release-automation.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,20 @@ describe("GitHub release workflow safeguards", () => {
22292229
peeledCommit: "",
22302230
status: 0,
22312231
},
2232+
{
2233+
description:
2234+
"already current on a release predating release-note configuration",
2235+
existingNotes: "Generated release notes",
2236+
updated: false,
2237+
latestTag: "npm-v0.1.2",
2238+
makeLatest: true,
2239+
latestUpdated: false,
2240+
releaseConfiguration: false,
2241+
tagType: "commit",
2242+
tagObject: releaseCommit,
2243+
peeledCommit: "",
2244+
status: 0,
2245+
},
22322246
{
22332247
description:
22342248
"already current on a newest release incorrectly marked non-Latest",
@@ -2336,6 +2350,7 @@ describe("GitHub release workflow safeguards", () => {
23362350
latestTag,
23372351
makeLatest,
23382352
latestUpdated,
2353+
releaseConfiguration = true,
23392354
tagType,
23402355
tagObject,
23412356
peeledCommit,
@@ -2388,6 +2403,11 @@ describe("GitHub release workflow safeguards", () => {
23882403
" printf '%s\\n' \"$MOCK_PEELED_COMMIT\"",
23892404
" ;;",
23902405
' "POST repos/test/codex-security/releases/generate-notes")',
2406+
' if [[ "$MOCK_RELEASE_CONFIGURATION" == "missing" &&',
2407+
' "$*" == *"configuration_file_path=.github/release.yml"* ]]; then',
2408+
" printf '%s\\n' 'Could not find a configuration file at .github/release.yml' >&2",
2409+
" return 1",
2410+
" fi",
23912411
" printf '%s\\n' 'Generated release notes'",
23922412
" ;;",
23932413
" *) return 65 ;;",
@@ -2435,6 +2455,14 @@ describe("GitHub release workflow safeguards", () => {
24352455
" return 64",
24362456
" fi",
24372457
"}",
2458+
"git() {",
2459+
' if [[ "$1" == "cat-file" && "$2" == "-e" &&',
2460+
' "$3" == "$RELEASE_SHA:.github/release.yml" ]]; then',
2461+
' [[ "$MOCK_RELEASE_CONFIGURATION" == "present" ]]',
2462+
" return",
2463+
" fi",
2464+
' command git "$@"',
2465+
"}",
24382466
"node() {",
24392467
' if [[ "${1:-}" == "sdk/typescript/scripts/release-automation.mjs" &&',
24402468
' "${2:-}" == "verify-github-release" ]]; then',
@@ -2456,6 +2484,9 @@ describe("GitHub release workflow safeguards", () => {
24562484
MOCK_LATEST_TAG: latestTag,
24572485
MOCK_MAKE_LATEST: String(makeLatest),
24582486
MOCK_PEELED_COMMIT: peeledCommit,
2487+
MOCK_RELEASE_CONFIGURATION: releaseConfiguration
2488+
? "present"
2489+
: "missing",
24592490
MOCK_TAG_OBJECT: tagObject,
24602491
MOCK_TAG_TYPE: tagType,
24612492
PREVIOUS_TAG: "npm-v0.1.1",

0 commit comments

Comments
 (0)