Skip to content

Commit 4ec6be1

Browse files
committedMay 9, 2024
build: include version in build artefacts
1 parent c6f7f12 commit 4ec6be1

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed
 

‎.goreleaser.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ builds:
4141
flags:
4242
- -trimpath
4343
ldflags:
44-
- -s -w -X {{.ModulePath}}/cmd.version={{.Version}} -X {{.ModulePath}}/cmd.commit={{.Commit}} -X {{.ModulePath}}/cmd.date={{ .CommitDate }} -X {{.ModulePath}}/cmd.treeState={{ .IsGitDirty }}
44+
- -s -w -X {{.ModulePath}.version={{.Version}} -X {{.ModulePath}}.commit={{.Commit}} -X {{.ModulePath}}.date={{ .CommitDate }} -X {{.ModulePath}}.treeState={{ .IsGitDirty }}
4545

4646
universal_binaries:
4747
- replace: false

‎main.go

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"fmt"
45
"io"
56
"log"
67
"os"
@@ -9,6 +10,15 @@ import (
910
"github.com/jippi/scm-engine/cmd"
1011
"github.com/jippi/scm-engine/pkg/tui"
1112
"github.com/urfave/cli/v2"
13+
slogctx "github.com/veqryn/slog-context"
14+
)
15+
16+
// nolint: gochecknoglobals
17+
var (
18+
commit = "unknown"
19+
date = "unknown"
20+
treeState = "unknown"
21+
version = "dev"
1222
)
1323

1424
func main() {
@@ -20,14 +30,16 @@ func main() {
2030
Copyright: "Christian Winther",
2131
EnableBashCompletion: true,
2232
Suggest: true,
33+
Version: fmt.Sprintf("%s (date: %s; commit: %s)", version, date, commit),
2334
Authors: []*cli.Author{
2435
{
2536
Name: "Christian Winther",
26-
Email: "gitlab-engine@jippi.dev",
37+
Email: "scm-engine@jippi.dev",
2738
},
2839
},
2940
Before: func(cCtx *cli.Context) error {
3041
cCtx.Context = tui.NewContext(cCtx.Context, cCtx.App.Writer, cCtx.App.ErrWriter)
42+
cCtx.Context = slogctx.With(cCtx.Context, "scm_engine_version", version)
3143

3244
return nil
3345
},

0 commit comments

Comments
 (0)