]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
ci: add a canary release workflow for next minor (#9265)
authorHaoqun Jiang <haoqunjiang@gmail.com>
Fri, 22 Sep 2023 07:51:11 +0000 (15:51 +0800)
committerGitHub <noreply@github.com>
Fri, 22 Sep 2023 07:51:11 +0000 (15:51 +0800)
.github/workflows/canary-minor.yml [new file with mode: 0644]
scripts/release.js

diff --git a/.github/workflows/canary-minor.yml b/.github/workflows/canary-minor.yml
new file mode 100644 (file)
index 0000000..2aa6db1
--- /dev/null
@@ -0,0 +1,33 @@
+name: canary minor release
+on:
+  # Runs every Monday at 1 AM UTC (9:00 AM in Singapore)
+  schedule:
+    - cron: 0 1 * * MON
+  workflow_dispatch:
+
+jobs:
+  canary:
+    # prevents this action from running on forks
+    if: github.repository == 'vuejs/core'
+    runs-on: ubuntu-latest
+    environment: Release
+    steps:
+      - uses: actions/checkout@v4
+        with:
+          ref: minor
+
+      - name: Install pnpm
+        uses: pnpm/action-setup@v2
+
+      - name: Set node version to 18
+        uses: actions/setup-node@v3
+        with:
+          node-version: 18
+          registry-url: 'https://registry.npmjs.org'
+          cache: 'pnpm'
+
+      - run: pnpm install
+
+      - run: pnpm release --canary --tag minor
+        env:
+          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
index 3d29b8b2c64901cda53e5648ac11176e3fad220c..2c653a4f7d6f9a358a498883700e65b64c36a8f4 100644 (file)
@@ -12,7 +12,15 @@ import { fileURLToPath } from 'node:url'
 const { prompt } = enquirer
 const currentVersion = createRequire(import.meta.url)('../package.json').version
 const __dirname = path.dirname(fileURLToPath(import.meta.url))
-const args = minimist(process.argv.slice(2))
+const args = minimist(process.argv.slice(2), {
+  alias: {
+    skipBuild: 'skip-build',
+    skipTests: 'skip-tests',
+    skipGit: 'skip-git',
+    skipPrompts: 'skip-prompts'
+  }
+})
+
 const preId = args.preid || semver.prerelease(currentVersion)?.[0]
 const isDryRun = args.dry
 let skipTests = args.skipTests
@@ -74,7 +82,7 @@ async function main() {
   let targetVersion = args._[0]
 
   if (isCanary) {
-    // The canary version string format is `3.yyyyMMdd.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()
@@ -82,9 +90,13 @@ async function main() {
     const dd = date.getUTCDate().toString().padStart(2, '0')
 
     const major = semver.major(currentVersion)
-    const minor = `${yyyy}${MM}${dd}`
-    const patch = 0
-    let canaryVersion = `${major}.${minor}.${patch}`
+    const datestamp = `${yyyy}${MM}${dd}`
+    let canaryVersion
+
+    canaryVersion = `${major}.${datestamp}.0`
+    if (args.tag && args.tag !== 'latest') {
+      canaryVersion = `${major}.${datestamp}.0-${args.tag}.0`
+    }
 
     // check the registry to avoid version collision
     // in case we need to publish more than one canary versions in a day
@@ -100,9 +112,15 @@ async function main() {
       const latestSameDayPatch = /** @type {string} */ (
         semver.maxSatisfying(versions, `~${canaryVersion}`)
       )
+
       canaryVersion = /** @type {string} */ (
         semver.inc(latestSameDayPatch, 'patch')
       )
+      if (args.tag && args.tag !== 'latest') {
+        canaryVersion = /** @type {string} */ (
+          semver.inc(latestSameDayPatch, 'prerelease', args.tag)
+        )
+      }
     } catch (e) {
       if (/E404/.test(e.message)) {
         // the first patch version on that day