Skip to content

Commit dcd1a0a

Browse files
committed
Add comprehensive goreleaser support for multi-platform builds
This change replaces the custom build-all.sh script with a full goreleaser integration that provides: ## What's Added ### Configuration - : Configures builds for macOS and Linux (arm64 and amd64) with proper archiving, checksums, and changelog generation - : Provides convenient commands for common release tasks (build, test, snapshot, clean, etc.) ### Version Management - Removes hardcoded version from main.go (was "2.5.1") - Uses goreleaser's ldflags injection for version from git tags - Fallback to "dev" version when building locally ### CI/CD Integration - Updates : Adds goreleaser snapshot builds on PRs with artifact uploads - Adds : Automates releases when tags are pushed ## Benefits - **Tag-based versioning**: Version is automatically derived from git tags - **Snapshot builds**: Test releases locally or in CI without creating actual releases - **Simplified workflow**: Single command for testing builds - **Better CI feedback**: PR builds now validate the full release process - **Automated releases**: Push a tag, get a GitHub release with all platform binaries ## Migration Notes - The build-all.sh script is now superseded but kept for backward compatibility - Existing release process: Create and push a git tag (e.g., v2.5.2) - For local testing: Run to create test builds in ./dist/ ## Platform Support Currently building for: - macOS (darwin): amd64, arm64 - Linux: amd64, arm64 FreeBSD builds from build-all.sh can be added if needed by extending .goreleaser.yml
1 parent f57a6d0 commit dcd1a0a

9 files changed

Lines changed: 227 additions & 67 deletions

File tree

.github/workflows/build.yml

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
11
name: Build
22

33
on:
4-
- push
5-
- pull_request
4+
push:
5+
branches:
6+
- main
7+
- master
8+
pull_request:
9+
10+
permissions:
11+
contents: read
612

713
jobs:
814
build:
915
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read
1018
strategy:
1119
matrix:
12-
go-version: ["1.18.x", "1.19.x", "1.20.x", "1.21.x"]
20+
go-version:
21+
[
22+
"1.18.x",
23+
"1.19.x",
24+
"1.20.x",
25+
"1.21.x",
26+
"1.22.x",
27+
"1.23.x",
28+
"1.24.x",
29+
"1.25.x",
30+
]
1331
steps:
1432
- name: Checkout
15-
uses: actions/checkout@v3
16-
- uses: actions/setup-go@v3
33+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
with:
35+
fetch-depth: 0
36+
persist-credentials: false
37+
- name: Set up Go
38+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
1739
with:
1840
go-version: ${{ matrix.go-version }}
1941
- name: Cache mods
20-
uses: actions/cache@v3
42+
uses: actions/cache@6f8efc29b200d32929f49075959781ed54ec270c # v3.4.2
2143
with:
2244
path: |
2345
~/.cache/go-build
@@ -27,3 +49,46 @@ jobs:
2749
run: go mod download
2850
- name: Build
2951
run: go build
52+
53+
zizmor:
54+
runs-on: ubuntu-latest
55+
permissions:
56+
contents: read
57+
security-events: write
58+
steps:
59+
- name: Checkout
60+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
61+
with:
62+
persist-credentials: false
63+
- name: Run zizmor
64+
uses: zizmorcore/zizmor-action@e639db99335bc9038abc0e066dfcd72e23d26fb4 # v0.3.0
65+
with:
66+
inputs: .github/workflows/
67+
68+
goreleaser-snapshot:
69+
runs-on: ubuntu-latest
70+
permissions:
71+
contents: read
72+
if: github.event_name == 'pull_request'
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
76+
with:
77+
fetch-depth: 0
78+
persist-credentials: false
79+
- name: Set up Go
80+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
81+
with:
82+
go-version: "1.24.x"
83+
cache: false
84+
- name: Run GoReleaser (snapshot)
85+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
86+
with:
87+
distribution: goreleaser
88+
version: latest
89+
args: release --snapshot --clean
90+
- name: Upload artifacts
91+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
92+
with:
93+
name: dist
94+
path: dist/

.github/workflows/lint.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@ on:
44
- push
55
- pull_request
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
lint:
912
runs-on: ubuntu-latest
13+
permissions:
14+
contents: read
1015
strategy:
1116
matrix:
12-
go-version: ["1.21.x"]
17+
go-version: ["1.24.x"]
1318
steps:
1419
- name: Checkout
15-
uses: actions/checkout@v3
16-
- uses: actions/setup-go@v3
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
21+
with:
22+
persist-credentials: false
23+
- name: Set up Go
24+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
1725
with:
1826
go-version: ${{ matrix.go-version }}
1927
- name: Cache mods
20-
uses: actions/cache@v3
28+
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
2129
with:
2230
path: |
2331
~/.cache/go-build
@@ -26,8 +34,8 @@ jobs:
2634
- name: Download mods
2735
run: go mod download
2836
- name: Lint
29-
uses: golangci/golangci-lint-action@v3
37+
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
3038
with:
31-
version: v1.54.1
39+
version: v2.7.2
3240
args: --timeout 5m0s
3341
skip-cache: true

