chore(repo): check valid release authors for latest (#22127)

This commit is contained in:
James Henry 2024-03-04 16:20:21 +04:00 committed by GitHub
parent 7c998db5ed
commit 80ae3971ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -11,6 +11,14 @@ import * as yargs from 'yargs';
const LARGE_BUFFER = 1024 * 1000000;
// DO NOT MODIFY, even for testing. This only gates releases to latest.
const VALID_AUTHORS_FOR_LATEST = [
'jaysoo',
'JamesHenry',
'FrozenPandaz',
'vsavkin',
];
(async () => {
const options = parseArgs();
// Perform minimal logging by default
@ -121,6 +129,17 @@ const LARGE_BUFFER = 1024 * 1000000;
});
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');