Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow: separate version bumping and publishing on release #6879

Merged
merged 9 commits into from
Feb 12, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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. 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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: remove the --dry flag

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/create-vite/package.json
Original file line number Diff line number Diff line change
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
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-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
Original file line number Diff line number Diff line change
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
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
3 changes: 1 addition & 2 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
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
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