From 5eb43b08b24bc8a4f897967573436b7c43912b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Deng=20=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90?= Date: Sun, 23 Jun 2024 18:50:36 +0800 Subject: [PATCH] ci: add release tag (#254) --- .github/workflows/ci.yml | 2 +- scripts/release.js | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13329fd06..673c50dd5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -88,7 +88,7 @@ jobs: - run: pnpm install - - run: pnpm release --vapor --skip-tests + - run: pnpm release --vapor --skip-tests --tag ${{ github.ref == 'refs/heads/main' && 'latest' || 'branch' }} env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_CONFIG_PROVENANCE: 'true' diff --git a/scripts/release.js b/scripts/release.js index 3864c37bc..3e299d3f0 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -140,21 +140,21 @@ async function main() { const major = semver.major(currentVersion) let newVersion - if (isCanary) { - // The canary version string format is `3.yyyyMMdd.0` (or `3.yyyyMMdd.0-minor.0` for minor) - // Use UTC date so that it's consistent across CI and maintainers' machines - const date = new Date() - const yyyy = date.getUTCFullYear() - const MM = (date.getUTCMonth() + 1).toString().padStart(2, '0') - const dd = date.getUTCDate().toString().padStart(2, '0') + // The canary version string format is `3.yyyyMMdd.0` (or `3.yyyyMMdd.0-minor.0` for minor) + // Use UTC date so that it's consistent across CI and maintainers' machines + const date = new Date() + const yyyy = date.getUTCFullYear() + const MM = (date.getUTCMonth() + 1).toString().padStart(2, '0') + const dd = date.getUTCDate().toString().padStart(2, '0') + const datestamp = `${yyyy}${MM}${dd}` - const datestamp = `${yyyy}${MM}${dd}` + if (isCanary) { newVersion = `${major}.${datestamp}.0` if (args.tag && args.tag !== 'latest') { newVersion = `${major}.${datestamp}.0-${args.tag}.0` } } else { - newVersion = `${major}.2024.0-${await getSha(true)}` + newVersion = `${major}.${datestamp}.0-${await getSha(true)}` } // check the registry to avoid version collision