Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
workflow: separate version bumping and publishing on release (#6879)
  • Loading branch information
antfu committed Feb 12, 2022
1 parent 6ea6e08 commit fe8ef39
Show file tree
Hide file tree
Showing 13 changed files with 361 additions and 312 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/publish.yml
@@ -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. create-vite@1.0.0

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
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/create-vite/package.json
Expand Up @@ -12,10 +12,6 @@
"template-*"
],
"main": "index.js",
"scripts": {
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path . --lerna-package create-vite",
"release": "ts-node updateVersions && ts-node ../../scripts/release.ts --skipBuild"
},
"engines": {
"node": ">=12.0.0"
},
Expand Down
23 changes: 0 additions & 23 deletions packages/create-vite/updateVersions.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/plugin-legacy/package.json
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-legacy",
"release": "ts-node ../../scripts/release.ts --skipBuild"
},
"engines": {
"node": ">=12.0.0"
},
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-react/package.json
Expand Up @@ -18,8 +18,7 @@
"build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@babel/* --external:@rollup/* --external:resolve --external:react-refresh/* --outfile=dist/index.js && npm run patch-dist",
"patch-dist": "ts-node ../../scripts/patchEsbuildDist.ts dist/index.js viteReact",
"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-react",
"release": "ts-node ../../scripts/release.ts"
"prepublishOnly": "npm run build"
},
"engines": {
"node": ">=12.0.0"
Expand Down
4 changes: 0 additions & 4 deletions packages/plugin-vue-jsx/package.json
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
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
3 changes: 1 addition & 2 deletions packages/vite/package.json
Expand Up @@ -39,8 +39,7 @@
"roll-types": "api-extractor run && rimraf temp",
"lint": "eslint --ext .ts src/**",
"format": "prettier --write --parser typescript \"src/**/*.ts\"",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path .",
"release": "ts-node ../../scripts/release.ts"
"prepublishOnly": "npm run build"
},
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
"dependencies": {
Expand Down
31 changes: 31 additions & 0 deletions scripts/publishCI.ts
@@ -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)
})

0 comments on commit fe8ef39

Please sign in to comment.