File tree Expand file tree Collapse file tree 5 files changed +24
-43
lines changed Expand file tree Collapse file tree 5 files changed +24
-43
lines changed Original file line number Diff line number Diff line change 29
29
uses : actions/setup-go@v4
30
30
with :
31
31
go-version : ' 1.21'
32
- -
33
- name : Create version helper
34
- run : |
35
- cat > service/library/version_state.go << EOF
36
- package library
37
- import (
38
- "fmt"
39
- "strings"
40
- )
41
- var PYGMY_VERSION = "${GITHUB_REF}"
42
- func printversion() bool {
43
- parts := strings.Split(PYGMY_VERSION, "/")
44
- if PYGMY_VERSION == "" {
45
- return false
46
- }
47
- fmt.Printf("Pygmy version v%v\n", parts[len(parts)-1])
48
- return true
49
- }
50
- EOF
51
32
-
52
33
name : Fetch Dependencies
53
34
run : go mod vendor
@@ -65,13 +46,13 @@ jobs:
65
46
env :
66
47
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
67
48
-
68
- name : Check GoReleaser
49
+ name : Dry-Run GoReleaser
69
50
uses : goreleaser/goreleaser-action@v6
70
51
if : ${{ startsWith(github.ref, 'refs/tags/v') }}
71
52
with :
72
53
distribution : goreleaser
73
54
version : ' ~> v2'
74
- args : release --clean --skip=docker --skip=homebrew --skip=publish
55
+ args : release --clean --snapshot -- skip=docker --skip=homebrew --skip=publish
75
56
env :
76
57
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
77
58
-
Original file line number Diff line number Diff line change @@ -12,10 +12,17 @@ archives:
12
12
name_template : " {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}_static"
13
13
builds :
14
14
- pygmy-static
15
+
15
16
builds :
16
17
- id : pygmy
17
18
env :
18
19
- CGO_ENABLED=0
20
+ ldflags :
21
+ - -X main.Version={{.Tag}}
22
+ - -X main.CommitSHA={{.FullCommit}}
23
+ - -X main.BuildDate={{.CommitDate}}
24
+ - -X main.GoOS={{.Os}}
25
+ - -X main.GoArch={{.Arch}}
19
26
goos :
20
27
- linux
21
28
- darwin
@@ -39,6 +46,11 @@ builds:
39
46
flags :
40
47
- -a
41
48
ldflags :
49
+ - -X main.Version={{.Tag}}
50
+ - -X main.CommitSHA={{.FullCommit}}
51
+ - -X main.BuildDate={{.CommitDate}}
52
+ - -X main.GoOS={{.Os}}
53
+ - -X main.GoArch={{.Arch}}
42
54
- -extldflags "-static"
43
55
goos :
44
56
- linux
@@ -48,6 +60,9 @@ builds:
48
60
- arm
49
61
- arm64
50
62
63
+ snapshot :
64
+ name_template : " {{ .Version }}-SNAPSHOT-{{.ShortCommit}}"
65
+
51
66
brews :
52
67
- ids :
53
68
- pygmy
Original file line number Diff line number Diff line change 21
21
package cmd
22
22
23
23
import (
24
- "github.com/pygmystack/pygmy/service/library"
25
24
"github.com/spf13/cobra"
25
+
26
+ "github.com/pygmystack/pygmy/service/library"
26
27
)
27
28
28
29
// versionCmd represents the version command
Original file line number Diff line number Diff line change @@ -2,18 +2,17 @@ package library
2
2
3
3
import (
4
4
"fmt"
5
+ "runtime/debug"
5
6
)
6
7
7
8
// Version describes which version of Pygmy is running.
8
9
func Version (c Config ) {
10
+ info , _ := debug .ReadBuildInfo ()
9
11
10
- // printversion is updated as static content via GitHub Actions.
11
- // If this version is not injected as static content, the version
12
- // is deemed unidentifiable - it should be assumed the binary was
13
- // compiled outside of official release management.
14
- if printversion () {
12
+ if info .Main .Version == "(devel)" {
13
+ fmt .Println ("Development version" )
15
14
return
16
15
}
17
16
18
- fmt .Printf ("Pygmy version unidentifiable. \n " )
17
+ fmt .Printf ("Pygmy %s \n " , info . Main . Version )
19
18
}
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments