Skip to content

Commit 986a4d3

Browse files
authored
feat: Adds GoReleaser (#1)
* feat: Adds Goreleaser
1 parent ed07a8e commit 986a4d3

File tree

6 files changed

+350
-1
lines changed

6 files changed

+350
-1
lines changed

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version: '>=1.21.0'
24+
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@v5
27+
with:
28+
distribution: goreleaser
29+
version: latest
30+
args: release --clean
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
34+
- name: Update Homebrew tap
35+
if: success()
36+
uses: dawidd6/action-homebrew-bump-formula@v3
37+
with:
38+
token: ${{ secrets.GITHUB_TOKEN }}
39+
tap: scalvert/homebrew-tap
40+
formula: glean-cli
41+
tag: ${{ github.ref_name }}

.goreleaser.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
before:
2+
hooks:
3+
- go mod tidy
4+
5+
builds:
6+
- env:
7+
- CGO_ENABLED=0
8+
goos:
9+
- linux
10+
- windows
11+
- darwin
12+
goarch:
13+
- amd64
14+
- arm64
15+
ldflags:
16+
- -s -w -X main.version={{.Version}}
17+
18+
archives:
19+
- format: tar.gz
20+
name_template: >-
21+
{{ .ProjectName }}_
22+
{{- title .Os }}_
23+
{{- if eq .Arch "amd64" }}x86_64
24+
{{- else }}{{ .Arch }}{{ end }}
25+
format_overrides:
26+
- goos: windows
27+
format: zip
28+
29+
brews:
30+
- repository:
31+
owner: scalvert
32+
name: homebrew-tap
33+
homepage: "https://github.com/scalvert/glean-cli"
34+
description: "A command-line interface for Glean operations"
35+
license: "MIT"
36+
install: |
37+
bin.install "glean"
38+
39+
checksum:
40+
name_template: 'checksums.txt'
41+
42+
changelog:
43+
sort: asc
44+
filters:
45+
exclude:
46+
- '^docs:'
47+
- '^test:'
48+
- '^ci:'
49+
- Merge pull request
50+
- Merge branch

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,30 @@ A command-line interface for interacting with Glean's API and services. This CLI
66

77
## Installation
88

9+
You can install the Glean CLI in several ways:
10+
11+
### Using Homebrew (macOS and Linux)
12+
13+
```bash
14+
brew install scalvert/tap/glean-cli
15+
```
16+
17+
### Using Go
18+
919
```bash
1020
go install github.com/scalvert/glean-cli@latest
1121
```
1222

23+
### Using Shell Script (macOS and Linux)
24+
25+
```bash
26+
curl -fsSL https://raw.githubusercontent.com/scalvert/glean-cli/main/install.sh | sh
27+
```
28+
29+
### Manual Installation
30+
31+
You can also download the latest binary for your platform from the [releases page](https://github.com/scalvert/glean-cli/releases).
32+
1333
## Usage
1434

1535
```bash

RELEASE.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Release Process
2+
3+
This document outlines the process for creating new releases of the Glean CLI.
4+
5+
## Versioning
6+
7+
We follow [Semantic Versioning](https://semver.org/) (SemVer):
8+
- MAJOR version (X.0.0) - incompatible API changes
9+
- MINOR version (0.X.0) - add functionality in a backward compatible manner
10+
- PATCH version (0.0.X) - backward compatible bug fixes
11+
12+
## Prerequisites
13+
14+
Install the required tools:
15+
```bash
16+
# Install svu for automated versioning
17+
go install github.com/caarlos0/svu@latest
18+
```
19+
20+
## Release Steps
21+
22+
You can create a new release using either the automated task or the manual steps below.
23+
24+
### Automated Release
25+
26+
```bash
27+
# This will run all checks, create and push the tag
28+
task release
29+
```
30+
31+
### Manual Steps
32+
33+
If you need more control over the release process, you can follow these steps manually:
34+
35+
1. **Ensure Main Branch is Ready**
36+
```bash
37+
git checkout main
38+
git pull origin main
39+
```
40+
41+
2. **Run Tests and Checks**
42+
```bash
43+
task test
44+
task lint
45+
```
46+
47+
3. **Create Release**
48+
```bash
49+
# Preview the next version based on conventional commits
50+
svu next
51+
52+
# Create and push the tag with the next version
53+
git tag -a $(svu next) -m "Release $(svu next)"
54+
git push origin $(svu next)
55+
```
56+
57+
Note: `svu` automatically determines the next version based on your commit messages:
58+
- `feat:` -> MINOR version bump
59+
- `fix:` -> PATCH version bump
60+
- `BREAKING CHANGE:` in commit body -> MAJOR version bump
61+
62+
4. **Monitor Release Process**
63+
- The GitHub Action will automatically:
64+
- Create a GitHub release
65+
- Build binaries for all supported platforms
66+
- Generate release notes from commits
67+
- Upload artifacts to the release
68+
- Update the Homebrew formula
69+
70+
5. **Verify Release**
71+
- Check the [GitHub releases page](https://github.com/scalvert/glean-cli/releases)
72+
- Verify Homebrew formula was updated
73+
- Test installation methods:
74+
```bash
75+
# Homebrew
76+
brew update
77+
brew install scalvert/tap/glean-cli
78+
79+
# Go Install
80+
go install github.com/scalvert/glean-cli@latest
81+
82+
# Shell Script
83+
curl -fsSL https://raw.githubusercontent.com/scalvert/glean-cli/main/install.sh | sh
84+
```
85+
86+
## Release Artifacts
87+
88+
Each release includes:
89+
- Binary distributions for:
90+
- macOS (x86_64, arm64)
91+
- Linux (x86_64, arm64)
92+
- Windows (x86_64, arm64)
93+
- Source code (zip, tar.gz)
94+
- Checksums file
95+
- Changelog
96+
97+
## Commit Convention
98+
99+
To make the most of automated versioning, follow these commit message conventions:
100+
101+
```
102+
<type>: <description>
103+
104+
[optional body]
105+
106+
[optional footer(s)]
107+
```
108+
109+
Types:
110+
- `feat:` - New feature (MINOR version bump)
111+
- `fix:` - Bug fix (PATCH version bump)
112+
- `docs:` - Documentation only changes
113+
- `style:` - Changes that do not affect the meaning of the code
114+
- `refactor:` - Code change that neither fixes a bug nor adds a feature
115+
- `perf:` - Code change that improves performance
116+
- `test:` - Adding missing tests or correcting existing tests
117+
- `chore:` - Changes to the build process or auxiliary tools
118+
119+
Breaking Changes:
120+
- Add `BREAKING CHANGE:` to the commit body to trigger a MAJOR version bump
121+
- Example:
122+
```
123+
feat: change API endpoint structure
124+
125+
BREAKING CHANGE: The API endpoint structure has changed from /v1/* to /api/v1/*
126+
```
127+
128+
## Troubleshooting
129+
130+
1. **GitHub Action Failed**
131+
- Check the Action logs for errors
132+
- Ensure GITHUB_TOKEN has required permissions
133+
- Verify the tag follows the format `v*` (e.g., v1.0.0)
134+
135+
2. **Homebrew Update Failed**
136+
- Check if homebrew-tap repository exists
137+
- Verify repository permissions
138+
- Check the "Update Homebrew tap" step in the Action logs
139+
140+
3. **Bad Release**
141+
If a release has issues:
142+
```bash
143+
# Get current version
144+
current_version=$(svu current)
145+
146+
# Delete tag locally
147+
git tag -d $current_version
148+
149+
# Delete tag remotely
150+
git push --delete origin $current_version
151+
```
152+
Then fix the issues and retry the release process.
153+
154+
## Notes
155+
156+
- Release notes are automatically generated from commit messages
157+
- Commits starting with `docs:`, `test:`, `ci:` are excluded from release notes
158+
- The release process is automated via GitHub Actions
159+
- Binary distributions are built using GoReleaser
160+
- All releases are automatically published to GitHub Releases

install.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
set -e
3+
4+
# Glean CLI Installer
5+
#
6+
# Usage:
7+
# curl -fsSL https://raw.githubusercontent.com/scalvert/glean-cli/main/install.sh | sh
8+
9+
LATEST_VERSION=$(curl -s https://api.github.com/repos/scalvert/glean-cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
10+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
11+
ARCH=$(uname -m)
12+
13+
# Convert architecture names
14+
case "$ARCH" in
15+
x86_64) ARCH="x86_64" ;;
16+
amd64) ARCH="x86_64" ;;
17+
arm64) ARCH="arm64" ;;
18+
aarch64) ARCH="arm64" ;;
19+
*) echo "Unsupported architecture: $ARCH"; exit 1 ;;
20+
esac
21+
22+
# Construct download URL
23+
DOWNLOAD_URL="https://github.com/scalvert/glean-cli/releases/download/${LATEST_VERSION}/glean-cli_${OS}_${ARCH}.tar.gz"
24+
25+
# Create temporary directory
26+
TMP_DIR=$(mktemp -d)
27+
cleanup() {
28+
rm -rf "$TMP_DIR"
29+
}
30+
trap cleanup EXIT
31+
32+
# Download and extract
33+
echo "Downloading Glean CLI ${LATEST_VERSION}..."
34+
curl -fsSL "$DOWNLOAD_URL" -o "$TMP_DIR/glean.tar.gz"
35+
tar -xzf "$TMP_DIR/glean.tar.gz" -C "$TMP_DIR"
36+
37+
# Install binary
38+
INSTALL_DIR="/usr/local/bin"
39+
if [ ! -w "$INSTALL_DIR" ]; then
40+
echo "Installing Glean CLI requires sudo access to $INSTALL_DIR"
41+
sudo mv "$TMP_DIR/glean" "$INSTALL_DIR/"
42+
sudo chmod +x "$INSTALL_DIR/glean"
43+
else
44+
mv "$TMP_DIR/glean" "$INSTALL_DIR/"
45+
chmod +x "$INSTALL_DIR/glean"
46+
fi
47+
48+
echo "Glean CLI has been installed to $INSTALL_DIR/glean"
49+
echo "Run 'glean --help' to get started"

taskfile.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,37 @@ tasks:
3636
cmds:
3737
- golangci-lint run --fix
3838

39-
4039
install:
4140
desc: Install the CLI locally
4241
cmds:
4342
- go install
43+
44+
release:
45+
desc: Create and push a new release
46+
cmds:
47+
# Ensure we're on main and up to date
48+
- git checkout main
49+
- git pull origin main
50+
51+
# Run checks
52+
- task: check
53+
54+
# Get the next version
55+
- echo "Next version will be $(svu next)"
56+
- echo "Press Ctrl+C to cancel or wait 5 seconds to continue..."
57+
- sleep 5
58+
59+
# Create and push the tag
60+
- |
61+
version=$(svu next)
62+
git tag -a $version -m "Release $version"
63+
git push origin $version
64+
65+
# Instructions for monitoring
66+
- echo "Release process started!"
67+
- echo "Monitor the release at https://github.com/scalvert/glean-cli/actions"
68+
preconditions:
69+
- sh: "git diff-index --quiet HEAD"
70+
msg: "Working directory is not clean. Please commit or stash changes first."
71+
- sh: "command -v svu"
72+
msg: "svu is not installed. Run: go install github.com/caarlos0/svu@latest"

0 commit comments

Comments
 (0)