.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
17+
with:
18+
fetch-depth: 0
19+
persist-credentials: false
20+
- name: Set up Go
21+
uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
22+
with:
23+
go-version: "1.24.x"
24+
cache: false
25+
- name: Run GoReleaser
26+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
27+
with:
28+
distribution: goreleaser
29+
version: latest
30+
args: release --clean
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.golangci.yml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1-
run:
2-
skip-dirs:
3-
- .tmp
4-
- vendor
1+
version: "2"
52

63
linters:
7-
disable-all: true
4+
default: none
85
enable:
9-
# - errcheck
106
- gocritic
117
- goconst
12-
- goimports
13-
- gosimple
148
- govet
159
- ineffassign
1610
- staticcheck
17-
- stylecheck
18-
- typecheck
1911
- unused
12+
disable:
13+
- errcheck
14+
exclusions:
15+
rules:
16+
# Suppress ST1005 - error strings capitalization
17+
- linters: [staticcheck]
18+
text: "error strings should not be capitalized"
19+
settings:
20+
govet:
21+
enable:
22+
- shadow
2023

21-
linters-settings:
22-
govet:
23-
# report about shadowed variables
24-
check-shadowing: true
25-
26-
issues:
27-
exclude-rules:
28-
- linters: [stylecheck]
29-
text: "ST1005:"
24+
formatters:
25+
enable:
26+
- goimports

.goreleaser.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
version: 2
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- env:
9+
- CGO_ENABLED=0
10+
goos:
11+
- linux
12+
- darwin
13+
- freebsd
14+
goarch:
15+
- amd64
16+
- arm64
17+
- arm
18+
- "386"
19+
ignore:
20+
# macOS doesn't support 32-bit architectures
21+
- goos: darwin
22+
goarch: "386"
23+
- goos: darwin
24+
goarch: arm
25+
ldflags:
26+
- -s -w
27+
- -X main.version={{.Version}}
28+
29+
archives:
30+
- name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
31+
files:
32+
- LICENSE*
33+
- README*
34+
- CHANGELOG*
35+
36+
checksum:
37+
name_template: "checksums.txt"
38+
algorithm: sha256
39+
40+
snapshot:
41+
version_template: "{{ incpatch .Version }}-next"
42+
43+
changelog:
44+
sort: asc
45+
filters:
46+
exclude:
47+
- "^docs:"
48+
- "^test:"
49+
- "^chore:"
50+
- "^ci:"
51+
52+
release:
53+
draft: false
54+
prerelease: auto
55+
name_template: "{{.ProjectName}} {{.Version}}"

build-all.sh

Lines changed: 0 additions & 34 deletions
This file was deleted.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ module github.com/DarthSim/overmind/v2
33
go 1.21
44

55
require (
6+
github.com/Envek/godotenv v0.0.0-20240326021258-e36c8a003587
67
github.com/matoous/go-nanoid v1.5.0
78
github.com/sevlyar/go-daemon v0.1.6
89
github.com/urfave/cli v1.22.12
910
golang.org/x/term v0.4.0
1011
)
1112

1213
require (
13-
github.com/Envek/godotenv v0.0.0-20240326021258-e36c8a003587 // indirect
1414
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
1515
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
1616
github.com/russross/blackfriday/v2 v2.1.0 // indirect

justfile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Build a local development version
2+
build:
3+
go build -ldflags "-X main.version=dev" -o overmind .
4+
5+
# Run tests
6+
test:
7+
go test -v ./...
8+
9+
# Run linter
10+
lint:
11+
golangci-lint run --timeout 5m0s
12+
13+
# Build a snapshot release (useful for testing)
14+
snapshot:
15+
goreleaser release --snapshot --clean
16+
17+
# Check if the goreleaser config is valid
18+
check-config:
19+
goreleaser check
20+
21+
# Clean build artifacts
22+
clean:
23+
rm -rf ./dist
24+
rm -f overmind
25+
26+
# Show current version from git tags
27+
version:
28+
@git describe --always --tags --abbrev=0 2>/dev/null || echo "no tags found"
29+
30+
# Install goreleaser (if not already installed)
31+
install-goreleaser:
32+
@which goreleaser > /dev/null || (echo "Installing goreleaser..." && go install github.com/goreleaser/goreleaser/v2@latest)
33+
34+
# Local release (requires goreleaser to be installed)
35+
release: install-goreleaser
36+
goreleaser release --clean

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
"github.com/urfave/cli"
1313
)
1414

15-
const version = "2.5.1"
15+
// version will be set by goreleaser via ldflags
16+
var version = "dev"
1617

1718
func socketFlags(s, n *string) []cli.Flag {
1819
return []cli.Flag{

0 commit comments

Comments
 (0)