Skip to content

Commit eda4df3

Browse files
authored
chore: use @vitejs/release-scripts in v3 (#16255)
1 parent 89c7c64 commit eda4df3

5 files changed

Lines changed: 144 additions & 381 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"@types/ws": "^8.5.3",
6161
"@typescript-eslint/eslint-plugin": "^5.41.0",
6262
"@typescript-eslint/parser": "^5.41.0",
63+
"@vitejs/release-scripts": "^1.3.1",
6364
"conventional-changelog-cli": "^2.2.2",
6465
"esbuild": "^0.14.47",
6566
"eslint": "^8.26.0",

pnpm-lock.yaml

Lines changed: 98 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/publishCI.ts

Lines changed: 8 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,10 @@
1-
import semver from 'semver'
2-
import {
3-
args,
4-
getActiveVersion,
5-
getPackageInfo,
6-
publishPackage,
7-
step
8-
} from './releaseUtils'
1+
;(async () => {
2+
const { publish } = await import('@vitejs/release-scripts')
93

10-
async function main() {
11-
const tag = args._[0]
4+
// Check the tag passed in CI, and skip provenance if tag has `@` due to
5+
// https://github.com/slsa-framework/slsa-github-generator/pull/2758 not released
6+
const tag = process.argv.slice(2)[0] ?? ''
7+
const provenance = !tag.includes('@')
128

13-
if (!tag) {
14-
throw new Error('No tag specified')
15-
}
16-
17-
let pkgName = 'vite'
18-
let version
19-
20-
if (tag.includes('@')) [pkgName, version] = tag.split('@')
21-
else version = tag
22-
23-
if (version.startsWith('v')) version = version.slice(1)
24-
25-
const { currentVersion, pkgDir } = getPackageInfo(pkgName)
26-
if (currentVersion !== version)
27-
throw new Error(
28-
`Package version from tag "${version}" mismatches with current version "${currentVersion}"`
29-
)
30-
31-
const activeVersion = await getActiveVersion(pkgName)
32-
33-
step('Publishing package...')
34-
const releaseTag = version.includes('beta')
35-
? 'beta'
36-
: version.includes('alpha')
37-
? 'alpha'
38-
: semver.lt(currentVersion, activeVersion)
39-
? 'previous'
40-
: undefined
41-
await publishPackage(pkgDir, releaseTag)
42-
}
43-
44-
main().catch((err) => {
45-
console.error(err)
46-
process.exit(1)
47-
})
9+
publish({ defaultPackage: 'vite', provenance, packageManager: 'pnpm' })
10+
})()

0 commit comments

Comments
 (0)