Skip to content

Commit

Permalink
ci: add a canary release workflow for next minor (vuejs#9265)
Browse files Browse the repository at this point in the history
  • Loading branch information
haoqunjiang committed Sep 22, 2023
1 parent 831e180 commit b8fc18c
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/canary-minor.yml
Original file line number Diff line number Diff line change
@@ -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 }}
28 changes: 23 additions & 5 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -74,17 +82,21 @@ 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()
const MM = (date.getUTCMonth() + 1).toString().padStart(2, '0')
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
Expand All @@ -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
Expand Down

0 comments on commit b8fc18c

Please sign in to comment.