Skip to content

Commit a427454

Browse files
chuongld20claude
andcommitted
feat: add cross-compile Makefile and GitHub Actions release workflow
- Makefile with build (single platform), release (4 targets), clean, test, vet - GitHub Actions workflow triggers on v* tags, cross-compiles, creates release - Version embedding via -ldflags -X main.version - SHA256 checksums for all release binaries - Add dist/ to .gitignore Resolves: ISS-36 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4b4deb8 commit a427454

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
23+
- name: Cross-compile
24+
run: make release VERSION=${{ github.ref_name }}
25+
26+
- name: Create GitHub Release
27+
uses: softprops/action-gh-release@v2
28+
with:
29+
files: dist/*
30+
generate_release_notes: true

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ vendor/
3030
.DS_Store
3131
Thumbs.db
3232

33+
# Build output
34+
/dist/
35+
3336
# devbox specific
3437
devbox.yaml
3538
*.log

Makefile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
BINARY := devbox
2+
MODULE := github.com/junixlabs/devbox
3+
BUILD_DIR := dist
4+
VERSION ?= $(shell git describe --tags 2>/dev/null || echo "0.1.0-dev")
5+
LDFLAGS := -s -w -X main.version=$(VERSION)
6+
7+
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
8+
9+
.PHONY: build release clean test vet
10+
11+
build:
12+
@mkdir -p $(BUILD_DIR)
13+
go build -ldflags '$(LDFLAGS)' -o $(BUILD_DIR)/$(BINARY) ./cmd/devbox/
14+
15+
release:
16+
@mkdir -p $(BUILD_DIR)
17+
@for platform in $(PLATFORMS); do \
18+
GOOS=$${platform%/*} GOARCH=$${platform#*/} \
19+
go build -ldflags '$(LDFLAGS)' -o $(BUILD_DIR)/$(BINARY)-$${platform%/*}-$${platform#*/} ./cmd/devbox/ && \
20+
echo "Built $(BINARY)-$${platform%/*}-$${platform#*/}"; \
21+
done
22+
@cd $(BUILD_DIR) && sha256sum $(BINARY)-* > checksums.txt
23+
@echo "Checksums written to $(BUILD_DIR)/checksums.txt"
24+
25+
clean:
26+
rm -rf $(BUILD_DIR)
27+
28+
test:
29+
go test ./...
30+
31+
vet:
32+
go vet ./...

0 commit comments

Comments
 (0)