Stamp the git tag or short commit into the binary (closes #4)
check / check (push) Successful in 3m35s
check / check (push) Successful in 3m35s
A plain `docker build .` now stamps bsdaily's version: the VERSION build argument when one is given, otherwise `git describe --tags --always` on the .git in the build context, as the canonical Dockerfile does. The build fails if .git is there and the version still comes out empty, dev or unknown. A host `make` build stamps the same `git describe`, or dev. bsdaily logs the version on the first line of every run and prints it with --version; a build that stamps nothing, or an empty value, reports dev. Judgement call: the build line also takes the canonical -trimpath and -s -w. One //nolint (gochecknoglobals): -X can only set a package-level variable. Model: opus-5-5 Co-authored-by: clawbot <sneak+clawbot@sneak.cloud>
This commit was merged in pull request #5.
This commit is contained in:
@@ -20,7 +20,18 @@ var (
|
||||
errFromAfterTo = errors.New("is after --to")
|
||||
)
|
||||
|
||||
// Version is the git tag or short commit, set at link time with
|
||||
// -X main.Version=... by the Dockerfile and the Makefile. A build that sets
|
||||
// nothing, or sets it empty, reports dev.
|
||||
//
|
||||
//nolint:gochecknoglobals // -X can only set a package-level variable
|
||||
var Version string
|
||||
|
||||
func main() {
|
||||
if Version == "" {
|
||||
Version = "dev"
|
||||
}
|
||||
|
||||
logger := slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{
|
||||
Level: slog.LevelInfo,
|
||||
}))
|
||||
@@ -31,8 +42,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(_ *cobra.Command, _ []string) error {
|
||||
slog.Info("starting", "version", Version)
|
||||
|
||||
targetDates, err := parseTargetDates(dateFlag, fromFlag, toFlag)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user