Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,23 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: "1.27"
# gh extension install matches release assets by the `{os}-{arch}` suffix,
# e.g. gh-prpush_0.1.0_linux-amd64 or gh-prpush_0.1.0_windows-amd64.exe.
# Binaries are static (CGO_ENABLED=0), so they run on any glibc version.
- name: Cross-compile extension binaries
run: |
set -euo pipefail
mkdir -p dist
version="${GITHUB_REF_NAME}"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w" -o "dist/gh-prpush_${version}_linux_amd64" .
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w" -o "dist/gh-prpush_${version}_darwin_amd64" .
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w" -o "dist/gh-prpush_${version}_darwin_arm64" .
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "-s -w" -o "dist/gh-prpush_${version}_windows_amd64.exe" .
version="${GITHUB_REF_NAME#v}"
for target in linux/amd64 linux/arm64 linux/386 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64; do
os="${target%/*}"
arch="${target#*/}"
ext=""
[ "$os" = "windows" ] && ext=".exe"
CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -trimpath -buildvcs=false -ldflags "-s -w" \
-o "dist/gh-prpush_${version}_${os}-${arch}${ext}" .
done
ls -l dist
- uses: softprops/action-gh-release@v2
with:
files: dist/*
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
(150+ upvotes, still open). Until it ships in `gh` proper, this extension fills the gap:

```
$ gh pr push
$ gh prpush
pushed HEAD to fork (fix-thing)
```

Expand All @@ -26,15 +26,34 @@ That's it. No state, no config file — it asks `gh` and `git` and gets out of t
gh extension install technothatch/gh-prpush
```

Requires the [GitHub CLI](https://cli.github.com/) (`gh`) on your PATH.
Requires the [GitHub CLI](https://cli.github.com/) (`gh`) on your PATH. Prebuilt
static binaries are attached to every release for Linux (amd64/arm64/386),
macOS (amd64/arm64) and Windows (amd64/arm64); `gh` picks the right one
automatically.

If you prefer to build from source:

```bash
git clone https://github.com/technothatch/gh-prpush.git
cd gh-prpush
go build -o gh-prpush . # Windows: go build -o gh-prpush.exe .
gh extension install .
```

## Usage

> **Naming note:** this is a `gh` *extension*, so the command is
> **`gh prpush`** — not `gh pr push`. That's a `gh` limitation: extensions live
> in the `gh <name>` namespace, and the built-in `pr` command can't be extended
> with new subcommands. If/when the feature lands in `gh` itself
> ([cli/cli#2189](https://github.com/cli/cli/issues/2189)), it will be
> `gh pr push`.

```
cd your-repo
gh pr checkout 123 # or whatever workflow you use
# ... commit your changes ...
gh pr push
gh prpush
```

Flags:
Expand Down
7 changes: 4 additions & 3 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ func Run(args []string, stdout, stderr io.Writer, r ...run.Runner) error {
case "--force-with-lease":
force = true
case "-h", "--help":
fmt.Fprint(stdout, `gh pr push - push the head branch of the current pull request
fmt.Fprint(stdout, `gh prpush - push the head branch of the current pull request

Usage:
gh pr push [--force-with-lease]
gh prpush [--force-with-lease]

Pushes the checked-out branch of the PR you are on to the correct remote
(your fork when the PR is cross-repository, origin otherwise).

Implements https://github.com/cli/cli/issues/2189 as an extension.
Note: this is a gh extension, so it runs as 'gh prpush'. The upstream
feature request is https://github.com/cli/cli/issues/2189.
`)
return nil
default:
Expand Down
Loading