Skip to content

Commit 109cac2

Browse files
committed
feat: tag-driven release — version injected via ldflags, no more manual bumps
1 parent e9b048d commit 109cac2

5 files changed

Lines changed: 44 additions & 19 deletions

File tree

.github/workflows/release.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,24 @@ jobs:
3333
with:
3434
go-version: '1.22'
3535

36+
- name: Get version from tag
37+
id: version
38+
run: |
39+
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
40+
VERSION="${{ github.event.inputs.version }}"
41+
else
42+
VERSION="${GITHUB_REF#refs/tags/}"
43+
fi
44+
# Strip 'v' prefix for the version string
45+
echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
46+
3647
- name: Build
3748
env:
3849
GOOS: ${{ matrix.os }}
3950
GOARCH: ${{ matrix.arch }}
4051
CGO_ENABLED: '0'
4152
run: |
42-
go build -ldflags="-s -w" -trimpath -o openboot-${{ matrix.os }}-${{ matrix.arch }} ./cmd/openboot
53+
go build -ldflags="-s -w -X github.com/openbootdotdev/openboot/internal/cli.version=${{ steps.version.outputs.version }}" -trimpath -o openboot-${{ matrix.os }}-${{ matrix.arch }} ./cmd/openboot
4354
4455
- name: Install UPX
4556
run: |

AGENTS.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ cli (root)
7878
- **Testing**: Table-driven with testify/assert. Build tags for integration/e2e
7979
- **Concurrency**: `sync.WaitGroup` with bounded workers (max 4 for brew)
8080
- **Dry-run**: All destructive operations check `cfg.DryRun` first
81-
- **Version string**: Hardcoded in `internal/cli/root.go`bump manually before release
81+
- **Version string**: Default `"dev"` in `internal/cli/root.go`injected via ldflags at build time, never edit manually
8282
- **Config storage**: `~/.openboot/` directory for auth, state, snapshots
8383

8484
## ANTI-PATTERNS
@@ -93,24 +93,32 @@ cli (root)
9393
## COMMANDS
9494

9595
```bash
96-
make build # go build -o openboot ./cmd/openboot
97-
make build-release # Optimized: -ldflags="-s -w" -trimpath + UPX
98-
make test-unit # go test -v ./...
99-
make test-integration # go test -v -tags=integration ./...
100-
make test-e2e # go test -v -tags=e2e -short ./...
101-
make test-all # All above + coverage
102-
make clean # Remove binaries + coverage
103-
go vet ./... # Lint check
96+
make build # Dev build (version=dev)
97+
make build VERSION=0.19.0 # Build with specific version
98+
make build-release VERSION=0.19.0 # Optimized + UPX with version
99+
make test-unit # go test -v ./...
100+
make test-integration # go test -v -tags=integration ./...
101+
make test-e2e # go test -v -tags=e2e -short ./...
102+
make test-all # All above + coverage
103+
make clean # Remove binaries + coverage
104+
go vet ./... # Lint check
104105
```
105106

106107
## RELEASE PROCESS
107108

108-
1. Bump version in `internal/cli/root.go`
109-
2. `git commit && git push`
110-
3. Build: `GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o openboot-darwin-arm64 ./cmd/openboot`
111-
4. `gh release create vX.Y.Z openboot-darwin-arm64 openboot-darwin-amd64 checksums.txt`
109+
Tag-driven. CI handles everything. **Never edit root.go for version bumps.**
112110

113-
CI auto-releases on `v*` tags via `.github/workflows/release.yml`.
111+
```bash
112+
git tag v0.19.0
113+
git push --tags
114+
# CI builds binaries with version injected via ldflags, creates GitHub release
115+
```
116+
117+
- Version is `"dev"` in source — overridden by `-ldflags -X` at build time
118+
- Dev builds (`version=dev`) skip auto-update
119+
- CI workflow: `.github/workflows/release.yml` extracts version from git tag
120+
121+
**When to release**: Only for user-facing changes (features, bug fixes, package updates). Skip for docs, AGENTS.md, CI config, test-only changes.
114122

115123
## NOTES
116124

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
BINARY_NAME=openboot
44
BINARY_PATH=./$(BINARY_NAME)
5+
VERSION ?= dev
6+
LDFLAGS=-X github.com/openbootdotdev/openboot/internal/cli.version=$(VERSION)
57
COVERAGE_FILE=coverage.out
68
COVERAGE_HTML=coverage.html
79

@@ -27,11 +29,11 @@ test-all:
2729
$(MAKE) test-coverage
2830

2931
build:
30-
go build -o $(BINARY_PATH) ./cmd/openboot
32+
go build -ldflags="$(LDFLAGS)" -o $(BINARY_PATH) ./cmd/openboot
3133

3234
build-release:
33-
@echo "Building optimized release binary..."
34-
go build -ldflags="-s -w" -trimpath -o $(BINARY_PATH) ./cmd/openboot
35+
@echo "Building optimized release binary (version=$(VERSION))..."
36+
go build -ldflags="-s -w $(LDFLAGS)" -trimpath -o $(BINARY_PATH) ./cmd/openboot
3537
@echo "Original size: $$(du -h $(BINARY_PATH) | cut -f1)"
3638
@if command -v upx >/dev/null 2>&1; then \
3739
echo "Compressing with UPX..."; \

internal/cli/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
var (
14-
version = "0.18.2"
14+
version = "dev"
1515
cfg = &config.Config{}
1616
)
1717

internal/updater/updater.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,10 @@ func isNewerVersion(latest, current string) bool {
196196
if latest == "" {
197197
return false
198198
}
199+
// Dev builds (built from source without version injection) never auto-update
200+
if current == "dev" {
201+
return false
202+
}
199203
latestClean := trimVersionPrefix(latest)
200204
currentClean := trimVersionPrefix(current)
201205
return latestClean != currentClean && latestClean > currentClean

0 commit comments

Comments
 (0)