Skip to content

Commit b8fc18c

Browse files
authored
ci: add a canary release workflow for next minor (#9265)
1 parent 831e180 commit b8fc18c

File tree

2 files changed

+56
-5
lines changed

2 files changed

+56
-5
lines changed

.github/workflows/canary-minor.yml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: canary minor release
2+
on:
3+
# Runs every Monday at 1 AM UTC (9:00 AM in Singapore)
4+
schedule:
5+
- cron: 0 1 * * MON
6+
workflow_dispatch:
7+
8+
jobs:
9+
canary:
10+
# prevents this action from running on forks
11+
if: github.repository == 'vuejs/core'
12+
runs-on: ubuntu-latest
13+
environment: Release
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
ref: minor
18+
19+
- name: Install pnpm
20+
uses: pnpm/action-setup@v2
21+
22+
- name: Set node version to 18
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: 18
26+
registry-url: 'https://registry.npmjs.org'
27+
cache: 'pnpm'
28+
29+
- run: pnpm install
30+
31+
- run: pnpm release --canary --tag minor
32+
env:
33+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

scripts/release.js

+23-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ import { fileURLToPath } from 'node:url'
1212
const { prompt } = enquirer
1313
const currentVersion = createRequire(import.meta.url)('../package.json').version
1414
const __dirname = path.dirname(fileURLToPath(import.meta.url))
15-
const args = minimist(process.argv.slice(2))
15+
const args = minimist(process.argv.slice(2), {
16+
alias: {
17+
skipBuild: 'skip-build',
18+
skipTests: 'skip-tests',
19+
skipGit: 'skip-git',
20+
skipPrompts: 'skip-prompts'
21+
}
22+
})
23+
1624
const preId = args.preid || semver.prerelease(currentVersion)?.[0]
1725
const isDryRun = args.dry
1826
let skipTests = args.skipTests
@@ -74,17 +82,21 @@ async function main() {
7482
let targetVersion = args._[0]
7583

7684
if (isCanary) {
77-
// The canary version string format is `3.yyyyMMdd.0`.
85+
// The canary version string format is `3.yyyyMMdd.0` (or `3.yyyyMMdd.0-minor.0` for minor)
7886
// Use UTC date so that it's consistent across CI and maintainers' machines
7987
const date = new Date()
8088
const yyyy = date.getUTCFullYear()
8189
const MM = (date.getUTCMonth() + 1).toString().padStart(2, '0')
8290
const dd = date.getUTCDate().toString().padStart(2, '0')
8391

8492
const major = semver.major(currentVersion)
85-
const minor = `${yyyy}${MM}${dd}`
86-
const patch = 0
87-
let canaryVersion = `${major}.${minor}.${patch}`
93+
const datestamp = `${yyyy}${MM}${dd}`
94+
let canaryVersion
95+
96+
canaryVersion = `${major}.${datestamp}.0`
97+
if (args.tag && args.tag !== 'latest') {
98+
canaryVersion = `${major}.${datestamp}.0-${args.tag}.0`
99+
}
88100

89101
// check the registry to avoid version collision
90102
// in case we need to publish more than one canary versions in a day
@@ -100,9 +112,15 @@ async function main() {
100112
const latestSameDayPatch = /** @type {string} */ (
101113
semver.maxSatisfying(versions, `~${canaryVersion}`)
102114
)
115+
103116
canaryVersion = /** @type {string} */ (
104117
semver.inc(latestSameDayPatch, 'patch')
105118
)
119+
if (args.tag && args.tag !== 'latest') {
120+
canaryVersion = /** @type {string} */ (
121+
semver.inc(latestSameDayPatch, 'prerelease', args.tag)
122+
)
123+
}
106124
} catch (e) {
107125
if (/E404/.test(e.message)) {
108126
// the first patch version on that day

0 commit comments

Comments
 (0)