From 1a639a7857e9f9b026c22eb3cc64de6e20a0e5ae Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Fri, 13 Oct 2023 22:46:47 +0200 Subject: [PATCH] Only release 'latest' from 'main' branch --- scripts/publish-action.mjs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/publish-action.mjs b/scripts/publish-action.mjs index 8e0a340d8..3811e12c4 100755 --- a/scripts/publish-action.mjs +++ b/scripts/publish-action.mjs @@ -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':