mirror of https://github.com/vuejs/core.git
workflow: bypass pnpm publish branch restrictions during release
This commit is contained in:
parent
26399aa6fa
commit
fe82f96376
|
@ -270,8 +270,23 @@ async function main() {
|
||||||
|
|
||||||
// publish packages
|
// publish packages
|
||||||
step('\nPublishing packages...')
|
step('\nPublishing packages...')
|
||||||
|
|
||||||
|
const additionalPublishFlags = []
|
||||||
|
if (isDryRun) {
|
||||||
|
additionalPublishFlags.push('--dry-run')
|
||||||
|
}
|
||||||
|
if (skipGit) {
|
||||||
|
additionalPublishFlags.push('--no-git-checks')
|
||||||
|
}
|
||||||
|
// bypass the pnpm --publish-branch restriction which isn't too useful to us
|
||||||
|
// otherwise it leads to a prompt and blocks the release script
|
||||||
|
const branch = await getBranch()
|
||||||
|
if (branch !== 'main') {
|
||||||
|
additionalPublishFlags.push('--publish-branch', branch)
|
||||||
|
}
|
||||||
|
|
||||||
for (const pkg of packages) {
|
for (const pkg of packages) {
|
||||||
await publishPackage(pkg, targetVersion)
|
await publishPackage(pkg, targetVersion, additionalPublishFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// push to GitHub
|
// push to GitHub
|
||||||
|
@ -300,7 +315,7 @@ async function main() {
|
||||||
|
|
||||||
async function getCIResult() {
|
async function getCIResult() {
|
||||||
try {
|
try {
|
||||||
const { stdout: sha } = await execa('git', ['rev-parse', 'HEAD'])
|
const sha = await getSha()
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://api.github.com/repos/vuejs/core/actions/runs?head_sha=${sha}` +
|
`https://api.github.com/repos/vuejs/core/actions/runs?head_sha=${sha}` +
|
||||||
`&status=success&exclude_pull_requests=true`
|
`&status=success&exclude_pull_requests=true`
|
||||||
|
@ -315,17 +330,12 @@ async function getCIResult() {
|
||||||
|
|
||||||
async function isInSyncWithRemote() {
|
async function isInSyncWithRemote() {
|
||||||
try {
|
try {
|
||||||
const { stdout: sha } = await execa('git', ['rev-parse', 'HEAD'])
|
const branch = await getBranch()
|
||||||
const { stdout: branch } = await execa('git', [
|
|
||||||
'rev-parse',
|
|
||||||
'--abbrev-ref',
|
|
||||||
'HEAD'
|
|
||||||
])
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://api.github.com/repos/vuejs/core/commits/${branch}?per_page=1`
|
`https://api.github.com/repos/vuejs/core/commits/${branch}?per_page=1`
|
||||||
)
|
)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
return data.sha === sha
|
return data.sha === (await getSha())
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(
|
console.error(
|
||||||
'Failed to check whether local HEAD is up-to-date with remote.'
|
'Failed to check whether local HEAD is up-to-date with remote.'
|
||||||
|
@ -334,6 +344,14 @@ async function isInSyncWithRemote() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getSha() {
|
||||||
|
return (await execa('git', ['rev-parse', 'HEAD'])).stdout
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getBranch() {
|
||||||
|
return (await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'])).stdout
|
||||||
|
}
|
||||||
|
|
||||||
function updateVersions(version, getNewPackageName = keepThePackageName) {
|
function updateVersions(version, getNewPackageName = keepThePackageName) {
|
||||||
// 1. update root package.json
|
// 1. update root package.json
|
||||||
updatePackage(path.resolve(__dirname, '..'), version, getNewPackageName)
|
updatePackage(path.resolve(__dirname, '..'), version, getNewPackageName)
|
||||||
|
@ -371,7 +389,7 @@ function updateDeps(pkg, depType, version, getNewPackageName) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function publishPackage(pkgName, version) {
|
async function publishPackage(pkgName, version, additionalFlags) {
|
||||||
if (skippedPackages.includes(pkgName)) {
|
if (skippedPackages.includes(pkgName)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -402,8 +420,7 @@ async function publishPackage(pkgName, version) {
|
||||||
...(releaseTag ? ['--tag', releaseTag] : []),
|
...(releaseTag ? ['--tag', releaseTag] : []),
|
||||||
'--access',
|
'--access',
|
||||||
'public',
|
'public',
|
||||||
...(isDryRun ? ['--dry-run'] : []),
|
...additionalFlags
|
||||||
...(skipGit ? ['--no-git-checks'] : [])
|
|
||||||
],
|
],
|
||||||
{
|
{
|
||||||
cwd: pkgRoot,
|
cwd: pkgRoot,
|
||||||
|
|
Loading…
Reference in New Issue