OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
fix(release): skip already tagged unchanged versions (#1091)
mldangelo-oaibc70facbecec
diff --git a/.github/workflows/node-release-cut.yml b/.github/workflows/node-release-cut.ymlindex 797501792..aff7b2574 100644--- a/.github/workflows/node-release-cut.yml+++ b/.github/workflows/node-release-cut.yml@@ -113,6 +113,19 @@ jobs:echo "changed=false" >> "$GITHUB_OUTPUT"exit 0fi+ if tagged_sha="$(git rev-parse --verify "refs/tags/npm-v$version^{commit}" 2>/dev/null)" &&+ [[ "$tagged_sha" != "$RELEASE_SHA" ]] &&+ git merge-base --is-ancestor "$tagged_sha" "$RELEASE_SHA"; then+ tagged_version="$(+ git show "$tagged_sha:sdk/typescript/package.json" |+ node -p 'JSON.parse(require("node:fs").readFileSync(0, "utf8")).version'+ )"+ if [[ "$tagged_version" == "$version" ]]; then+ echo "Package version is unchanged and already tagged at $tagged_sha."+ echo "changed=false" >> "$GITHUB_OUTPUT"+ exit 0+ fi+ fielsenode sdk/typescript/scripts/release-automation.mjs \require-increase "$version" "$previous_version" >/dev/nulldiff --git a/sdk/typescript/tests-ts/release-automation.test.ts b/sdk/typescript/tests-ts/release-automation.test.tsindex 317b05e1b..90927bf05 100644--- a/sdk/typescript/tests-ts/release-automation.test.ts+++ b/sdk/typescript/tests-ts/release-automation.test.ts@@ -1899,11 +1899,13 @@ describe("GitHub release workflow safeguards", () => {test.each([{- scenario: "a successful version-increase commit",+ scenario: "a version-increase commit with a conflicting existing tag",event: "workflow_run",previousVersion: "0.1.5",currentVersion: "0.1.6",publishedVersions: ["0.1.5"],+ taggedSha: "cccccccccccccccccccccccccccccccccccccccc",+ taggedVersion: "0.1.6",changed: true,},{@@ -1914,6 +1916,48 @@ describe("GitHub release workflow safeguards", () => {publishedVersions: ["0.1.5"],changed: true,},+ {+ scenario:+ "an unchanged unpublished version already tagged on an ancestor",+ event: "workflow_run",+ previousVersion: "0.1.6",+ currentVersion: "0.1.6",+ publishedVersions: ["0.1.5"],+ taggedSha: "cccccccccccccccccccccccccccccccccccccccc",+ taggedVersion: "0.1.6",+ changed: false,+ },+ {+ scenario: "a retry at the exact tagged unpublished commit",+ event: "workflow_run",+ previousVersion: "0.1.6",+ currentVersion: "0.1.6",+ publishedVersions: ["0.1.5"],+ taggedSha: releaseCommit,+ taggedVersion: "0.1.6",+ changed: true,+ },+ {+ scenario: "an unchanged version with a tag outside its ancestry",+ event: "workflow_run",+ previousVersion: "0.1.6",+ currentVersion: "0.1.6",+ publishedVersions: ["0.1.5"],+ taggedSha: "cccccccccccccccccccccccccccccccccccccccc",+ taggedVersion: "0.1.6",+ taggedAncestor: false,+ changed: true,+ },+ {+ scenario: "an unchanged version with a tag for another package version",+ event: "workflow_run",+ previousVersion: "0.1.6",+ currentVersion: "0.1.6",+ publishedVersions: ["0.1.5"],+ taggedSha: "cccccccccccccccccccccccccccccccccccccccc",+ taggedVersion: "0.1.5",+ changed: true,+ },{scenario: "an unchanged version that has already been published",event: "workflow_run",@@ -1930,6 +1974,16 @@ describe("GitHub release workflow safeguards", () => {publishedVersions: ["0.1.5"],changed: true,},+ {+ scenario: "a manual dispatch after an unpublished version was tagged",+ event: "workflow_dispatch",+ previousVersion: "0.1.6",+ currentVersion: "0.1.6",+ publishedVersions: ["0.1.5"],+ taggedSha: "cccccccccccccccccccccccccccccccccccccccc",+ taggedVersion: "0.1.6",+ changed: true,+ },])("resolves $scenario against its published npm history",async ({@@ -1937,6 +1991,9 @@ describe("GitHub release workflow safeguards", () => {previousVersion,currentVersion,publishedVersions,+ taggedSha = "",+ taggedVersion = "",+ taggedAncestor = true,changed,}) => {const script = workflowStepShell(@@ -1946,11 +2003,29 @@ describe("GitHub release workflow safeguards", () => {const mocks = ["git() {",' case "$1" in',- " fetch|merge-base) return 0 ;;",- " rev-parse) printf '%s\\n' \"$MOCK_PREVIOUS_SHA\" ;;",+ " fetch) return 0 ;;",+ " merge-base)",+ ' if [[ "$3" == "$MOCK_TAGGED_SHA" && "$4" == "$RELEASE_SHA" ]]; then',+ ' [[ "$MOCK_TAGGED_ANCESTOR" == "true" ]]',+ " else",+ " return 0",+ " fi",+ " ;;",+ " rev-parse)",+ ' if [[ "$2" == "$RELEASE_SHA^" ]]; then',+ " printf '%s\\n' \"$MOCK_PREVIOUS_SHA\"",+ ' elif [[ "$2" == "--verify" && "$3" == "refs/tags/npm-v$MOCK_RELEASE_VERSION^{commit}" ]]; then',+ ' [[ -n "$MOCK_TAGGED_SHA" ]] || return 1',+ " printf '%s\\n' \"$MOCK_TAGGED_SHA\"",+ " else",+ " return 64",+ " fi",+ " ;;"," show)",' if [[ "$2" == *":.github/release-notes.md" ]]; then'," printf '%s\\n%s\\n' \"<!-- release-version: $MOCK_RELEASE_VERSION -->\" 'Reviewed summary'",+ ' elif [[ "$2" == "$MOCK_TAGGED_SHA:sdk/typescript/package.json" ]]; then',+ ' printf \'{"version":"%s"}\\n\' "$MOCK_TAGGED_VERSION"'," else",' printf \'{"version":"%s"}\\n\' "$MOCK_PREVIOUS_VERSION"'," fi",@@ -1985,6 +2060,9 @@ describe("GitHub release workflow safeguards", () => {MOCK_PREVIOUS_VERSION: previousVersion,MOCK_PUBLISHED_VERSIONS: JSON.stringify(publishedVersions),MOCK_RELEASE_VERSION: currentVersion,+ MOCK_TAGGED_SHA: taggedSha,+ MOCK_TAGGED_VERSION: taggedVersion,+ MOCK_TAGGED_ANCESTOR: String(taggedAncestor),RELEASE_SHA: releaseCommit,},timeout: 10_000,@@ -1998,6 +2076,9 @@ describe("GitHub release workflow safeguards", () => {if (changed) {expect(outputs).toContain(`version=${currentVersion}`);expect(outputs).toContain(`tag=npm-v${currentVersion}`);+ } else {+ expect(outputs).not.toContain("version=");+ expect(outputs).not.toContain("tag=");}} finally {rmSync(workspace, { recursive: true, force: true });