Skip to content

Commit

Permalink
feat: add option to skip pushing to remote (#172)
Browse files Browse the repository at this point in the history
Co-authored-by: Dominic Griesel <dominic.griesel@nabucasa.com>
  • Loading branch information
foxriver76 and AlCalzone authored Jul 23, 2024
1 parent 4da181d commit a0c7d17
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Placeholder for the next version (at the beginning of the line):
## **WORK IN PROGRESS**
-->
## **WORK IN PROGRESS**
* `git` plugin: allow to skip push stage via `noPush` option

## 3.7.3 (2024-07-05)
* `package` plugin: Support monorepos managed with Yarn v4

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,14 @@ When this option is set, only the annotated release tag will be pushed to the re
npm run release patch -- --tagOnly
```
#### Do not push to the remote at all (`--noPush`)
When this option is set, nothing will be pushed to the remote. This option can be useful if branch protection rules prevent the release branch from being pushed, and release commits are pushed by other means.
```bash
npm run release patch -- --noPush
```
### `changelog` plugin options
#### Limit the number of entries in README.md (`--numChangelogEntries` or `-n`)
Expand Down
10 changes: 10 additions & 0 deletions packages/plugin-git/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ class GitPlugin implements Plugin {
description: "Only push the annotated tag, not the release commit",
default: false,
},
noPush: {
type: "boolean",
description: "Do not push anything to the remote",
default: false,
},
});
}

Expand Down Expand Up @@ -183,6 +188,11 @@ ${context.getData("changelog_new")}`;
}

private async executePushStage(context: Context): Promise<void> {
if (context.argv.noPush) {
context.cli.log("git push skipped");
return;
}

const upstream =
(context.argv.remote as string | undefined) || (await getUpstream(context));
const [remote, branch] = upstream.split("/", 2);
Expand Down
4 changes: 4 additions & 0 deletions packages/release-script/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ class CLI implements ICLI {
this.log(`$ ${command}`);
}
clearLines(lines: number): void {
if (!process.stdout.isTTY) {
return;
}

process.stdout.moveCursor(0, -lines);
process.stdout.clearScreenDown();
}
Expand Down

0 comments on commit a0c7d17

Please sign in to comment.