Skip to content

Commit

Permalink
chore: use @vitejs/release-scripts in v3 (#16255)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored Mar 24, 2024
1 parent 89c7c64 commit eda4df3
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 381 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"@types/ws": "^8.5.3",
"@typescript-eslint/eslint-plugin": "^5.41.0",
"@typescript-eslint/parser": "^5.41.0",
"@vitejs/release-scripts": "^1.3.1",
"conventional-changelog-cli": "^2.2.2",
"esbuild": "^0.14.47",
"eslint": "^8.26.0",
Expand Down
98 changes: 98 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

53 changes: 8 additions & 45 deletions scripts/publishCI.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,10 @@
import semver from 'semver'
import {
args,
getActiveVersion,
getPackageInfo,
publishPackage,
step
} from './releaseUtils'
;(async () => {
const { publish } = await import('@vitejs/release-scripts')

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

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}"`
)

const activeVersion = await getActiveVersion(pkgName)

step('Publishing package...')
const releaseTag = version.includes('beta')
? 'beta'
: version.includes('alpha')
? 'alpha'
: semver.lt(currentVersion, activeVersion)
? 'previous'
: undefined
await publishPackage(pkgDir, releaseTag)
}

main().catch((err) => {
console.error(err)
process.exit(1)
})
publish({ defaultPackage: 'vite', provenance, packageManager: 'pnpm' })
})()
Loading

0 comments on commit eda4df3

Please sign in to comment.