All checks were successful
check / check (push) Successful in 3m6s
The binary reported "dev" in every deployment: main.version carried a placeholder and nothing ever set it. Neither `make build` nor the Dockerfile passed -X, so a tagged release produced an artifact that could not say which commit it was, and the upgrade procedure's "confirm the new build is live" step had nothing to confirm against. script/version is now the single source of the value: $VERSION when set, else `git describe --tags --always --dirty`, else "unknown". A clean checkout at a tag reports exactly that tag; a tree with no git metadata reports "unknown" rather than failing or naming a tag it may not be at. Nothing time- or host-dependent is stamped, so two builds of one commit stay byte-identical. The Makefile's build target composes the flags -- `-X main.version` plus whatever GO_LDFLAGS adds -- and every compile goes through it, including the Dockerfile's static relink, which now contributes its -extldflags through GO_LDFLAGS instead of replacing -ldflags wholesale. Since .dockerignore excludes .git/, the image cannot derive the version: it takes a VERSION build arg, defaulted to "unknown", that script/docker fills in from the host checkout. The UI footer needed the other half of the fix. It renders .Version, which nothing ever put in the template data, so it printed its literal "dev" fallback no matter what the binary was built as; renderTemplate now supplies the value on both the map and the wrapper path. An empty VERSION means unset in the Makefile too, not only in script/version: `make build VERSION=` and a `--build-arg VERSION=` reaching the Dockerfile's `make build VERSION="$VERSION"` both define the variable as the empty string, which the script's guard never sees and which would stamp no version at all -- putting the footer back on its "dev" fallback, the defect this change exists to remove. The guard needs `override`: a plain assignment loses to the command-line definition it exists to correct.
75 lines
1.6 KiB
Makefile
75 lines
1.6 KiB
Makefile
.PHONY: bootstrap setup assets test lint fmt fmt-check check build run dev deps docker clean hooks css version
|
|
|
|
# Default target
|
|
.DEFAULT_GOAL := check
|
|
|
|
# Version stamped into the binary. Derived from git by script/version;
|
|
# override it (`make build VERSION=v1.2.3`) where git metadata is
|
|
# unavailable, which is how the Dockerfile passes its build arg in.
|
|
VERSION ?= $(shell script/version)
|
|
|
|
# An empty override (`make build VERSION=`, or a `--build-arg VERSION=`
|
|
# landing on the Dockerfile's `make build VERSION="$VERSION"`) means unset,
|
|
# exactly as it does in script/version -- stamping "" would leave the binary
|
|
# reporting no version and the footer back on its "dev" fallback. `override`
|
|
# is required: a plain assignment loses to the command-line definition it
|
|
# exists to correct.
|
|
override VERSION := $(or $(strip $(VERSION)),$(shell script/version))
|
|
|
|
# Extra linker flags for the build target. The static relink in the
|
|
# Dockerfile adds -extldflags here rather than passing its own -ldflags,
|
|
# so composing flags cannot drop the version stamp.
|
|
GO_LDFLAGS ?=
|
|
|
|
bootstrap:
|
|
@script/bootstrap
|
|
|
|
setup:
|
|
@script/setup
|
|
|
|
assets:
|
|
@script/fetch-assets
|
|
|
|
test:
|
|
@script/test
|
|
|
|
lint:
|
|
@script/lint
|
|
|
|
fmt:
|
|
@script/fmt
|
|
|
|
fmt-check:
|
|
@script/fmt-check
|
|
|
|
check:
|
|
@script/check
|
|
|
|
build:
|
|
go build -ldflags '$(strip -X main.version=$(VERSION) $(GO_LDFLAGS))' -o bin/webhooker ./cmd/webhooker
|
|
|
|
run: build
|
|
./bin/webhooker
|
|
|
|
dev:
|
|
go run ./cmd/webhooker
|
|
|
|
deps:
|
|
go mod download
|
|
go mod tidy
|
|
|
|
version:
|
|
@echo $(VERSION)
|
|
|
|
docker:
|
|
@script/docker
|
|
|
|
clean:
|
|
rm -rf bin/
|
|
|
|
hooks:
|
|
@script/install-precommit
|
|
|
|
css:
|
|
tailwindcss -i static/css/input.css -o static/css/tailwind.css --minify
|