Skip to content

Commit 6e81606

Browse files
authored
Fix auto-publishing permissions / graceful fallback (#4391)
1 parent 5cd329c commit 6e81606

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@less/root",
33
"private": true,
4-
"version": "4.5.0",
4+
"version": "4.5.1",
55
"description": "Less monorepo",
66
"homepage": "http://lesscss.org",
77
"scripts": {

scripts/bump-and-publish.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,26 +417,43 @@ function main() {
417417

418418
console.log(`\n📦 Publishing packages to NPM with tag: ${npmTag}...`);
419419

420+
const publishErrors = [];
421+
420422
for (const pkg of publishable) {
421423
console.log(`\n📤 Publishing ${pkg.name}...`);
422424
if (dryRun) {
423425
console.log(` [DRY RUN] Would publish: ${pkg.name}@${nextVersion} with tag: ${npmTag}`);
424426
console.log(` [DRY RUN] Command: npm publish --tag ${npmTag}`);
425427
} else {
426428
try {
427-
execSync(`npm publish --tag ${npmTag}`, {
429+
// For scoped packages, ensure access is set correctly
430+
const publishCmd = `npm publish --tag ${npmTag} --access public`;
431+
execSync(publishCmd, {
428432
cwd: pkg.dir,
429433
stdio: 'inherit',
430434
env: { ...process.env, NODE_AUTH_TOKEN: process.env.NPM_TOKEN }
431435
});
432436
console.log(`✅ Successfully published ${pkg.name}@${nextVersion}`);
433437
} catch (e) {
434-
console.error(`❌ Failed to publish ${pkg.name}:`, e.message);
435-
process.exit(1);
438+
const errorMsg = e.message || String(e);
439+
console.error(`❌ Failed to publish ${pkg.name}: ${errorMsg}`);
440+
publishErrors.push({ name: pkg.name, error: errorMsg });
441+
// Continue with other packages instead of exiting immediately
436442
}
437443
}
438444
}
439445

446+
// Report any publish errors at the end
447+
if (publishErrors.length > 0) {
448+
console.error(`\n❌ Publishing completed with ${publishErrors.length} error(s):`);
449+
publishErrors.forEach(({ name, error }) => {
450+
console.error(` - ${name}: ${error}`);
451+
});
452+
console.error(`\n⚠️ Note: Version bump and commit were successful.`);
453+
console.error(` Some packages failed to publish. You may need to publish them manually.`);
454+
process.exit(1);
455+
}
456+
440457
if (dryRun) {
441458
console.log(`\n🧪 DRY RUN COMPLETE - No changes were made`);
442459
console.log(` Would publish version: ${nextVersion}`);

0 commit comments

Comments
 (0)