Skip to content

Commit 47cdf24

Browse files
committed
workflow: adjust release workflow
1 parent 32a1433 commit 47cdf24

File tree

5 files changed

+113
-151
lines changed

5 files changed

+113
-151
lines changed

.github/workflows/canary-minor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ jobs:
2828

2929
- run: pnpm install
3030

31-
- run: pnpm release --canary --tag minor
31+
- run: pnpm release --canary --publish --tag minor
3232
env:
3333
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/canary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626

2727
- run: pnpm install
2828

29-
- run: pnpm release --canary
29+
- run: pnpm release --canary --publish
3030
env:
3131
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release-gh.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 8 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,9 @@
11
name: Release
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
branch:
7-
description: 'Branch to publish'
8-
required: true
9-
default: 'main'
10-
type: choice
11-
options:
12-
- main
13-
- minor
14-
bump:
15-
description: 'Bump version'
16-
required: true
17-
default: 'patch'
18-
type: choice
19-
options:
20-
- patch
21-
- minor
22-
- prepatch
23-
- preminor
24-
- custom
25-
custom_version:
26-
description: 'Custom version'
27-
required: false
28-
default: ''
29-
type: string
4+
push:
5+
tags:
6+
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
307

318
jobs:
329
release:
@@ -41,9 +18,6 @@ jobs:
4118
steps:
4219
- name: Checkout
4320
uses: actions/checkout@v4
44-
with:
45-
ref: ${{ inputs.branch }}
46-
fetch-depth: 0 # need this to get tags for changelog generation
4721

4822
- name: Install pnpm
4923
uses: pnpm/action-setup@v4
@@ -58,38 +32,20 @@ jobs:
5832
- name: Install deps
5933
run: pnpm install
6034

61-
- name: Configure git user as vue bot
62-
run: |
63-
git config user.name "vue-bot"
64-
git config user.email "<bot@vuejs.org>"
65-
66-
- name: Import GPG key
67-
uses: crazy-max/ghaction-import-gpg@v6
68-
with:
69-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
70-
passphrase: ${{ secrets.GPG_PASSPHRASE }}
71-
git_user_signingkey: true
72-
git_commit_gpgsign: true
73-
74-
- name: Run release script
75-
id: release
35+
- name: Build and publish
36+
id: publish
7637
run: |
77-
pnpm release ${{ inputs.bump != 'custom' && inputs.bump || inputs.custom_version }} --skipPrompts
78-
RELEASE_TAG=$(git describe --tags --abbrev=0)
79-
echo "tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
38+
pnpm release --publishOnly
8039
env:
8140
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8241

83-
- name: Push tags
84-
run: git push -u origin ${{ inputs.branch }} --follow-tags
85-
86-
- name: Create Release for Tag
42+
- name: Create GitHub release
8743
id: release_tag
8844
uses: yyx990803/release-tag@master
8945
env:
9046
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9147
with:
92-
tag_name: ${{ steps.release.outputs.tag }}
48+
tag_name: ${{ github.ref }}
9349
body: |
9450
For stable releases, please refer to [CHANGELOG.md](https://github.com/vuejs/core/blob/main/CHANGELOG.md) for details.
9551
For pre-releases, please refer to [CHANGELOG.md](https://github.com/vuejs/core/blob/minor/CHANGELOG.md) of the `minor` branch.

scripts/release.js

Lines changed: 103 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ const { values: args, positionals } = parseArgs({
5151
skipPrompts: {
5252
type: 'boolean',
5353
},
54+
publish: {
55+
type: 'boolean',
56+
default: false,
57+
},
58+
publishOnly: {
59+
type: 'boolean',
60+
},
5461
},
5562
})
5663

@@ -247,41 +254,7 @@ async function main() {
247254
}
248255
}
249256

250-
if (!skipTests) {
251-
step('Checking CI status for HEAD...')
252-
let isCIPassed = await getCIResult()
253-
skipTests ||= isCIPassed
254-
255-
if (isCIPassed) {
256-
if (!skipPrompts) {
257-
/** @type {{ yes: boolean }} */
258-
const { yes: promptSkipTests } = await prompt({
259-
type: 'confirm',
260-
name: 'yes',
261-
message: `CI for this commit passed. Skip local tests?`,
262-
})
263-
skipTests = promptSkipTests
264-
} else {
265-
skipTests = true
266-
}
267-
} else if (skipPrompts) {
268-
throw new Error(
269-
'CI for the latest commit has not passed yet. ' +
270-
'Only run the release workflow after the CI has passed.',
271-
)
272-
}
273-
}
274-
275-
if (!skipTests) {
276-
step('\nRunning tests...')
277-
if (!isDryRun) {
278-
await run('pnpm', ['run', 'test', '--run'])
279-
} else {
280-
console.log(`Skipped (dry run)`)
281-
}
282-
} else {
283-
step('Tests skipped.')
284-
}
257+
await runTestsIfNeeded()
285258

286259
// update all package versions and inter-dependencies
287260
step('\nUpdating cross dependencies...')
@@ -291,16 +264,6 @@ async function main() {
291264
)
292265
versionUpdated = true
293266

294-
// build all packages with types
295-
step('\nBuilding all packages...')
296-
if (!skipBuild && !isDryRun) {
297-
await run('pnpm', ['run', 'build', '--withTypes'])
298-
step('\nTesting built types...')
299-
await run('pnpm', ['test-dts-only'])
300-
} else {
301-
console.log(`(skipped)`)
302-
}
303-
304267
// generate changelog
305268
step('\nGenerating changelog...')
306269
await run(`pnpm`, ['run', 'changelog'])
@@ -337,29 +300,15 @@ async function main() {
337300
}
338301

339302
// publish packages
340-
step('\nPublishing packages...')
341-
342-
const additionalPublishFlags = []
343-
if (isDryRun) {
344-
additionalPublishFlags.push('--dry-run')
345-
}
346-
if (isDryRun || skipGit) {
347-
additionalPublishFlags.push('--no-git-checks')
348-
}
349-
// bypass the pnpm --publish-branch restriction which isn't too useful to us
350-
// otherwise it leads to a prompt and blocks the release script
351-
const branch = await getBranch()
352-
if (branch !== 'main') {
353-
additionalPublishFlags.push('--publish-branch', branch)
354-
}
355-
// add provenance metadata when releasing from CI
356-
// canary release commits are not pushed therefore we don't need to add provenance
357-
if (process.env.CI && !isCanary) {
358-
additionalPublishFlags.push('--provenance')
359-
}
360-
361-
for (const pkg of packages) {
362-
await publishPackage(pkg, targetVersion, additionalPublishFlags)
303+
if (args.publish) {
304+
await buildPackages()
305+
await publishPackages(targetVersion)
306+
} else {
307+
console.log(
308+
pico.yellow(
309+
'\nPublish step skipped (will be done in GitHub actions on successful push)',
310+
),
311+
)
363312
}
364313

365314
// push to GitHub
@@ -386,6 +335,44 @@ async function main() {
386335
console.log()
387336
}
388337

338+
async function runTestsIfNeeded() {
339+
if (!skipTests) {
340+
step('Checking CI status for HEAD...')
341+
let isCIPassed = await getCIResult()
342+
skipTests ||= isCIPassed
343+
344+
if (isCIPassed) {
345+
if (!skipPrompts) {
346+
/** @type {{ yes: boolean }} */
347+
const { yes: promptSkipTests } = await prompt({
348+
type: 'confirm',
349+
name: 'yes',
350+
message: `CI for this commit passed. Skip local tests?`,
351+
})
352+
skipTests = promptSkipTests
353+
} else {
354+
skipTests = true
355+
}
356+
} else if (skipPrompts) {
357+
throw new Error(
358+
'CI for the latest commit has not passed yet. ' +
359+
'Only run the release workflow after the CI has passed.',
360+
)
361+
}
362+
}
363+
364+
if (!skipTests) {
365+
step('\nRunning tests...')
366+
if (!isDryRun) {
367+
await run('pnpm', ['run', 'test', '--run'])
368+
} else {
369+
console.log(`Skipped (dry run)`)
370+
}
371+
} else {
372+
step('Tests skipped.')
373+
}
374+
}
375+
389376
async function getCIResult() {
390377
try {
391378
const sha = await getSha()
@@ -492,6 +479,46 @@ function updateDeps(pkg, depType, version, getNewPackageName) {
492479
})
493480
}
494481

482+
async function buildPackages() {
483+
step('\nBuilding all packages...')
484+
if (!skipBuild) {
485+
await run('pnpm', ['run', 'build', '--withTypes'])
486+
} else {
487+
console.log(`(skipped)`)
488+
}
489+
}
490+
491+
/**
492+
* @param {string} version
493+
*/
494+
async function publishPackages(version) {
495+
// publish packages
496+
step('\nPublishing packages...')
497+
498+
const additionalPublishFlags = []
499+
if (isDryRun) {
500+
additionalPublishFlags.push('--dry-run')
501+
}
502+
if (isDryRun || skipGit) {
503+
additionalPublishFlags.push('--no-git-checks')
504+
}
505+
// bypass the pnpm --publish-branch restriction which isn't too useful to us
506+
// otherwise it leads to a prompt and blocks the release script
507+
const branch = await getBranch()
508+
if (branch !== 'main') {
509+
additionalPublishFlags.push('--publish-branch', branch)
510+
}
511+
// add provenance metadata when releasing from CI
512+
// canary release commits are not pushed therefore we don't need to add provenance
513+
if (process.env.CI && !isCanary) {
514+
additionalPublishFlags.push('--provenance')
515+
}
516+
517+
for (const pkg of packages) {
518+
await publishPackage(pkg, version, additionalPublishFlags)
519+
}
520+
}
521+
495522
/**
496523
* @param {string} pkgName
497524
* @param {string} version
@@ -541,7 +568,14 @@ async function publishPackage(pkgName, version, additionalFlags) {
541568
}
542569
}
543570

544-
main().catch(err => {
571+
async function publishOnly() {
572+
await buildPackages()
573+
await publishPackages(currentVersion)
574+
}
575+
576+
const fnToRun = args.publishOnly ? publishOnly : main
577+
578+
fnToRun().catch(err => {
545579
if (versionUpdated) {
546580
// revert to current version on failed releases
547581
updateVersions(currentVersion)

0 commit comments

Comments
 (0)