Skip to content

Commit

Permalink
Only release 'latest' from 'main' branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Oct 13, 2023
1 parent 2261a9f commit 1a639a7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/publish-action.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ const publishAction = async ({ version, repo }) => {

const { default: pkg } = await import('../package.json', { assert: { type: 'json' } });

const [, major, minor, patch, tag] = pkg.version.match(/(\d+)\.(\d+)\.(\d+)-?(\w+)?/) || [];
const [, major, minor, patch, tag] = pkg.version.match(/(\d+)\.(\d+)\.(\d+)-*(\w+)?/) || [];
if (!major || !minor || !patch) {
console.error(`❗️ Invalid version: ${pkg.version}`);
return;
}

const { stdout: branch } = await execaCommand('git rev-parse --abbrev-ref HEAD');
const defaultTag = branch === 'main' ? 'latest' : 'canary';
const context = ['canary', 'next', 'latest'].includes(process.argv[2])
? process.argv[2]
: tag || 'latest';
: tag || defaultTag;

switch (context) {
case 'canary':
Expand Down

0 comments on commit 1a639a7

Please sign in to comment.