Skip to content

Commit 1604f5a

Browse files
timvwclaude
andcommitted
feat: add release workflow with automated binary builds
Add automated release process that builds binaries for multiple platforms and creates GitHub releases with downloadable artifacts. Changes: - Add release workflow triggered by vX.Y.Z tags - Build matrix for Linux (amd64, arm64), macOS (amd64, arm64), Windows (amd64) - Generate SHA256 checksums for all binaries - Create GitHub release with auto-generated notes - Add version command to CLI (wt version) - Inject version via ldflags during build - Use GitHub App authentication for release creation To create a release: git tag v1.0.0 git push origin v1.0.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 560f9b5 commit 1604f5a

3 files changed

Lines changed: 120 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: Build Binaries
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
include:
18+
- goos: linux
19+
goarch: amd64
20+
output: wt-linux-amd64
21+
- goos: linux
22+
goarch: arm64
23+
output: wt-linux-arm64
24+
- goos: darwin
25+
goarch: amd64
26+
output: wt-darwin-amd64
27+
- goos: darwin
28+
goarch: arm64
29+
output: wt-darwin-arm64
30+
- goos: windows
31+
goarch: amd64
32+
output: wt-windows-amd64.exe
33+
34+
steps:
35+
- name: Generate GitHub App token
36+
id: generate-token
37+
uses: actions/create-github-app-token@v1
38+
with:
39+
app-id: ${{ secrets.BOT_APP_ID }}
40+
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
41+
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
with:
45+
token: ${{ steps.generate-token.outputs.token }}
46+
47+
- name: Set up Go
48+
uses: actions/setup-go@v5
49+
with:
50+
go-version: '1.23'
51+
52+
- name: Build binary
53+
env:
54+
GOOS: ${{ matrix.goos }}
55+
GOARCH: ${{ matrix.goarch }}
56+
run: |
57+
mkdir -p dist
58+
go build -ldflags="-s -w -X main.version=${{ github.ref_name }}" -o dist/${{ matrix.output }} .
59+
60+
- name: Upload artifact
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: ${{ matrix.output }}
64+
path: dist/${{ matrix.output }}
65+
if-no-files-found: error
66+
67+
release:
68+
name: Create Release
69+
needs: build
70+
runs-on: ubuntu-latest
71+
72+
steps:
73+
- name: Generate GitHub App token
74+
id: generate-token
75+
uses: actions/create-github-app-token@v1
76+
with:
77+
app-id: ${{ secrets.BOT_APP_ID }}
78+
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
79+
80+
- name: Checkout code
81+
uses: actions/checkout@v4
82+
with:
83+
token: ${{ steps.generate-token.outputs.token }}
84+
85+
- name: Download all artifacts
86+
uses: actions/download-artifact@v4
87+
with:
88+
path: dist/
89+
merge-multiple: true
90+
91+
- name: Generate checksums
92+
run: |
93+
cd dist
94+
shasum -a 256 * > checksums.txt
95+
cat checksums.txt
96+
97+
- name: Create GitHub Release
98+
env:
99+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
100+
run: |
101+
gh release create ${{ github.ref_name }} \
102+
--title "Release ${{ github.ref_name }}" \
103+
--generate-notes \
104+
dist/*

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ wt prune
7979
# Show shell integration code
8080
wt shellenv
8181

82+
# Show version
83+
wt version
84+
8285
# Show help
8386
wt --help
8487
wt <command> --help

main.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import (
1111
"github.com/spf13/cobra"
1212
)
1313

14-
var worktreeRoot string
14+
var (
15+
version = "dev"
16+
worktreeRoot string
17+
)
1518

1619
func init() {
1720
// Set worktree root from environment or default
@@ -48,6 +51,7 @@ func init() {
4851
rootCmd.AddCommand(removeCmd)
4952
rootCmd.AddCommand(pruneCmd)
5053
rootCmd.AddCommand(shellenvCmd)
54+
rootCmd.AddCommand(versionCmd)
5155
}
5256

5357
// Helper functions
@@ -402,3 +406,11 @@ fi
402406
`)
403407
},
404408
}
409+
410+
var versionCmd = &cobra.Command{
411+
Use: "version",
412+
Short: "Show version information",
413+
Run: func(cmd *cobra.Command, args []string) {
414+
fmt.Printf("wt version %s\n", version)
415+
},
416+
}

0 commit comments

Comments
 (0)