Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit a586901

Browse files
authored
workflow: add a "publish" workflow for automated releases (#9690)
1 parent 275354c commit a586901

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

.github/workflows/publish.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Publish Package
2+
3+
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
30+
31+
jobs:
32+
publish:
33+
# prevents this action from running on forks
34+
if: github.repository == 'vuejs/core'
35+
runs-on: ubuntu-latest
36+
permissions:
37+
contents: write
38+
id-token: write
39+
# Use Release environment for deployment protection
40+
environment: Release
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v4
44+
with:
45+
ref: ${{ inputs.branch }}
46+
47+
- name: Install pnpm
48+
uses: pnpm/action-setup@v2
49+
50+
- name: Install Node.js
51+
uses: actions/setup-node@v4
52+
with:
53+
node-version-file: '.node-version'
54+
cache: 'pnpm'
55+
56+
- name: Install deps
57+
run: pnpm install
58+
59+
- name: Configure git user as vue bot
60+
run: |
61+
git config user.name "vue-bot"
62+
git config user.email "<[email protected]>"
63+
64+
- name: Release
65+
run: pnpm release ${{ inputs.bump != 'custom' && inputs.bump || inputs.custom_version }} --skip-prompts
66+
env:
67+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
68+
69+
- name: Push tags
70+
run: git push -u origin ${{ inputs.branch }} --follow-tags

scripts/release.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ async function main() {
218218
}
219219
}
220220

221+
// @ts-expect-error
222+
if (versionIncrements.includes(targetVersion)) {
223+
// @ts-expect-error
224+
targetVersion = inc(targetVersion)
225+
}
226+
221227
if (!semver.valid(targetVersion)) {
222228
throw new Error(`invalid target version: ${targetVersion}`)
223229
}
@@ -338,6 +344,11 @@ async function main() {
338344
if (branch !== 'main') {
339345
additionalPublishFlags.push('--publish-branch', branch)
340346
}
347+
// add provenance metadata when releasing from CI
348+
// canary release commits are not pushed therefore we don't need to add provenance
349+
if (process.env.CI && !isCanary) {
350+
additionalPublishFlags.push('--provenance')
351+
}
341352

342353
for (const pkg of packages) {
343354
await publishPackage(pkg, targetVersion, additionalPublishFlags)

0 commit comments

Comments
 (0)