From eeac73b165a5564fd4cdc2fd62d348db90e2a057 Mon Sep 17 00:00:00 2001 From: mldangelo-oai Date: Thu, 30 Jul 2026 17:07:08 -0700 Subject: [PATCH] fix: make historical GitHub release backfills idempotent (#165) --- .github/workflows/node-github-release.yml | 4 ++- .../tests-ts/release-automation.test.ts | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node-github-release.yml b/.github/workflows/node-github-release.yml index a93bee2b8..5dcf856da 100644 --- a/.github/workflows/node-github-release.yml +++ b/.github/workflows/node-github-release.yml @@ -499,8 +499,10 @@ jobs: "repos/$GITHUB_REPOSITORY/releases/generate-notes" -f "tag_name=$RELEASE_TAG" -f "target_commitish=$RELEASE_SHA" - -f "configuration_file_path=.github/release.yml" ) + if git cat-file -e "$RELEASE_SHA:.github/release.yml" 2>/dev/null; then + notes_args+=(-f "configuration_file_path=.github/release.yml") + fi if [[ -n "$PREVIOUS_TAG" ]]; then notes_args+=(-f "previous_tag_name=$PREVIOUS_TAG") fi diff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.ts index f4775b6b8..1aa93d88d 100644 --- a/sdk/typescript/tests-ts/release-automation.test.ts +++ b/sdk/typescript/tests-ts/release-automation.test.ts @@ -2229,6 +2229,20 @@ describe("GitHub release workflow safeguards", () => { peeledCommit: "", status: 0, }, + { + description: + "already current on a release predating release-note configuration", + existingNotes: "Generated release notes", + updated: false, + latestTag: "npm-v0.1.2", + makeLatest: true, + latestUpdated: false, + releaseConfiguration: false, + tagType: "commit", + tagObject: releaseCommit, + peeledCommit: "", + status: 0, + }, { description: "already current on a newest release incorrectly marked non-Latest", @@ -2336,6 +2350,7 @@ describe("GitHub release workflow safeguards", () => { latestTag, makeLatest, latestUpdated, + releaseConfiguration = true, tagType, tagObject, peeledCommit, @@ -2388,6 +2403,11 @@ describe("GitHub release workflow safeguards", () => { " printf '%s\\n' \"$MOCK_PEELED_COMMIT\"", " ;;", ' "POST repos/test/codex-security/releases/generate-notes")', + ' if [[ "$MOCK_RELEASE_CONFIGURATION" == "missing" &&', + ' "$*" == *"configuration_file_path=.github/release.yml"* ]]; then', + " printf '%s\\n' 'Could not find a configuration file at .github/release.yml' >&2", + " return 1", + " fi", " printf '%s\\n' 'Generated release notes'", " ;;", " *) return 65 ;;", @@ -2435,6 +2455,14 @@ describe("GitHub release workflow safeguards", () => { " return 64", " fi", "}", + "git() {", + ' if [[ "$1" == "cat-file" && "$2" == "-e" &&', + ' "$3" == "$RELEASE_SHA:.github/release.yml" ]]; then', + ' [[ "$MOCK_RELEASE_CONFIGURATION" == "present" ]]', + " return", + " fi", + ' command git "$@"', + "}", "node() {", ' if [[ "${1:-}" == "sdk/typescript/scripts/release-automation.mjs" &&', ' "${2:-}" == "verify-github-release" ]]; then', @@ -2456,6 +2484,9 @@ describe("GitHub release workflow safeguards", () => { MOCK_LATEST_TAG: latestTag, MOCK_MAKE_LATEST: String(makeLatest), MOCK_PEELED_COMMIT: peeledCommit, + MOCK_RELEASE_CONFIGURATION: releaseConfiguration + ? "present" + : "missing", MOCK_TAG_OBJECT: tagObject, MOCK_TAG_TYPE: tagType, PREVIOUS_TAG: "npm-v0.1.1",