Fix auto-publishing permissions / graceful fallback (#4391)

This commit is contained in:
Matthew Dean
2025-12-14 12:01:32 -08:00
committed by GitHub
parent 5cd329c9d0
commit 6e81606869
2 changed files with 21 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
{
"name": "@less/root",
"private": true,
"version": "4.5.0",
"version": "4.5.1",
"description": "Less monorepo",
"homepage": "http://lesscss.org",
"scripts": {

View File

@@ -417,6 +417,8 @@ function main() {
console.log(`\n📦 Publishing packages to NPM with tag: ${npmTag}...`);
const publishErrors = [];
for (const pkg of publishable) {
console.log(`\n📤 Publishing ${pkg.name}...`);
if (dryRun) {
@@ -424,19 +426,34 @@ function main() {
console.log(` [DRY RUN] Command: npm publish --tag ${npmTag}`);
} else {
try {
execSync(`npm publish --tag ${npmTag}`, {
// For scoped packages, ensure access is set correctly
const publishCmd = `npm publish --tag ${npmTag} --access public`;
execSync(publishCmd, {
cwd: pkg.dir,
stdio: 'inherit',
env: { ...process.env, NODE_AUTH_TOKEN: process.env.NPM_TOKEN }
});
console.log(`✅ Successfully published ${pkg.name}@${nextVersion}`);
} catch (e) {
console.error(`❌ Failed to publish ${pkg.name}:`, e.message);
process.exit(1);
const errorMsg = e.message || String(e);
console.error(`❌ Failed to publish ${pkg.name}: ${errorMsg}`);
publishErrors.push({ name: pkg.name, error: errorMsg });
// Continue with other packages instead of exiting immediately
}
}
}
// Report any publish errors at the end
if (publishErrors.length > 0) {
console.error(`\n❌ Publishing completed with ${publishErrors.length} error(s):`);
publishErrors.forEach(({ name, error }) => {
console.error(` - ${name}: ${error}`);
});
console.error(`\n⚠️ Note: Version bump and commit were successful.`);
console.error(` Some packages failed to publish. You may need to publish them manually.`);
process.exit(1);
}
if (dryRun) {
console.log(`\n🧪 DRY RUN COMPLETE - No changes were made`);
console.log(` Would publish version: ${nextVersion}`);