File tree 6 files changed +54
-2
lines changed
6 files changed +54
-2
lines changed Original file line number Diff line number Diff line change
1
+ bin /**
Original file line number Diff line number Diff line change
1
+ .ONESHELL :
2
+ .SHELLFLAGS += -x -e
3
+ PWD = $(shell pwd)
4
+ UID = $(shell id -u)
5
+ GID = $(shell id -g)
6
+ VERSION = "0.1.0"
7
+ LD_FLAGS = -X goauthentik.io/cli/pkg/cfg.Version=${VERSION}
8
+ GO_FLAGS = -ldflags "${LD_FLAGS}" -v
9
+
10
+ bin/ak :
11
+ $(eval LD_FLAGS := -X goauthentik.io/cli/pkg/cfg.Version=${VERSION} -X goauthentik.io/cli/pkg/cfg.BuildHash=dev-$(shell git rev-parse HEAD) )
12
+ go build \
13
+ -ldflags " ${LD_FLAGS} -X goauthentik.io/cli/pkg/cfg.BuildHash=${GIT_BUILD_HASH} " \
14
+ -v -a -o bin/ak .
15
+
16
+ clean :
17
+ rm -rf ${PWD} /bin/*
Original file line number Diff line number Diff line change 1
1
package cmd
2
2
3
3
import (
4
+ "fmt"
4
5
"os"
5
6
6
7
log "github.com/sirupsen/logrus"
7
8
"github.com/spf13/cobra"
9
+ "goauthentik.io/cli/pkg/cfg"
8
10
)
9
11
10
12
func mustFlag [T any ](res T , err error ) T {
@@ -17,7 +19,7 @@ func mustFlag[T any](res T, err error) T {
17
19
// rootCmd represents the base command when called without any subcommands
18
20
var rootCmd = & cobra.Command {
19
21
Use : "ak" ,
20
- Short : "authentik CLI" ,
22
+ Short : fmt . Sprintf ( "authentik CLI v%s" , cfg . FullVersion ()) ,
21
23
PersistentPreRun : func (cmd * cobra.Command , args []string ) {
22
24
verbose := mustFlag (cmd .Flags ().GetBool ("verbose" ))
23
25
if verbose {
Original file line number Diff line number Diff line change 5
5
6
6
"github.com/kolide/systray"
7
7
"goauthentik.io/cli/pkg/agent/icon"
8
+ "goauthentik.io/cli/pkg/cfg"
8
9
)
9
10
10
11
func (a * Agent ) startSystray () {
@@ -25,7 +26,7 @@ func (a *Agent) systrayReady() {
25
26
}
26
27
27
28
func (a * Agent ) systrayEarlyItems () {
28
- _ = systray .AddMenuItem ("authentik CLI v0.1" , "" )
29
+ _ = systray .AddMenuItem (fmt . Sprintf ( "authentik CLI v%s" , cfg . FullVersion ()) , "" )
29
30
}
30
31
31
32
func (a * Agent ) systrayLateItems () {
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ package cfg
2
+
3
+ import (
4
+ "strings"
5
+ )
6
+
7
+ // Set via ldflags
8
+ var (
9
+ Version = ""
10
+ BuildHash = ""
11
+ )
12
+
13
+ func FullVersion () string {
14
+ version := strings.Builder {}
15
+ version .WriteString (Version )
16
+ if BuildHash != "" {
17
+ version .WriteRune ('-' )
18
+ if len (BuildHash ) >= 8 {
19
+ version .WriteString (BuildHash [:8 ])
20
+ } else {
21
+ version .WriteString (BuildHash )
22
+ }
23
+ }
24
+ return version .String ()
25
+ }
26
+
27
+ func init () {
28
+ if BuildHash == "" {
29
+ BuildHash = "dev"
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments