Skip to content

Commit

Permalink
build: fix release scripts (NG-ZORRO#3840)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsuanxyz authored and Wendell committed Jul 22, 2019
1 parent 146de58 commit 0b27681
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
6 changes: 3 additions & 3 deletions scripts/release/git-client.ts
Expand Up @@ -27,8 +27,8 @@ export class GitClient {
return this.spawnGitProcess(['checkout', '-b', branchName]).status === 0;
}

pushBranchToRemote(branchName: string, remoteName: string = this.remoteGitUrl): boolean {
return this.spawnGitProcess(['push', remoteName, branchName]).status === 0;
pushBranchToRemote(branchName: string, force: boolean = false, remoteName: string = this.remoteGitUrl): boolean {
return this.spawnGitProcess(['push', remoteName, branchName, `${force && '-f'}`]).status === 0;
}

}
2 changes: 1 addition & 1 deletion scripts/release/release-site.ts
Expand Up @@ -31,7 +31,7 @@ export function releaseSite(version: string): boolean {

git.stageAllChanges();
git.createNewCommit(`release: ${version}`);
const pushed = git.pushBranchToRemote(branchName);
const pushed = git.pushBranchToRemote(branchName, true);
removeSync(docDir);
return pushed;
}
17 changes: 10 additions & 7 deletions scripts/release/release.ts
Expand Up @@ -13,7 +13,10 @@ const print = console.log;
const log = {
info: (msg: string) => print(chalk.bgBlue.black(' INFO\t'), chalk.blue(msg)),
warn: (msg: string) => print(chalk.bgYellow.black(' WARN\t'), chalk.yellow(msg)),
error: (msg: string) => print(chalk.bgRed.black(' ERROR\t'), chalk.red(msg)),
error: (msg: string) => {
print(chalk.bgRed.black(' ERROR\t'), chalk.red(msg));
process.exit(1);
},
success: (msg: string) => print(chalk.bgGreen.black(' SUCCESS\t'), chalk.green(msg))
};

Expand All @@ -22,11 +25,6 @@ const log = {
run();

function run(): void {
if (hasUncommittedChanges()) {
log.error('Current working tree has changes which are not committed. ' +
'Please make sure your working tree is clean.');
return;
}
const stages = [
{
name: 'Fetch upstream',
Expand Down Expand Up @@ -131,14 +129,19 @@ function bumpVersion(): void {
}

function fetchUpstream(): void {
if (hasUncommittedChanges()) {
log.error('Current working tree has changes which are not committed. ' +
'Please make sure your working tree is clean.');
return;
}
log.info('Fetching upstream...');
const remoteName = getUpstreamRemoteName();
if (!remoteName) {
log.error('The valid remote name does not exist. View detail https://help.github.com/en/articles/configuring-a-remote-for-a-fork');
return;
}
execSync('git checkout master');
execSync(`git pull ${remoteName} master`);
execSync(`git pull ${remoteName} master -f`);
execSync(`git fetch ${remoteName} master --prune --tags`);
log.success('Older versions fetched!');
}
Expand Down

0 comments on commit 0b27681

Please sign in to comment.