Skip to content

Commit 9161c87

Browse files
imran110219claude
andcommitted
feat: add binary distribution system with GoReleaser
This commit implements automated binary releases and a rewritten installer that downloads pre-built binaries, removing the need for go and git on target systems. Changes: - Add .goreleaser.yml for building Linux amd64/arm64 binaries - Add GitHub Actions workflow for automated releases on version tags - Completely rewrite install.sh to download from GitHub Releases - Implement 'stackctl version' command with build info injection - Add comprehensive release and testing documentation - Update .gitignore to exclude build artifacts The new installer: - Detects OS/arch automatically - Downloads pre-built binaries (no compilation needed) - Supports version selection (latest or specific) - No longer requires go, git, or external template files - Provides better UX with colored output and progress indicators Documentation added: - docs/RELEASE.md: Complete release process guide - docs/INSTALL_TESTING.md: Testing procedures and checklist This completes Priority 1 Tasks 3 & 4 from the roadmap. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6b78efd commit 9161c87

10 files changed

Lines changed: 939 additions & 81 deletions

File tree

.github/workflows/release.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
name: Build and Release
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Fetch all tags
23+
run: git fetch --force --tags
24+
25+
- name: Set up Go
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version: '1.24.2'
29+
cache: true
30+
31+
- name: Verify embedded templates
32+
run: |
33+
echo "Checking that templates are embedded..."
34+
if [ ! -f templates_embed.go ]; then
35+
echo "Error: templates_embed.go not found"
36+
exit 1
37+
fi
38+
grep -q "go:embed all:templates" templates_embed.go || {
39+
echo "Error: go:embed directive not found in templates_embed.go"
40+
exit 1
41+
}
42+
echo "Templates are properly embedded"
43+
44+
- name: Run tests
45+
run: go test -v ./...
46+
continue-on-error: true
47+
48+
- name: Set repository env vars
49+
run: |
50+
echo "GITHUB_REPOSITORY_OWNER=${GITHUB_REPOSITORY_OWNER}" >> $GITHUB_ENV
51+
echo "GITHUB_REPOSITORY_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
52+
53+
- name: Run GoReleaser
54+
uses: goreleaser/goreleaser-action@v6
55+
with:
56+
distribution: goreleaser
57+
version: '~> v2'
58+
args: release --clean
59+
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }}
62+
GITHUB_REPOSITORY_NAME: ${{ github.event.repository.name }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
*.log
33
*.tmp
44
.DS_Store
5+
6+
# Build artifacts
7+
stackctl
8+
dist/

.goreleaser.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# GoReleaser configuration for stackctl
2+
# Docs: https://goreleaser.com
3+
4+
version: 2
5+
6+
# Build configuration
7+
builds:
8+
- id: stackctl
9+
main: ./cmd/stackctl
10+
binary: stackctl
11+
12+
# Target platforms
13+
goos:
14+
- linux
15+
16+
goarch:
17+
- amd64
18+
- arm64
19+
20+
# Build flags
21+
env:
22+
- CGO_ENABLED=0
23+
24+
flags:
25+
- -trimpath
26+
27+
ldflags:
28+
- -s -w
29+
- -X main.version={{.Version}}
30+
- -X main.commit={{.Commit}}
31+
- -X main.date={{.Date}}
32+
- -X main.builtBy=goreleaser
33+
34+
# Ensure templates are embedded
35+
hooks:
36+
pre:
37+
- go mod tidy
38+
- go mod download
39+
40+
# Archive configuration
41+
archives:
42+
- id: default
43+
format: tar.gz
44+
name_template: >-
45+
{{ .ProjectName }}_
46+
{{- .Version }}_
47+
{{- .Os }}_
48+
{{- .Arch }}
49+
50+
files:
51+
- LICENSE
52+
- README.md
53+
- USER_GUIDE.md
54+
- docs/**/*
55+
56+
# Use zip for Windows if we add it later
57+
format_overrides:
58+
- goos: windows
59+
format: zip
60+
61+
# Checksum configuration
62+
checksum:
63+
name_template: 'checksums.txt'
64+
algorithm: sha256
65+
66+
# Changelog configuration
67+
changelog:
68+
use: github
69+
sort: asc
70+
71+
filters:
72+
exclude:
73+
- '^docs:'
74+
- '^test:'
75+
- '^chore:'
76+
- '^ci:'
77+
- 'typo'
78+
79+
groups:
80+
- title: Features
81+
regexp: '^.*?feat(\([[:word:]]+\))??!?:.+$'
82+
order: 0
83+
- title: Bug Fixes
84+
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
85+
order: 1
86+
- title: Performance
87+
regexp: '^.*?perf(\([[:word:]]+\))??!?:.+$'
88+
order: 2
89+
- title: Refactors
90+
regexp: '^.*?refactor(\([[:word:]]+\))??!?:.+$'
91+
order: 3
92+
- title: Others
93+
order: 999
94+
95+
# GitHub Release configuration
96+
release:
97+
github:
98+
owner: "{{ .Env.GITHUB_REPOSITORY_OWNER }}"
99+
name: "{{ .Env.GITHUB_REPOSITORY_NAME }}"
100+
101+
draft: false
102+
prerelease: auto
103+
mode: append
104+
105+
header: |
106+
## stackctl {{ .Tag }}
107+
108+
**Installation:**
109+
```bash
110+
curl -fsSL https://raw.githubusercontent.com/{{ .Env.GITHUB_REPOSITORY_OWNER }}/{{ .Env.GITHUB_REPOSITORY_NAME }}/main/install.sh | bash
111+
```
112+
113+
Or download a binary directly from the assets below.
114+
115+
footer: |
116+
## Verification
117+
118+
Verify checksums:
119+
```bash
120+
sha256sum -c checksums.txt
121+
```
122+
123+
---
124+
125+
**Full Changelog**: https://github.com/{{ .Env.GITHUB_REPOSITORY_OWNER }}/{{ .Env.GITHUB_REPOSITORY_NAME }}/compare/{{ .PreviousTag }}...{{ .Tag }}
126+
127+
# Announcement configuration (optional)
128+
announce:
129+
skip: true
130+
131+
# Metadata
132+
metadata:
133+
mod_timestamp: '{{ .CommitTimestamp }}'

cmd/stackctl/main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,24 @@ import (
99
"github.com/example/stackctl/internal/tui"
1010
)
1111

12+
// Build information injected by GoReleaser at build time
13+
var (
14+
version = "dev"
15+
commit = "none"
16+
date = "unknown"
17+
builtBy = "manual"
18+
)
19+
1220
func main() {
1321
// Initialize stackctl with embedded templates
1422
stackctl.InitTemplates(stackctlpkg.EmbeddedTemplates)
1523

24+
// Set version information
25+
stackctl.Version = version
26+
stackctl.Commit = commit
27+
stackctl.Date = date
28+
stackctl.BuiltBy = builtBy
29+
1630
args := os.Args[1:]
1731

1832
if len(args) > 0 {

0 commit comments

Comments
 (0)