Skip to content

Commit 8c328ce

Browse files
committed
CI release pipeline + install script
1 parent 4a49938 commit 8c328ce

File tree

6 files changed

+194
-13
lines changed

6 files changed

+194
-13
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
23+
- name: Run tests
24+
run: go test ./...
25+
26+
- uses: goreleaser/goreleaser-action@v6
27+
with:
28+
version: "~> v2"
29+
args: release --clean
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Binary
2+
/helpscout
3+
/helpscout.exe
4+
5+
# IDE
6+
.idea/
7+
.vscode/
8+
*.swp
9+
10+
# OS
11+
.DS_Store
12+
Thumbs.db
13+
14+
# Go
15+
/dist/

.goreleaser.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,20 @@ builds:
1717
- arm64
1818

1919
archives:
20-
- format: tar.gz
20+
- formats:
21+
- tar.gz
2122
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
2223
format_overrides:
2324
- goos: windows
24-
format: zip
25+
formats:
26+
- zip
2527

2628
checksum:
2729
name_template: checksums.txt
2830

31+
release:
32+
draft: true
33+
2934
changelog:
3035
sort: asc
3136
filters:

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,21 @@
22

33
A command-line interface for the [HelpScout](https://www.helpscout.com/) API. Manage mailboxes, conversations, customers, tags, users, workflows, and webhooks from the terminal.
44

5-
## Installation
6-
7-
### From source
5+
## Install
86

97
```bash
10-
go install github.com/getpinch/helpscout-cli/cmd/helpscout@latest
11-
```
8+
# One-liner (Linux/macOS)
9+
curl -sSL https://raw.githubusercontent.com/getpinch/helpscout-cli/main/install.sh | bash
1210

13-
### From release binaries
11+
# Custom install directory
12+
curl -sSL https://raw.githubusercontent.com/getpinch/helpscout-cli/main/install.sh | INSTALL_DIR=~/.local/bin bash
1413

15-
Download the latest release for your platform from the [releases page](https://github.com/getpinch/helpscout-cli/releases). Archives are available for Linux, macOS, and Windows on amd64 and arm64.
14+
# Specific version
15+
curl -sSL https://raw.githubusercontent.com/getpinch/helpscout-cli/main/install.sh | HELPSCOUT_VERSION=v0.0.1 bash
16+
17+
# From source (requires Go)
18+
go install github.com/getpinch/helpscout-cli/cmd/helpscout@latest
19+
```
1620

1721
### Build from source
1822

@@ -417,14 +421,13 @@ HELPSCOUT_CLIENT_ID=xxx HELPSCOUT_CLIENT_SECRET=yyy go test -tags integration ./
417421

418422
### Release
419423

420-
Releases are built with [GoReleaser](https://goreleaser.com/):
424+
Releases are automated via GitHub Actions. Push a `v*` tag to trigger a draft release with platform binaries:
421425

422426
```bash
423-
goreleaser release --clean
427+
git tag v0.1.0
428+
git push origin v0.1.0
424429
```
425430

426-
Produces archives for linux/darwin/windows on amd64/arm64.
427-
428431
## License
429432

430433
[MIT](LICENSE)

docs/homebrew-tap.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Homebrew Tap Setup
2+
3+
How to distribute `helpscout` via Homebrew once the project name/org is settled.
4+
5+
## 1. Create the tap repo
6+
7+
Create a **public** repo named `getpinch/homebrew-tap` on GitHub.
8+
9+
The `homebrew-` prefix is a Homebrew convention — users reference it as `getpinch/tap`, and Homebrew automatically looks up `getpinch/homebrew-tap`.
10+
11+
## 2. Create a GitHub token
12+
13+
Goreleaser needs write access to the tap repo to push the formula on each release.
14+
15+
- Create a fine-grained PAT with **Contents: Read and write** scope on the `homebrew-tap` repo
16+
- Add it as a repository secret named `HOMEBREW_TAP_TOKEN` in the `helpscout-cli` repo
17+
18+
## 3. Add `brews` section to `.goreleaser.yml`
19+
20+
```yaml
21+
brews:
22+
- repository:
23+
owner: getpinch
24+
name: homebrew-tap
25+
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
26+
homepage: "https://github.com/getpinch/helpscout-cli"
27+
description: "HelpScout API CLI"
28+
install: |
29+
bin.install "helpscout"
30+
test: |
31+
system "#{bin}/helpscout", "version"
32+
```
33+
34+
## 4. Update the release workflow
35+
36+
Add the token to the goreleaser step environment:
37+
38+
```yaml
39+
- uses: goreleaser/goreleaser-action@v6
40+
with:
41+
version: "~> v2"
42+
args: release --clean
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
46+
```
47+
48+
## 5. How users install
49+
50+
```bash
51+
brew tap getpinch/tap
52+
brew install helpscout
53+
```
54+
55+
Upgrades: `brew upgrade helpscout`
56+
57+
## Notes
58+
59+
- The tap repo must be **public** for users to tap without authentication
60+
- Goreleaser auto-generates and pushes the formula `.rb` file on each release
61+
- The formula points to the GitHub release archive, so users download from there
62+
- If the project moves to a different org, update the `repository.owner` in goreleaser and create a new tap repo under the new org

install.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/sh
2+
set -e
3+
4+
REPO="getpinch/helpscout-cli"
5+
BINARY="helpscout"
6+
INSTALL_DIR="${INSTALL_DIR:-/usr/local/bin}"
7+
8+
# Detect OS
9+
case "$(uname -s)" in
10+
Linux*) OS="linux" ;;
11+
Darwin*) OS="darwin" ;;
12+
*) echo "Unsupported OS: $(uname -s)"; exit 1 ;;
13+
esac
14+
15+
# Detect arch
16+
case "$(uname -m)" in
17+
x86_64|amd64) ARCH="amd64" ;;
18+
arm64|aarch64) ARCH="arm64" ;;
19+
*) echo "Unsupported architecture: $(uname -m)"; exit 1 ;;
20+
esac
21+
22+
# Resolve version
23+
if [ -z "$HELPSCOUT_VERSION" ]; then
24+
HELPSCOUT_VERSION=$(curl -sI "https://github.com/${REPO}/releases/latest" \
25+
| grep -i "^location:" \
26+
| sed 's|.*/tag/||' \
27+
| tr -d '\r\n')
28+
29+
if [ -z "$HELPSCOUT_VERSION" ]; then
30+
echo "Error: could not determine latest version. Set HELPSCOUT_VERSION manually."
31+
exit 1
32+
fi
33+
fi
34+
35+
VERSION_NUM="${HELPSCOUT_VERSION#v}"
36+
ARCHIVE="helpscout-cli_${VERSION_NUM}_${OS}_${ARCH}.tar.gz"
37+
URL="https://github.com/${REPO}/releases/download/${HELPSCOUT_VERSION}/${ARCHIVE}"
38+
CHECKSUMS_URL="https://github.com/${REPO}/releases/download/${HELPSCOUT_VERSION}/checksums.txt"
39+
40+
echo "Installing ${BINARY} ${HELPSCOUT_VERSION} (${OS}/${ARCH})..."
41+
42+
TMPDIR=$(mktemp -d)
43+
trap 'rm -rf "$TMPDIR"' EXIT
44+
45+
# Download archive + checksums
46+
curl -sL "$URL" -o "$TMPDIR/$ARCHIVE"
47+
curl -sL "$CHECKSUMS_URL" -o "$TMPDIR/checksums.txt"
48+
49+
# Verify checksum
50+
cd "$TMPDIR"
51+
if command -v sha256sum >/dev/null 2>&1; then
52+
grep "$ARCHIVE" checksums.txt | sha256sum -c --quiet
53+
elif command -v shasum >/dev/null 2>&1; then
54+
grep "$ARCHIVE" checksums.txt | shasum -a 256 -c --quiet
55+
else
56+
echo "Warning: no sha256sum or shasum found, skipping checksum verification"
57+
fi
58+
59+
# Extract and install
60+
tar xzf "$ARCHIVE" "$BINARY"
61+
install -d "$INSTALL_DIR"
62+
install "$BINARY" "$INSTALL_DIR/$BINARY"
63+
64+
echo "Installed ${BINARY} to ${INSTALL_DIR}/${BINARY}"
65+
"$INSTALL_DIR/$BINARY" version

0 commit comments

Comments
 (0)