Skip to content

Commit fe56aff

Browse files
committed
fix(ci): tolerate npm duplicate version race condition in alias publish
npm with provenance can return a 403 "cannot publish over previously published versions" even when the publish actually succeeded. The script now treats this specific error as success to prevent the workflow from failing and skipping the GitHub Release step.
1 parent 6dc280a commit fe56aff

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

scripts/publish-alias.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ pkg.dependencies['mint-tsdocs'] = '$VERSION';
2020
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
2121
"
2222

23-
# Publish the wrapper package
24-
npm publish --provenance --access public
23+
# Publish the wrapper package (tolerate "already published" errors from npm race conditions)
24+
npm publish --provenance --access public 2>&1 | tee /tmp/npm-publish-alias.log || {
25+
if grep -q "cannot publish over the previously published versions" /tmp/npm-publish-alias.log; then
26+
echo "Version $VERSION already published — treating as success"
27+
else
28+
exit 1
29+
fi
30+
}
2531

2632
# Navigate back to the root directory
2733
cd ../..

0 commit comments

Comments
 (0)