forked from sneak/bsdaily
Stamp the git tag or short commit into the binary (closes #4)
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
This commit is contained in:
@@ -10,6 +10,11 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// Version is the git tag or short commit, set at link time with -X by the
|
||||
// Dockerfile and the Makefile, logged on the first line of every run and
|
||||
// printed by --version. Builds that do not set it report dev.
|
||||
var Version = "dev"
|
||||
|
||||
func main() {
|
||||
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
|
||||
Level: slog.LevelInfo,
|
||||
@@ -23,8 +28,11 @@ func main() {
|
||||
rootCmd := &cobra.Command{
|
||||
Use: "bsdaily",
|
||||
Short: "Extract a single day's data from the latest daily snapshot",
|
||||
Version: Version,
|
||||
SilenceUsage: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
slog.Info("starting", "version", Version)
|
||||
|
||||
hasDate := dateFlag != ""
|
||||
hasFrom := fromFlag != ""
|
||||
hasTo := toFlag != ""
|
||||
|
||||
Reference in New Issue
Block a user