Skip to content

Commit dcfa146

Browse files
authored
goreleaser 2.0 (#45)
1 parent bbc8983 commit dcfa146

File tree

3 files changed

+211
-3
lines changed

3 files changed

+211
-3
lines changed

.github/workflows/release.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
- uses: actions/setup-go@v4
19+
with:
20+
go-version: "1.24.x"
21+
cache-dependency-path: go.sum
22+
- uses: goreleaser/goreleaser-action@v6
23+
with:
24+
distribution: goreleaser
25+
version: "~> v2"
26+
args: release --clean
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
77
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
88

9-
version: 1
9+
version: 2
1010

1111
before:
1212
hooks:
@@ -25,7 +25,7 @@ builds:
2525
- darwin
2626

2727
archives:
28-
- format: tar.gz
28+
- formats: [tar.gz]
2929
# this name template makes the OS and Arch compatible with the results of `uname`.
3030
name_template: >-
3131
{{ .ProjectName }}_
@@ -37,7 +37,7 @@ archives:
3737
# use zip for windows archives
3838
format_overrides:
3939
- goos: windows
40-
format: zip
40+
formats: [zip]
4141

4242
changelog:
4343
sort: asc

RELEASE.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Release Process
2+
3+
This document describes how to create a new release for the Hype project using GoReleaser.
4+
5+
## Prerequisites
6+
7+
### 1. Install GoReleaser
8+
9+
```bash
10+
# Install via Homebrew (recommended on macOS)
11+
brew install goreleaser
12+
13+
# Or install via Go
14+
go install github.com/goreleaser/goreleaser/v2@latest
15+
```
16+
17+
### 2. GitHub Token Setup
18+
19+
You need a GitHub Personal Access Token with appropriate permissions:
20+
21+
1. Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
22+
2. Create a token with `repo` scope (for private repos) or `public_repo` scope (for public repos)
23+
3. Export it locally:
24+
25+
```bash
26+
export GITHUB_TOKEN=your_token_here
27+
```
28+
29+
Tip: Add this to your `~/.zshrc` or `~/.bashrc` for persistence:
30+
31+
```bash
32+
echo 'export GITHUB_TOKEN=your_token_here' >> ~/.zshrc
33+
```
34+
35+
## Release Methods
36+
37+
### Method 1: Manual Release (Current Process)
38+
39+
Use this method for immediate releases or if you prefer manual control:
40+
41+
1. **Ensure you're on main branch and up to date:**
42+
43+
```bash
44+
git checkout main
45+
git pull origin main
46+
```
47+
48+
2. **Verify all changes are committed:**
49+
50+
```bash
51+
git status
52+
# Should show "nothing to commit, working tree clean"
53+
```
54+
55+
3. **Create and push the tag:**
56+
57+
```bash
58+
# Replace v0.3.2 with your desired version
59+
git tag v0.3.2
60+
git push origin v0.3.2
61+
```
62+
63+
4. **Run GoReleaser:**
64+
65+
```bash
66+
goreleaser release --clean
67+
```
68+
69+
### Method 2: Automated Release (Recommended for Future)
70+
71+
If you want automated releases via GitHub Actions:
72+
73+
1. **One-time setup - Commit the release workflow:**
74+
75+
```bash
76+
git add .github/workflows/release.yml
77+
git commit -m "Add automated release workflow"
78+
git push origin main
79+
```
80+
81+
2. **For future releases, simply push a tag:**
82+
83+
```bash
84+
# Replace v0.3.3 with your desired version
85+
git tag v0.3.3
86+
git push origin v0.3.3
87+
```
88+
89+
The GitHub Action will automatically run GoReleaser and create the release.
90+
91+
## What Gets Created
92+
93+
After a successful release, you'll have:
94+
95+
- A new release at `https://github.com/gopherguides/hype/releases/tag/v{version}`
96+
- Binaries for:
97+
- Linux (x86_64, ARM64)
98+
- Windows (x86_64)
99+
- macOS (x86_64, ARM64)
100+
- Automatically generated changelog
101+
- Downloadable archives for each platform (tar.gz for Unix, zip for Windows)
102+
103+
## Version Numbering
104+
105+
Follow semantic versioning (semver):
106+
107+
- `v1.0.0` - Major version (breaking changes)
108+
- `v0.1.0` - Minor version (new features, backwards compatible)
109+
- `v0.0.1` - Patch version (bug fixes, backwards compatible)
110+
111+
## Current Release Configuration
112+
113+
The release is configured via `.goreleaser.yaml`:
114+
115+
- Main binary: `./cmd/hype/main.go`
116+
- Builds for: Linux, Windows, macOS
117+
- Archives: tar.gz (Unix), zip (Windows)
118+
- Hooks: `go mod tidy` and `go generate ./...` before build
119+
120+
## Troubleshooting
121+
122+
### GoReleaser Command Not Found
123+
124+
```bash
125+
# Reinstall GoReleaser
126+
brew install goreleaser
127+
# Or
128+
go install github.com/goreleaser/goreleaser/v2@latest
129+
```
130+
131+
### Invalid GitHub Token
132+
133+
```bash
134+
# Verify token is set
135+
echo $GITHUB_TOKEN
136+
# If empty, export it again
137+
export GITHUB_TOKEN=your_token_here
138+
```
139+
140+
### Tag Already Exists
141+
142+
```bash
143+
# Delete local tag
144+
git tag -d v0.3.2
145+
# Delete remote tag
146+
git push origin --delete v0.3.2
147+
# Recreate tag
148+
git tag v0.3.2
149+
git push origin v0.3.2
150+
```
151+
152+
### Build Failures
153+
154+
```bash
155+
# Test the build locally first
156+
goreleaser build --snapshot --clean
157+
```
158+
159+
### Permission Denied
160+
161+
Ensure your GitHub token has the correct permissions:
162+
163+
- `public_repo` for public repositories
164+
- `repo` for private repositories
165+
166+
## Quick Reference
167+
168+
```bash
169+
# Complete release process (manual)
170+
git checkout main && git pull origin main
171+
git tag v0.3.2
172+
git push origin v0.3.2
173+
goreleaser release --clean
174+
175+
# Complete release process (automated, after workflow is set up)
176+
git checkout main && git pull origin main
177+
git tag v0.3.2
178+
git push origin v0.3.2
179+
# GitHub Actions handles the rest
180+
```

0 commit comments

Comments
 (0)