-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use @vitejs/release-scripts in v3 (#16255)
- Loading branch information
1 parent
89c7c64
commit eda4df3
Showing
5 changed files
with
144 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }) | ||
})() |
Oops, something went wrong.