ci: add publish workflow (#5168)

This commit is contained in:
Vladimir 2024-02-16 10:51:02 +01:00 committed by GitHub
parent 65889222cd
commit 2ee2317f47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 229 additions and 52 deletions

48
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,48 @@
name: Publish Package
on:
push:
tags:
- 'v*'
permissions:
contents: read
id-token: write
jobs:
publish:
if: github.repository == 'vitest-dev/vitest'
runs-on: ubuntu-latest
environment: Release
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pnpm
uses: pnpm/action-setup@v2
- name: Set node version to 18
uses: actions/setup-node@v4
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: pnpm
- name: Install
run: pnpm install --frozen-lockfile --prefer-offline
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: '1'
- name: Build
run: pnpm build
- name: Publish to npm
run: pnpm run publish-ci {{ github.ref_name }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Generate Changelog
run: npx changelogithub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,25 +0,0 @@
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: npx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

View File

@ -21,8 +21,8 @@
"docs:contributors": "tsx scripts/update-contributors.ts",
"lint": "eslint --cache .",
"lint:fix": "nr lint --fix",
"release": "bumpp package.json packages/*/package.json --commit --push --tag && git update-ref refs/heads/release refs/heads/main && git push origin release && pnpm -r publish --access public",
"release:beta": "bumpp package.json packages/*/package.json --commit --push --tag && git update-ref refs/heads/release refs/heads/main && git push origin release && pnpm -r publish --access public --tag beta",
"publish-ci": "tsx scripts/publish-ci.ts",
"release": "bumpp package.json packages/*/package.json --commit --push --tag && git update-ref refs/heads/release refs/heads/main && git push origin release",
"test": "vitest --api -r test/core",
"test:run": "vitest run -r test/core",
"test:all": "CI=true pnpm -r --stream run test --allowOnly",
@ -65,7 +65,8 @@
"tsx": "^4.6.1",
"typescript": "^5.2.2",
"vite": "^5.0.12",
"vitest": "workspace:*"
"vitest": "workspace:*",
"zx": "^7.2.3"
},
"pnpm": {
"overrides": {

View File

@ -46,8 +46,7 @@
"build:node": "rollup -c",
"dev:client": "vite build src/client --watch",
"dev:node": "rollup -c --watch --watch.include 'src/node/**'",
"dev": "rimraf dist && pnpm run --stream '/^dev:/'",
"prepublishOnly": "pnpm build"
"dev": "rimraf dist && pnpm run --stream '/^dev:/'"
},
"peerDependencies": {
"playwright": "*",

View File

@ -38,8 +38,7 @@
],
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "rollup -c --watch --watch.include 'src/**'",
"prepublishOnly": "pnpm build"
"dev": "rollup -c --watch --watch.include 'src/**'"
},
"peerDependencies": {
"vitest": "workspace:*"

View File

@ -38,8 +38,7 @@
],
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "rollup -c --watch --watch.include 'src/**'",
"prepublishOnly": "pnpm build"
"dev": "rollup -c --watch --watch.include 'src/**'"
},
"peerDependencies": {
"vitest": "workspace:*"

View File

@ -31,8 +31,7 @@
],
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "rollup -c --watch",
"prepublishOnly": "pnpm build"
"dev": "rollup -c --watch"
},
"dependencies": {
"@vitest/spy": "workspace:*",

View File

@ -39,8 +39,7 @@
],
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "rollup -c --watch",
"prepublishOnly": "pnpm build"
"dev": "rollup -c --watch"
},
"dependencies": {
"@vitest/utils": "workspace:*",

View File

@ -39,8 +39,7 @@
],
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "rollup -c --watch",
"prepublishOnly": "pnpm build"
"dev": "rollup -c --watch"
},
"dependencies": {
"magic-string": "^0.30.5",

View File

@ -30,8 +30,7 @@
],
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "rollup -c --watch",
"prepublishOnly": "pnpm build"
"dev": "rollup -c --watch"
},
"dependencies": {
"tinyspy": "^2.2.0"

View File

@ -42,8 +42,7 @@
"dev": "rollup -c --watch --watch.include 'node/**'",
"dev:ui": "pnpm run --stream '/^(dev|dev:client)$/'",
"test:run": "cypress run --component",
"test:open": "cypress open --component",
"prepublishOnly": "pnpm build"
"test:open": "cypress open --component"
},
"peerDependencies": {
"vitest": "workspace:*"

View File

@ -58,8 +58,7 @@
],
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "rollup -c --watch",
"prepublishOnly": "pnpm build"
"dev": "rollup -c --watch"
},
"dependencies": {
"diff-sequences": "^29.6.3",

View File

@ -79,7 +79,6 @@
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "rollup -c --watch --watch.include 'src/**' -m inline",
"prepublishOnly": "pnpm build",
"typecheck": "tsc --noEmit"
},
"dependencies": {

View File

@ -112,8 +112,7 @@
},
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "NODE_OPTIONS=\"--max-old-space-size=8192\" rollup -c --watch -m inline",
"prepublishOnly": "pnpm build"
"dev": "NODE_OPTIONS=\"--max-old-space-size=8192\" rollup -c --watch -m inline"
},
"peerDependencies": {
"@edge-runtime/vm": "*",

View File

@ -35,7 +35,6 @@
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "rollup -c --watch --watch.include 'src/**'",
"prepublishOnly": "pnpm build",
"typecheck": "tsc --noEmit"
},
"peerDependencies": {

View File

@ -35,7 +35,6 @@
"scripts": {
"build": "rimraf dist && rollup -c",
"dev": "rollup -c --watch --watch.include 'src/**'",
"prepublishOnly": "pnpm build",
"typecheck": "tsc --noEmit"
},
"dependencies": {

133
pnpm-lock.yaml generated
View File

@ -108,6 +108,9 @@ importers:
vitest:
specifier: workspace:*
version: link:packages/vitest
zx:
specifier: ^7.2.3
version: 7.2.3
docs:
dependencies:
@ -9211,10 +9214,17 @@ packages:
resolution: {integrity: sha512-frsJrz2t/CeGifcu/6uRo4b+SzAwT4NYCVPu1GN8IB9XTzrpPkGuV0tmh9mN+/L0PklAlsC3u5Fxt0ju00LXIw==}
dev: true
/@types/fs-extra@11.0.4:
resolution: {integrity: sha512-yTbItCNreRooED33qjunPthRcSjERP1r4MqCZc7wv0u2sUkzTFp45tgUfS5+r7FrZPdmCCNflLhVSP/o+SemsQ==}
dependencies:
'@types/jsonfile': 6.1.4
'@types/node': 20.11.17
dev: true
/@types/fs-extra@8.1.3:
resolution: {integrity: sha512-7IdV01N0u/CaVO0fuY1YmEg14HQN3+EW8mpNgg6NEfxEl/lzCa5OxlBu3iFsCAdamnYOcTQ7oEi43Xc/67Rgzw==}
dependencies:
'@types/node': 20.11.5
'@types/node': 20.11.17
dev: true
/@types/fs-extra@9.0.13:
@ -9335,6 +9345,12 @@ packages:
resolution: {integrity: sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw==}
dev: true
/@types/jsonfile@6.1.4:
resolution: {integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==}
dependencies:
'@types/node': 20.11.17
dev: true
/@types/linkify-it@3.0.4:
resolution: {integrity: sha512-hPpIeeHb/2UuCw06kSNAOVWgehBLXEo0/fUs0mw3W2qhqX89PI2yvok83MnuctYGCPrabGIoi0fFso4DQ+sNUQ==}
dev: true
@ -9378,6 +9394,10 @@ packages:
resolution: {integrity: sha512-v55NF6Dz0wrj14Rn8iEABTWrhYRmgkJYuokduunSiq++t3hZ9VZ6dvcDt+850Pm5sGJZk8RaHzkFCXPxVINZ+g==}
dev: true
/@types/minimist@1.2.5:
resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==}
dev: true
/@types/ms@0.7.31:
resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==}
dev: true
@ -9479,6 +9499,10 @@ packages:
/@types/prop-types@15.7.9:
resolution: {integrity: sha512-n1yyPsugYNSmHgxDFjicaI2+gCNjsBck8UX9kuofAKlc0h1bL+20oSF72KeNaW2DUlesbEVCFgyV2dPGTiY42g==}
/@types/ps-tree@1.1.6:
resolution: {integrity: sha512-PtrlVaOaI44/3pl3cvnlK+GxOM3re2526TJvPvh7W+keHIXdV4TE0ylpPBAcvFQCbGitaTXwL9u+RF7qtVeazQ==}
dev: true
/@types/pug@2.0.6:
resolution: {integrity: sha512-SnHmG9wN1UVmagJOnyo/qkk0Z7gejYxOYYmaAwr5u2yFYfsupN3sg10kyzN8Hep/2zbHxCnsumxOoRIRMBwKCg==}
dev: true
@ -9718,6 +9742,10 @@ packages:
resolution: {integrity: sha512-113D3mDkZDjo+EeUEHCFy0qniNc1ZpecGiAU7WSo7YDoSzolZIQKpYFHrPpjkB2nuyahcKfrmLXeQlh7gqJYdw==}
dev: true
/@types/which@3.0.3:
resolution: {integrity: sha512-2C1+XoY0huExTbs8MQv1DuS5FS86+SEjdM9F/+GS61gg5Hqbtj8ZiDSx8MfWcyei907fIPbfPGCOrNUTnVHY1g==}
dev: true
/@types/ws@8.5.9:
resolution: {integrity: sha512-jbdrY0a8lxfdTp/+r7Z4CkycbOFN8WX+IOchLJr3juT/xzbJ8URyTVSJ/hvNdadTgM1mnedb47n+Y31GsFnQlg==}
dependencies:
@ -15739,6 +15767,18 @@ packages:
engines: {node: '>= 0.6'}
dev: true
/event-stream@3.3.4:
resolution: {integrity: sha512-QHpkERcGsR0T7Qm3HNJSyXKEEj8AHNxkY3PK8TS2KJvQ7NiSHe3DDpwVKKtoYprL/AreyzFBeIkBIWChAqn60g==}
dependencies:
duplexer: 0.1.2
from: 0.1.7
map-stream: 0.1.0
pause-stream: 0.0.11
split: 0.3.3
stream-combiner: 0.0.4
through: 2.3.8
dev: true
/event-target-shim@5.0.1:
resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==}
engines: {node: '>=6'}
@ -16557,6 +16597,10 @@ packages:
readable-stream: 2.3.7
dev: true
/from@0.1.7:
resolution: {integrity: sha512-twe20eF1OxVxp/ML/kq2p1uc6KvFK/+vs8WjEbeKmV2He22MKm7YF2ANIt+EOqhJ5L3K/SuuPhk0hWQDjOM23g==}
dev: true
/fs-constants@1.0.0:
resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==}
dev: true
@ -16680,6 +16724,11 @@ packages:
resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==}
dev: true
/fx@31.0.0:
resolution: {integrity: sha512-OoeYSPKqNKmfnH4s+rGYI0c8OZmqqOOXsUtqy0YyHqQQoQSDiDs3m3M9uXKx5OQR+jDx7/FhYqpO3kl/As/xgg==}
hasBin: true
dev: true
/gauge@3.0.2:
resolution: {integrity: sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==}
engines: {node: '>=10'}
@ -17051,6 +17100,17 @@ packages:
slash: 3.0.0
dev: true
/globby@13.2.2:
resolution: {integrity: sha512-Y1zNGV+pzQdh7H39l9zgB4PJqjRNqydvdYCDG4HFXM4XuvSaQQlEc91IU1yALL8gUTDomgBAfz3XJdmUS+oo0w==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dependencies:
dir-glob: 3.0.1
fast-glob: 3.3.2
ignore: 5.2.4
merge2: 1.4.1
slash: 4.0.0
dev: true
/globby@9.2.0:
resolution: {integrity: sha512-ollPHROa5mcxDEkwg6bPt3QbEf4pDQSNtd6JPL1YvOvAo/7/0VAm9TccUeoTmarjPw4pfUthSCqcyfNB1I3ZSg==}
engines: {node: '>=6'}
@ -20069,6 +20129,10 @@ packages:
resolution: {integrity: sha512-0aF7ZmVon1igznGI4VS30yugpduQW3y3GkcgGJOp7d8x8QrizhigUxjI/m2UojsXXto+jLAH3KSz+xOJTiORjg==}
dev: true
/map-stream@0.1.0:
resolution: {integrity: sha512-CkYQrPYZfWnu/DAmVCpTSX/xHpKZ80eKh2lAkyA6AJTef6bW+6JpbQZN5rofum7da+SyN1bi5ctTm+lTfcCW3g==}
dev: true
/map-visit@1.0.0:
resolution: {integrity: sha512-4y7uGv8bd2WdM9vpQsiQNo41Ln1NvhvDRuVt0k2JZQ+ezN2uaQes7lZeZ+QQUHOLQAtDaBJ+7wCbi+ab/KFs+w==}
engines: {node: '>=0.10.0'}
@ -20843,6 +20907,15 @@ packages:
whatwg-url: 5.0.0
dev: true
/node-fetch@3.3.1:
resolution: {integrity: sha512-cRVc/kyto/7E5shrWca1Wsea4y6tL9iYJE5FBCius3JQfb/4P4I295PfhgbJQBLTx6lATE4z+wK0rPM4VS2uow==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
dependencies:
data-uri-to-buffer: 4.0.1
fetch-blob: 3.2.0
formdata-polyfill: 4.0.10
dev: true
/node-fetch@3.3.2:
resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==}
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
@ -21605,6 +21678,12 @@ packages:
resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==}
dev: false
/pause-stream@0.0.11:
resolution: {integrity: sha512-e3FBlXLmN/D1S+zHzanP4E/4Z60oFAa3O051qt1pxa7DEJWKAyil6upYVXCWadEnuoqa4Pkc9oUx9zsxYeRv8A==}
dependencies:
through: 2.3.8
dev: true
/pbkdf2@3.1.2:
resolution: {integrity: sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==}
engines: {node: '>=0.12'}
@ -22129,6 +22208,14 @@ packages:
resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==}
requiresBuild: true
/ps-tree@1.2.0:
resolution: {integrity: sha512-0VnamPPYHl4uaU/nSFeZZpR21QAWRz+sRv4iW9+v/GS/J5U5iZB5BNN6J0RMoOvdx2gWM2+ZFMIm58q24e4UYA==}
engines: {node: '>= 0.10'}
hasBin: true
dependencies:
event-stream: 3.3.4
dev: true
/psl@1.9.0:
resolution: {integrity: sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==}
dev: true
@ -23809,6 +23896,11 @@ packages:
engines: {node: '>=8'}
dev: true
/slash@4.0.0:
resolution: {integrity: sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==}
engines: {node: '>=12'}
dev: true
/slice-ansi@3.0.0:
resolution: {integrity: sha512-pSyv7bSTC7ig9Dcgbw9AuRNUb5k5V6oDudjZoMBSr13qpLBG7tB+zgCkARjq7xIUgdz5P1Qe8u+rSGdouOOIyQ==}
engines: {node: '>=8'}
@ -24078,6 +24170,12 @@ packages:
engines: {node: '>= 10.x'}
dev: true
/split@0.3.3:
resolution: {integrity: sha512-wD2AeVmxXRBoX44wAycgjVpMhvbwdI2aZjCkvfNcH1YqHQvJVa1duWc73OyVGJUc05fhFaTZeQ/PYsrmyH0JVA==}
dependencies:
through: 2.3.8
dev: true
/splitpanes@3.1.5:
resolution: {integrity: sha512-r3Mq2ITFQ5a2VXLOy4/Sb2Ptp7OfEO8YIbhVJqJXoFc9hc5nTXXkCvtVDjIGbvC0vdE7tse+xTM9BMjsszP6bw==}
dev: true
@ -24185,6 +24283,12 @@ packages:
readable-stream: 2.3.7
dev: true
/stream-combiner@0.0.4:
resolution: {integrity: sha512-rT00SPnTVyRsaSz5zgSPma/aHSOic5U1prhYdRy5HS2kTZviFpmDgzilbtsJsxiroqACmayynDN/9VzIbX5DOw==}
dependencies:
duplexer: 0.1.2
dev: true
/stream-each@1.2.3:
resolution: {integrity: sha512-vlMC2f8I2u/bZGqkdfLQW/13Zihpej/7PmSiMQsbYddxuTsJp8vRe2x2FvVExZg7FaOds43ROAuFJwPR4MTZLw==}
dependencies:
@ -26856,6 +26960,11 @@ packages:
- uglify-js
dev: true
/webpod@0.0.2:
resolution: {integrity: sha512-cSwwQIeg8v4i3p4ajHhwgR7N6VyxAf+KYSSsY6Pd3aETE+xEU4vbitz7qQkB0I321xnhDdgtxuiSfk5r/FVtjg==}
hasBin: true
dev: true
/whatwg-encoding@1.0.5:
resolution: {integrity: sha512-b5lim54JOPN9HtzvK9HFXvBma/rnfFeqsic0hSpjtDbVxR3dJKLc+KB4V6GgiGOvl7CY/KNh8rxSo9DKQrnUEw==}
dependencies:
@ -27477,6 +27586,28 @@ packages:
resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==}
dev: true
/zx@7.2.3:
resolution: {integrity: sha512-QODu38nLlYXg/B/Gw7ZKiZrvPkEsjPN3LQ5JFXM7h0JvwhEdPNNl+4Ao1y4+o3CLNiDUNcwzQYZ4/Ko7kKzCMA==}
engines: {node: '>= 16.0.0'}
hasBin: true
dependencies:
'@types/fs-extra': 11.0.4
'@types/minimist': 1.2.5
'@types/node': 18.18.9
'@types/ps-tree': 1.1.6
'@types/which': 3.0.3
chalk: 5.3.0
fs-extra: 11.1.1
fx: 31.0.0
globby: 13.2.2
minimist: 1.2.8
node-fetch: 3.3.1
ps-tree: 1.2.0
webpod: 0.0.2
which: 3.0.1
yaml: 2.3.4
dev: true
file:test/config/fixtures/conditions-subpackage:
resolution: {directory: test/config/fixtures/conditions-subpackage, type: directory}
name: subpackage

35
scripts/publish-ci.ts Normal file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env zx
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { $ } from 'zx'
let version = process.argv[2]
if (!version)
throw new Error('No tag specified')
if (version.startsWith('v'))
version = version.slice(1)
const pkgPath = fileURLToPath(new URL('../package.json', import.meta.url))
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'))
if (pkg.version !== version) {
throw new Error(
`Package version from tag "${version}" mismatches with the current version "${pkg.version}"`,
)
}
const releaseTag = version.includes('beta')
? 'beta'
: version.includes('alpha')
? 'alpha'
: undefined
console.log('Publishing version', version, 'with tag', releaseTag)
if (releaseTag)
await $`pnpm -r publish --provenance --access public --tag ${releaseTag}`
else
await $`pnpm -r publish --provenance --access public`