Skip to content

Commit 5a46eb5

Browse files
committed
fix(ci): resume registry acceptance after publish
1 parent 409b08a commit 5a46eb5

3 files changed

Lines changed: 27 additions & 2 deletions

File tree

.github/workflows/publish.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,28 @@ jobs:
8181
fi
8282
npm whoami --registry=https://registry.npmjs.org/
8383
84+
- name: Inspect existing registry state
85+
id: registry-state
86+
shell: bash
87+
run: |
88+
VERSION=$(node -p "require('./package.json').version")
89+
EXPECTED_GIT_HEAD=$(git rev-parse HEAD)
90+
PUBLISHED_VERSION=$(npm view "monsqlize@${VERSION}" version --registry=https://registry.npmjs.org/ 2>/dev/null || true)
91+
if [ "${PUBLISHED_VERSION}" != "${VERSION}" ]; then
92+
echo "already_published=false" >> "${GITHUB_OUTPUT}"
93+
exit 0
94+
fi
95+
96+
REGISTRY_GIT_HEAD=$(npm view "monsqlize@${VERSION}" gitHead --registry=https://registry.npmjs.org/)
97+
if [ "${REGISTRY_GIT_HEAD}" != "${EXPECTED_GIT_HEAD}" ]; then
98+
echo "::error::monsqlize@${VERSION} already exists with gitHead=${REGISTRY_GIT_HEAD:-missing}; expected=${EXPECTED_GIT_HEAD}"
99+
exit 1
100+
fi
101+
echo "monsqlize@${VERSION} already exists from this exact tag commit; publish will be skipped and registry acceptance will resume."
102+
echo "already_published=true" >> "${GITHUB_OUTPUT}"
103+
84104
- name: Publish to npm
105+
if: steps.registry-state.outputs.already_published != 'true'
85106
run: npm publish --provenance --access public --ignore-scripts
86107
env:
87108
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -113,7 +134,7 @@ jobs:
113134
mkdir -p "${CONSUMER_DIR}"
114135
cd "${CONSUMER_DIR}"
115136
npm init -y
116-
npm install "monsqlize@${VERSION}" "[email protected]" --ignore-scripts --no-audit --no-fund --registry=https://registry.npmjs.org/
137+
npm install "monsqlize@${VERSION}" "[email protected]" "@types/[email protected]" --ignore-scripts --no-audit --no-fund --registry=https://registry.npmjs.org/
117138
node -e "const p=require('monsqlize/package.json'); const M=require('monsqlize'); if(!M || p.version!==process.argv[1] || typeof M.dataTasks?.preview!=='function') process.exit(1)" "${VERSION}"
118139
node --input-type=module -e "import M,{dataTasks} from 'monsqlize'; if(!M || typeof dataTasks?.apply!=='function') process.exit(1)"
119140
node -e "require('node:fs').writeFileSync('consumer.ts', \"import MonSQLize, { dataTasks } from 'monsqlize';\\nvoid MonSQLize; void dataTasks.preview;\\n\")"

changelogs/unreleased.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Changes after v3.1.0
44

5-
No changes are currently recorded after v3.1.0.
5+
- Made the npm publish workflow recoverable after a successful publish followed by a registry-smoke failure: an existing version is accepted only when its registry `gitHead` matches the immutable tag commit, publish is then skipped, and acceptance resumes. The TypeScript registry consumer now installs the Node type declarations required by MongoDB's public declarations.
66

77
## v3.0.0 development inventory (released 2026-07-15)
88

test/smoke/release-contract.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,15 @@ test('release paths consume the complete single-source preflight gate', () => {
7777
assert.match(publishWorkflow, /npm run release:preflight/);
7878
assert.match(publishWorkflow, /dist\.integrity/);
7979
assert.match(publishWorkflow, /dist-tags\.latest/);
80+
assert.match(publishWorkflow, /id: registry-state/);
81+
assert.match(publishWorkflow, /REGISTRY_GIT_HEAD/);
82+
assert.match(publishWorkflow, /if: steps\.registry-state\.outputs\.already_published != 'true'/);
8083
assert.match(publishWorkflow, /mkdir -p "\$\{CONSUMER_DIR\}"/);
8184
assert.match(publishWorkflow, /cd "\$\{CONSUMER_DIR\}"/);
8285
assert.match(publishWorkflow, /require\('monsqlize'\)/);
8386
assert.match(publishWorkflow, /from 'monsqlize'/);
8487
assert.match(publishWorkflow, /consumer\.ts/);
88+
assert.match(publishWorkflow, /"@types\/node@25\.6\.2"/);
8589
assert.match(publishWorkflow, /\.\/node_modules\/\.bin\/monsqlize/);
8690
assert.doesNotMatch(publishWorkflow, /CONSUMER_DIR.*dist\/esm\/index\.mjs/);
8791
assert.match(publishWorkflow, /dataTasks/);

0 commit comments

Comments
 (0)