Skip to content

Commit

Permalink
workflow: separate version bumping and publishing on release (#6879)
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu authored Feb 12, 2022
1 parent 633532c commit 8013d90
Show file tree
Hide file tree
Showing 8 changed files with 359 additions and 277 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Publish Package

on:
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
- "plugin-*" # Push events to matching plugin-*, i.e. plugin-(vue|vue-jsx|react|legacy)@1.0.0
- "create-vite*" # # Push events to matching create-vite*, i.e. [email protected]

jobs:
publish:
# prevents this action from running on forks
if: github.repository == 'vitejs/vite'
runs-on: ubuntu-latest
environment: Release
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 6

- name: Set node version to 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: "pnpm"

- name: Install deps
run: pnpm install

- name: Publish package
run: pnpm run ci-publish -- ${{ github.ref_name }} --dry
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
79 changes: 0 additions & 79 deletions .github/workflows/release.yml

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"docs": "vitepress dev docs",
"build-docs": "vitepress build docs",
"serve-docs": "vitepress serve docs",
"release": "ts-node scripts/release.ts",
"ci-publish": "ts-node scripts/publishCI.ts",
"build": "run-s build-vite build-plugin-vue build-plugin-react",
"build-vite": "cd packages/vite && npm run build",
"build-plugin-vue": "cd packages/plugin-vue && npm run build",
Expand Down
4 changes: 0 additions & 4 deletions packages/plugin-vue-jsx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
],
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-vue-jsx",
"release": "ts-node ../../scripts/release.ts --skipBuild"
},
"engines": {
"node": ">=12.0.0"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js & npm run patch-dist",
"patch-dist": "ts-node ../../scripts/patchEsbuildDist.ts dist/index.js vuePlugin",
"build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package plugin-vue",
"release": "ts-node ../../scripts/release.ts"
"prepublishOnly": "npm run build"
},
"engines": {
"node": ">=12.0.0"
Expand Down
31 changes: 31 additions & 0 deletions scripts/publishCI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { args, getPackageInfo, publishPackage, step } from './releaseUtils'

async function main() {
const tag = args._[0]

if (!tag) {
throw new Error('No tag specified')
}

let pkgName = 'vite'
let version

if (tag.includes('@')) [pkgName, version] = tag.split('@')
else version = tag

if (version.startsWith('v')) version = version.slice(1)

const { currentVersion, pkgDir } = getPackageInfo(pkgName)
if (currentVersion !== version)
throw new Error(
`Package version from tag "${version}" mismatches with current version "${currentVersion}"`
)

step('Publishing package...')
await publishPackage(pkgDir, version.includes('beta') ? 'beta' : undefined)
}

main().catch((err) => {
console.error(err)
process.exit(1)
})
Loading

0 comments on commit 8013d90

Please sign in to comment.