Compare commits

1 Commits
Author SHA1 Message Date
sneak 2cd390e62e Stamp the git tag or short commit into the binary (closes #4)
check / check (pull_request) Blocked by required conditions
A plain `docker build .` now stamps the version into bsdaily: the
VERSION build argument when one is given, otherwise `git describe
--tags --always` of the .git in the build context. The build fails if
the context carries .git and no version comes out. A host `make` build
stamps the same `git describe` value, or dev when it yields nothing.
bsdaily logs the version on the first line of every run and prints it
with --version.

The new .dockerignore is the canonical copy, which keeps .git/config
out of the build context, plus this repo's host-built artifacts.
script/docker is replaced with the canonical copy, which passes the
version it derives on the host.

Model: opus-5-5
2026-10-02 08:38:33 +00:00
4 changed files with 17 additions and 10 deletions
+5
View File
@@ -58,3 +58,8 @@
**/.idea **/.idea
**/.vscode **/.vscode
**/*.sublime-* **/*.sublime-*
# This repo's host-built artifacts: `make` and `make test-coverage`.
/bsdaily
/coverage.out
/coverage.html
+2 -2
View File
@@ -1,7 +1,7 @@
.PHONY: all bootstrap setup check test lint fmt fmt-check build clean deps test-coverage test-integration install release release-snapshot docker hooks .PHONY: all bootstrap setup check test lint fmt fmt-check build clean deps test-coverage test-integration install release release-snapshot docker hooks
# Stamped into the binary: the same `git describe` the Dockerfile runs, so a # Stamped into the binary: the same `git describe` the Dockerfile runs, so a
# host build reports the same version as the image. # host build reports the same version as the image; dev when it yields nothing.
VERSION ?= $(shell git describe --tags --always) VERSION ?= $(shell git describe --tags --always)
# Default target # Default target
@@ -37,7 +37,7 @@ lint:
# Build binary (pure Go; no CGO required since we use modernc.org/sqlite). # Build binary (pure Go; no CGO required since we use modernc.org/sqlite).
bsdaily: internal/*/*.go cmd/bsdaily/*.go bsdaily: internal/*/*.go cmd/bsdaily/*.go
CGO_ENABLED=0 go build -ldflags "-X main.Version=$(VERSION)" -o $@ ./cmd/bsdaily CGO_ENABLED=0 go build -ldflags "-X main.Version=$(or $(VERSION),dev)" -o $@ ./cmd/bsdaily
# Clean build artifacts. # Clean build artifacts.
clean: clean:
+6 -6
View File
@@ -15,14 +15,15 @@ pre-1.0
# Next Step # Next Step
Bring the repo into policy compliance in one commit: add .gitignore, Bring the repo into policy compliance in one commit: add .gitignore,
.dockerignore, .editorconfig, and .golangci.yml. Verify `make check` stays .editorconfig, and .golangci.yml. Verify `make check` stays green with the new
green with the new lint config. lint config.
# Completed Steps # Completed Steps
- 2026-10-02: A plain `docker build .` and a host `make` build stamp the git tag - 2026-10-02: A plain `docker build .` and a host `make` build stamp the git tag
or short commit into the binary, which `bsdaily --version` prints; added the or short commit into the binary, which `bsdaily` logs on the first line of
canonical `.dockerignore`, which keeps `.git/config` out of the build context. every run and prints with `--version`; added the canonical `.dockerignore`,
which keeps `.git/config` out of the build context.
- 2026-07-07 Adopted scripts-to-rule-them-all: `script/` entrypoints, - 2026-07-07 Adopted scripts-to-rule-them-all: `script/` entrypoints,
Makefile shims, README Entrypoints section Makefile shims, README Entrypoints section
- 2026-06-28: Fixed errcheck lint failures; added compilation smoke test; - 2026-06-28: Fixed errcheck lint failures; added compilation smoke test;
@@ -39,8 +40,7 @@ green with the new lint config.
# Future Steps # Future Steps
- Add .gitignore, .dockerignore, .editorconfig, .golangci.yml (the Next - Add .gitignore, .editorconfig, .golangci.yml (the Next Step).
Step).
- Expand tests beyond the compilation smoke test: unit tests for the - Expand tests beyond the compilation smoke test: unit tests for the
extraction, verification, and atomic-publish paths. extraction, verification, and atomic-publish paths.
- Cut a first SemVer release once compliance and test coverage land. - Cut a first SemVer release once compliance and test coverage land.
+4 -2
View File
@@ -11,8 +11,8 @@ import (
) )
// Version is the git tag or short commit, set at link time with -X by the // Version is the git tag or short commit, set at link time with -X by the
// Dockerfile and the Makefile, and printed by --version. Builds that do not set // Dockerfile and the Makefile, logged on the first line of every run and
// it report dev. // printed by --version. Builds that do not set it report dev.
var Version = "dev" var Version = "dev"
func main() { func main() {
@@ -31,6 +31,8 @@ func main() {
Version: Version, Version: Version,
SilenceUsage: true, SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
slog.Info("starting", "version", Version)
hasDate := dateFlag != "" hasDate := dateFlag != ""
hasFrom := fromFlag != "" hasFrom := fromFlag != ""
hasTo := toFlag != "" hasTo := toFlag != ""