]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
workflow: add a "publish" workflow for automated releases (#9690)
authorHaoqun Jiang <haoqunjiang@gmail.com>
Tue, 6 Aug 2024 12:42:36 +0000 (20:42 +0800)
committerGitHub <noreply@github.com>
Tue, 6 Aug 2024 12:42:36 +0000 (20:42 +0800)
.github/workflows/publish.yml [new file with mode: 0644]
scripts/release.js

diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644 (file)
index 0000000..95a3cb9
--- /dev/null
@@ -0,0 +1,70 @@
+name: Publish Package
+
+on:
+  workflow_dispatch:
+    inputs:
+      branch:
+        description: 'Branch to publish'
+        required: true
+        default: 'main'
+        type: choice
+        options:
+          - main
+          - minor
+      bump:
+        description: 'Bump version'
+        required: true
+        default: 'patch'
+        type: choice
+        options:
+          - patch
+          - minor
+          - prepatch
+          - preminor
+          - custom
+      custom_version:
+        description: 'Custom version'
+        required: false
+        default: ''
+        type: string
+
+jobs:
+  publish:
+    # prevents this action from running on forks
+    if: github.repository == 'vuejs/core'
+    runs-on: ubuntu-latest
+    permissions:
+      contents: write
+      id-token: write
+    # Use Release environment for deployment protection
+    environment: Release
+    steps:
+      - name: Checkout
+        uses: actions/checkout@v4
+        with:
+          ref: ${{ inputs.branch }}
+
+      - name: Install pnpm
+        uses: pnpm/action-setup@v2
+
+      - name: Install Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version-file: '.node-version'
+          cache: 'pnpm'
+
+      - name: Install deps
+        run: pnpm install
+
+      - name: Configure git user as vue bot
+        run: |
+          git config user.name "vue-bot"
+          git config user.email "<bot@vuejs.org>"
+
+      - name: Release
+        run: pnpm release ${{ inputs.bump != 'custom' && inputs.bump || inputs.custom_version }} --skip-prompts
+        env:
+          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+
+      - name: Push tags
+        run: git push -u origin ${{ inputs.branch }} --follow-tags
index eed71c2fd192d268ee9c255bc88b5b0eebdfaf23..82ecf9f99004431a87be9aa4825dde2b81bab84f 100644 (file)
@@ -218,6 +218,12 @@ async function main() {
     }
   }
 
+  // @ts-expect-error
+  if (versionIncrements.includes(targetVersion)) {
+    // @ts-expect-error
+    targetVersion = inc(targetVersion)
+  }
+
   if (!semver.valid(targetVersion)) {
     throw new Error(`invalid target version: ${targetVersion}`)
   }
@@ -338,6 +344,11 @@ async function main() {
   if (branch !== 'main') {
     additionalPublishFlags.push('--publish-branch', branch)
   }
+  // add provenance metadata when releasing from CI
+  // canary release commits are not pushed therefore we don't need to add provenance
+  if (process.env.CI && !isCanary) {
+    additionalPublishFlags.push('--provenance')
+  }
 
   for (const pkg of packages) {
     await publishPackage(pkg, targetVersion, additionalPublishFlags)