chore(repo): only valid latest publish when not local (#22131)
This commit is contained in:
parent
80ae3971ff
commit
1d6e0f8c67
@ -129,17 +129,6 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
});
|
||||
|
||||
const distTag = determineDistTag(options.version);
|
||||
if (!distTag || distTag === 'latest') {
|
||||
// We are only expecting latest releases to be performed within publish.yml on GitHub
|
||||
const author = process.env.GITHUB_ACTOR ?? '';
|
||||
if (!VALID_AUTHORS_FOR_LATEST.includes(author)) {
|
||||
throw new Error(
|
||||
`The GitHub user "${author}" is not allowed to publish to "latest". Please request one of the following users to carry out the release: ${VALID_AUTHORS_FOR_LATEST.join(
|
||||
', '
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.dryRun) {
|
||||
console.warn('Not Publishing because --dryRun was passed');
|
||||
@ -174,6 +163,18 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
}
|
||||
}
|
||||
|
||||
if (!options.local && (!distTag || distTag === 'latest')) {
|
||||
// We are only expecting non-local latest releases to be performed within publish.yml on GitHub
|
||||
const author = process.env.GITHUB_ACTOR ?? '';
|
||||
if (!VALID_AUTHORS_FOR_LATEST.includes(author)) {
|
||||
throw new Error(
|
||||
`The GitHub user "${author}" is not allowed to publish to "latest". Please request one of the following users to carry out the release: ${VALID_AUTHORS_FOR_LATEST.join(
|
||||
', '
|
||||
)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Run with dynamic output-style so that we have more minimal logs by default but still always see errors
|
||||
let publishCommand = `pnpm nx release publish --registry=${getRegistry()} --tag=${distTag} --output-style=dynamic --parallel=8`;
|
||||
if (options.dryRun) {
|
||||
@ -184,17 +185,17 @@ const VALID_AUTHORS_FOR_LATEST = [
|
||||
stdio: [0, 1, 2],
|
||||
maxBuffer: LARGE_BUFFER,
|
||||
});
|
||||
}
|
||||
|
||||
let version;
|
||||
if (['minor', 'major', 'patch'].includes(options.version)) {
|
||||
version = execSync(`npm view nx@${distTag} version`).toString().trim();
|
||||
} else {
|
||||
version = options.version;
|
||||
}
|
||||
let version;
|
||||
if (['minor', 'major', 'patch'].includes(options.version)) {
|
||||
version = execSync(`npm view nx@${distTag} version`).toString().trim();
|
||||
} else {
|
||||
version = options.version;
|
||||
}
|
||||
|
||||
console.log(chalk.green` > Published version: ` + version);
|
||||
console.log(chalk.dim` Use: npx create-nx-workspace@${version}\n`);
|
||||
console.log(chalk.green` > Published version: ` + version);
|
||||
console.log(chalk.dim` Use: npx create-nx-workspace@${version}\n`);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
})();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user