Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ just docker run debug # Run with debug logging

```bash
just build # Build for current platform
just build-linux # Build for Linux
just build-all # Build all platforms
just build GOOS=linux GOARCH=amd64 # Build for linux/amd64
just test # Run tests
just lint # Lint code
just fmt # Format code
Expand Down
31 changes: 10 additions & 21 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ VERSION := `git describe --tags --always --dirty 2>/dev/null || echo "dev"`
GIT_COMMIT := `git rev-parse HEAD 2>/dev/null || echo "unknown"`
TAG := `git rev-parse --short HEAD 2>/dev/null || echo "dev"`
RELEASE := "dist"
GOARCH := env("GOARCH", `go env GOARCH`)
GOOS := env("GOOS", `go env GOOS`)

_help:
@just -l
Expand All @@ -34,36 +36,23 @@ fmt:
# ============================================================================

# Build for current platform
build:
@mkdir -p {{ RELEASE }}
@go build -trimpath -o {{ RELEASE }}/cachewd \
-ldflags "-s -w -X main.version={{ VERSION }} -X main.gitCommit={{ GIT_COMMIT }}" \
./cmd/cachewd
@echo "✓ Built {{ RELEASE }}/cachewd"

# Build for Linux (current arch)
build-linux:
build GOOS=(GOOS) GOARCH=(GOARCH):
#!/usr/bin/env bash
set -e
mkdir -p {{ RELEASE }}
ARCH=$(uname -m)
[[ "$ARCH" == "x86_64" ]] && ARCH="amd64"
[[ "$ARCH" == "aarch64" || "$ARCH" == "arm64" ]] && ARCH="arm64"
echo "Building for linux/${ARCH}..."
GOOS=linux GOARCH=${ARCH} go build -trimpath \
-o {{ RELEASE }}/cachewd-linux-${ARCH} \
go build -trimpath -o {{ RELEASE }}/cachewd-{{ GOOS }}-{{ GOARCH }} \
-ldflags "-s -w -X main.version={{ VERSION }} -X main.gitCommit={{ GIT_COMMIT }}" \
./cmd/cachewd
echo "✓ Built {{ RELEASE }}/cachewd-linux-${ARCH}"
test "{{ GOOS }}-{{ GOARCH }}" = "$(go env GOOS)-$(go env GOARCH)" && (cd {{ RELEASE }} && ln -sf cachewd-{{ GOOS }}-{{ GOARCH }} cachewd)
echo "✓ Built {{ RELEASE }}/cachewd-{{ GOOS }}-{{ GOARCH }}"

# Build all platforms
build-all:
@mkdir -p {{ RELEASE }}
@echo "Building all platforms..."
@GOOS=darwin GOARCH=arm64 go build -trimpath -o {{ RELEASE }}/cachewd-darwin-arm64 -ldflags "-s -w -X main.version={{ VERSION }} -X main.gitCommit={{ GIT_COMMIT }}" ./cmd/cachewd
@GOOS=darwin GOARCH=amd64 go build -trimpath -o {{ RELEASE }}/cachewd-darwin-amd64 -ldflags "-s -w -X main.version={{ VERSION }} -X main.gitCommit={{ GIT_COMMIT }}" ./cmd/cachewd
@GOOS=linux GOARCH=arm64 go build -trimpath -o {{ RELEASE }}/cachewd-linux-arm64 -ldflags "-s -w -X main.version={{ VERSION }} -X main.gitCommit={{ GIT_COMMIT }}" ./cmd/cachewd
@GOOS=linux GOARCH=amd64 go build -trimpath -o {{ RELEASE }}/cachewd-linux-amd64 -ldflags "-s -w -X main.version={{ VERSION }} -X main.gitCommit={{ GIT_COMMIT }}" ./cmd/cachewd
just build darwin arm64
just build darwin amd64
just build linux arm64
just build linux amd64
@echo "✓ Built all platforms"

# ============================================================================
Expand Down
2 changes: 1 addition & 1 deletion docker/Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ set positional-arguments := true
set shell := ["bash", "-c"]

# Configuration
ROOT := `git rev-parse --show-toplevel 2>/dev/null || echo "."`
ROOT := `git rev-parse --show-toplevel 2>/dev/null || echo "."`
TAG := `git rev-parse --short HEAD 2>/dev/null || echo "dev"`
VERSION := `git describe --tags --always --dirty 2>/dev/null || echo "dev"`
GIT_COMMIT := `git rev-parse HEAD 2>/dev/null || echo "unknown"`
Expand Down