release: Reset Git repo on error

pull/4792/head
Richard Hansen 2021-02-15 17:19:17 -05:00 committed by John McLear
parent ba32f71f30
commit 899f2e02f3
1 changed files with 60 additions and 36 deletions

View File

@ -114,6 +114,7 @@ if (!changelog.startsWith(`# ${newVersion}\n`)) {
// ////////////////////////////////////////////////////////////////////////////////////////////////
// Done with sanity checks, now it's time to make changes.
try {
console.log('Updating develop branch...');
run('git pull --ff-only');
@ -147,7 +148,22 @@ console.log('Switching back to develop...');
run('git checkout develop');
console.log('Merging master into develop...');
run('git merge --no-ff --no-edit master');
} catch (err) {
console.error(err.toString());
console.warn('Resetting repository...');
console.warn('Resetting master...');
run('git checkout -f master');
run('git reset --hard @{u}');
console.warn('Resetting develop...');
run('git checkout -f develop');
run('git reset --hard @{u}');
console.warn(`Deleting ${newVersion} tag...`);
run(`git rev-parse -q --verify refs/tags/'${newVersion}' >/dev/null || exit 0; ` +
`git tag -d '${newVersion}'`);
throw err;
}
try {
console.log('Building documentation...');
run('make docs');
console.log('Updating ether.github.com master branch...');
@ -156,6 +172,14 @@ console.log('Committing documentation...');
run(`cp -R out/doc/ ../ether.github.com/doc/v'${newVersion}'`);
run('git add .', {cwd: '../ether.github.com/'});
run(`git commit -m '${newVersion} docs'`, {cwd: '../ether.github.com/'});
} catch (err) {
console.error(err.toString());
console.warn('Resetting repository...');
console.warn('Resetting master...');
run('git checkout -f master', {cwd: '../ether.github.com/'});
run('git reset --hard @{u}', {cwd: '../ether.github.com/'});
throw err;
}
console.log('Done.');
console.log('Review the new commits and the new tag:');