Public Access
The version was a hand-edited constant in the Makefile, so tagging a release without first committing the bump produced a release whose binaries disagree with it: v0.2.1 was tagged on a commit still saying VERSION := v0.2.0, and all four binaries attached to that release print v0.2.0 from `draft version`. VERSION now comes from `git describe --tags --always`: exactly the tag on a tagged commit (v0.2.1), tag-plus-distance after it (v0.2.1-3-g1a2b3c4), `dev` outside a git checkout such as a source tarball. `make build VERSION=...` still overrides it. There is nothing left to bump before tagging. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
35 lines
1.4 KiB
Makefile
35 lines
1.4 KiB
Makefile
PKG_NAME := git.fernandovideira.com/FernandoJVideira/draft
|
|
# Taken from the git tag, so a build can never disagree with the release it was
|
|
# cut from: exactly `v0.2.1` on that tag, `v0.2.1-3-g1a2b3c4` three commits
|
|
# later, `dev` outside a git checkout (e.g. a source tarball). Override with
|
|
# `make build VERSION=v1.2.3`.
|
|
VERSION ?= $(shell git describe --tags --always 2>/dev/null || echo dev)
|
|
GO_SOURCES := $(shell find . -name '*.go' -not -path './assets/testdata/*')
|
|
|
|
.PHONY: version build windows win-arm linux mac prepare-embed clean
|
|
|
|
version:
|
|
@go run -ldflags "-X ${PKG_NAME}/cmd.version=${VERSION}" ./main.go version
|
|
|
|
windows: ; @$(MAKE) build GOOS=windows GOARCH=amd64 OUTPUT=draft_windows_amd64.exe
|
|
win-arm: ; @$(MAKE) build GOOS=windows GOARCH=arm64 OUTPUT=draft_windows_arm64.exe
|
|
linux: ; @$(MAKE) build GOOS=linux GOARCH=amd64 OUTPUT=draft_linux_amd64
|
|
mac: ; @$(MAKE) build GOOS=darwin GOARCH=arm64 OUTPUT=draft_darwin_arm64
|
|
|
|
build: $(OUTPUT)
|
|
|
|
$(OUTPUT): prepare-embed-stamp $(GO_SOURCES)
|
|
@echo "Building for $(GOOS)/$(GOARCH)..."
|
|
@GOOS=$(GOOS) GOARCH=$(GOARCH) go build -ldflags "-X ${PKG_NAME}/cmd.version=${VERSION}" -o $(OUTPUT) ./main.go
|
|
|
|
prepare-embed-stamp:
|
|
@git submodule update --init --recursive
|
|
@mkdir -p assets/embedded
|
|
@GOOS="" GOARCH="" go run tools/sync_templates.go
|
|
@touch $@
|
|
|
|
prepare-embed: prepare-embed-stamp
|
|
|
|
clean:
|
|
@rm -f draft_windows_amd64.exe draft_windows_arm64.exe draft_linux_amd64 draft_darwin_arm64 prepare-embed-stamp
|