Skip to content

Commit f23d951

Browse files
committed
chore: check if commit is up-to-date with remote before release
1 parent e3c2d69 commit f23d951

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scripts/release.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ const getPkgRoot = pkg => path.resolve(__dirname, '../packages/' + pkg)
7979
const step = msg => console.log(chalk.cyan(msg))
8080

8181
async function main() {
82+
if (!(await isInSyncWithRemote())) {
83+
return
84+
} else {
85+
console.log(`${chalk.green(`✓`)} commit is up-to-date with rmeote.\n`)
86+
}
87+
8288
let targetVersion = args._[0]
8389

8490
if (isCanary) {
@@ -299,6 +305,28 @@ async function getCIResult() {
299305
const data = await res.json()
300306
return data.workflow_runs.length > 0
301307
} catch (e) {
308+
console.error('Failed to get CI status for current commit.')
309+
return false
310+
}
311+
}
312+
313+
async function isInSyncWithRemote() {
314+
try {
315+
const { stdout: sha } = await execa('git', ['rev-parse', 'HEAD'])
316+
const { stdout: branch } = await execa('git', [
317+
'rev-parse',
318+
'--abbrev-ref',
319+
'HEAD'
320+
])
321+
const res = await fetch(
322+
`https://api.github.com/repos/vuejs/core/commits/${branch}?per_page=1`
323+
)
324+
const data = await res.json()
325+
return data.sha === sha
326+
} catch (e) {
327+
console.error(
328+
'Failed to check whether local HEAD is up-to-date with remote.'
329+
)
302330
return false
303331
}
304332
}

0 commit comments

Comments
 (0)