commit c78b6d1aaf2568df0ba8be543597323cbd743dc0
parent 7607f016c59b30f97918d97063c12c9388e0bc6f
Author: David Eisinger <[email protected]>
Date: Wed, 8 Oct 2025 14:45:00 -0400
make dist
Diffstat:
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
@@ -1,2 +1,3 @@
bin
coverage.out
+dist
diff --git a/Makefile b/Makefile
@@ -1,8 +1,14 @@
-.PHONY: build clean fmt test vendor
+.PHONY: build clean fmt test vendor dist
+.ONESHELL:
BINARY := bin/marky
SRC := cmd/marky.go
+# Tag-derived version (strip leading v)
+VER := $(shell git describe --tags --exact-match 2>/dev/null || git tag --points-at HEAD | head -n1)
+V := $(patsubst v%,%,$(VER))
+OUTDIR := dist
+
# All Go sources in repo (used to decide when to rebuild the binary)
GO_SOURCES := $(shell find . -type f -name '*.go')
# Embedded assets (served via go:embed)
@@ -36,3 +42,20 @@ vendor:
@echo "Fetching DOMPurify..."
@curl -fsSL https://cdn.jsdelivr.net/npm/[email protected]/dist/purify.min.js -o internal/web/vendor/purify.min.js
@echo "Vendored frontend libraries updated."
+
+# Build release binaries for the current tag (if any)
+dist:
+ @if [ -z "$(VER)" ]; then echo "No tag found."; exit 1; fi
+ @echo "Building marky $(V) artifacts..."
+ @mkdir -p $(OUTDIR)
+ # linux/amd64
+ @rm -rf $(OUTDIR)/.stage_linux_amd64 && mkdir -p $(OUTDIR)/.stage_linux_amd64
+ @CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags "-s -w" -o "$(OUTDIR)/.stage_linux_amd64/marky" $(SRC)
+ @tar -C "$(OUTDIR)/.stage_linux_amd64" -czf "$(OUTDIR)/marky_$(V)_linux_amd64.tar.gz" marky
+ @rm -rf "$(OUTDIR)/.stage_linux_amd64"
+ # darwin/arm64
+ @rm -rf $(OUTDIR)/.stage_darwin_arm64 && mkdir -p $(OUTDIR)/.stage_darwin_arm64
+ @GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags "-s -w" -o "$(OUTDIR)/.stage_darwin_arm64/marky" $(SRC)
+ @tar -C "$(OUTDIR)/.stage_darwin_arm64" -czf "$(OUTDIR)/marky_$(V)_darwin_arm64.tar.gz" marky
+ @rm -rf "$(OUTDIR)/.stage_darwin_arm64"
+ @echo "Artifacts written to $(OUTDIR): marky_$(V)_linux_amd64.tar.gz, marky_$(V)_darwin_arm64.tar.gz"