Skip to content

Commit 99165ee

Browse files
committed
Add GitHub Actions CI/CD pipeline and release automation
- CI workflow runs tests on push to main and PRs - Release workflow triggers on v* tags: runs tests, builds 4 platform binaries (linux, windows, darwin arm64/amd64) with version injected via ldflags, and publishes a GitHub Release with binaries attached - Makefile gains VERSION variable and darwin build targets - Default version string changed from hardcoded "0.1.0" to "dev" - Add docs/releasing.md documenting the release process
1 parent 78aff35 commit 99165ee

File tree

5 files changed

+107
-5
lines changed

5 files changed

+107
-5
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-go@v5
15+
with:
16+
go-version-file: go.mod
17+
- name: Run tests
18+
run: go test ./...

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- uses: actions/setup-go@v5
18+
with:
19+
go-version-file: go.mod
20+
21+
- name: Run tests
22+
run: go test ./...
23+
24+
- name: Build binaries
25+
run: |
26+
VERSION=${GITHUB_REF_NAME#v}
27+
LDFLAGS="-X 'github.com/yourorg/beads_server/internal/cli.version=${VERSION}'"
28+
mkdir -p build
29+
GOOS=linux GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o build/bs-linux-amd64 ./cmd/bs
30+
GOOS=windows GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o build/bs-windows-amd64.exe ./cmd/bs
31+
GOOS=darwin GOARCH=arm64 go build -ldflags="${LDFLAGS}" -o build/bs-darwin-arm64 ./cmd/bs
32+
GOOS=darwin GOARCH=amd64 go build -ldflags="${LDFLAGS}" -o build/bs-darwin-amd64 ./cmd/bs
33+
34+
- name: Create GitHub Release
35+
uses: softprops/action-gh-release@v2
36+
with:
37+
generate_release_notes: true
38+
files: |
39+
build/bs-linux-amd64
40+
build/bs-windows-amd64.exe
41+
build/bs-darwin-arm64
42+
build/bs-darwin-amd64

Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,29 @@
11
BINARY_NAME := bs
22
BUILD_DIR := build
33
SRC := ./cmd/bs
4+
VERSION ?= dev
5+
LDFLAGS := -X 'github.com/yourorg/beads_server/internal/cli.version=$(VERSION)'
46

5-
.PHONY: all build test clean linux windows
7+
.PHONY: all build test clean linux windows darwin-arm64 darwin-amd64
68

79
all: test build
810

9-
build: linux windows
11+
build: linux windows darwin-arm64 darwin-amd64
1012

1113
test:
1214
go test ./...
1315

1416
linux:
15-
GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 $(SRC)
17+
GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 $(SRC)
1618

1719
windows:
18-
GOOS=windows GOARCH=amd64 go build -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe $(SRC)
20+
GOOS=windows GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-windows-amd64.exe $(SRC)
21+
22+
darwin-arm64:
23+
GOOS=darwin GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 $(SRC)
24+
25+
darwin-amd64:
26+
GOOS=darwin GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-amd64 $(SRC)
1927

2028
clean:
2129
rm -rf $(BUILD_DIR)

docs/releasing.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Releasing
2+
3+
Releases are triggered by pushing a git tag. GitHub Actions handles the rest: it runs tests, cross-compiles binaries for all platforms, and publishes a GitHub Release with the binaries attached.
4+
5+
## How to cut a release
6+
7+
```bash
8+
git tag v0.9.1
9+
git push origin v0.9.1
10+
```
11+
12+
The tag name determines the version string baked into the binaries (`v0.9.1``bs --version` reports `0.9.1`).
13+
14+
## What happens automatically
15+
16+
1. CI runs `go test ./...` — if tests fail, the release is aborted
17+
2. Four binaries are built:
18+
- `bs-linux-amd64`
19+
- `bs-windows-amd64.exe`
20+
- `bs-darwin-arm64` (Apple Silicon)
21+
- `bs-darwin-amd64` (Intel Mac)
22+
3. A GitHub Release named `v0.9.1` is created with all four binaries attached and auto-generated release notes
23+
24+
## Versioning convention
25+
26+
Use [semantic versioning](https://semver.org): `vMAJOR.MINOR.PATCH`
27+
28+
- `PATCH` — bug fixes, no new features (`v0.9.0``v0.9.1`)
29+
- `MINOR` — new features, backwards compatible (`v0.9.1``v0.10.0`)
30+
- `MAJOR` — breaking changes (`v0.x.x``v1.0.0`)
31+
32+
## Non-release commits
33+
34+
Ordinary commits and PRs to `main` run CI (tests only) but do **not** produce a release. Only tagged commits trigger a release build.

internal/cli/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"github.com/spf13/cobra"
55
)
66

7-
var version = "0.1.0"
7+
var version = "dev"
88

99
// NewRootCmd creates the root cobra command for the bs CLI.
1010
func NewRootCmd() *cobra.Command {

0 commit comments

Comments
 (0)