File tree Expand file tree Collapse file tree 4 files changed +90
-21
lines changed Expand file tree Collapse file tree 4 files changed +90
-21
lines changed Original file line number Diff line number Diff line change 1+ name : goreleaser
2+
3+ on :
4+ push :
5+ tags :
6+ - ' *'
7+
8+ permissions :
9+ contents : write
10+
11+ jobs :
12+ goreleaser :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout
16+ uses : actions/checkout@v4
17+ with :
18+ fetch-depth : 0
19+ - name : Set up Go
20+ uses : actions/setup-go@v4
21+ with :
22+ go-version : ' 1.21'
23+ - name : Run GoReleaser
24+ uses : goreleaser/goreleaser-action@v5
25+ with :
26+ # either 'goreleaser' (default) or 'goreleaser-pro'
27+ distribution : goreleaser
28+ version : latest
29+ args : release --clean
30+ env :
31+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
32+ - name : Upload assets
33+ uses : actions/upload-artifact@v3
34+ with :
35+ name : gitfs
36+ path : dist/*
Original file line number Diff line number Diff line change 1- .idea
1+ .idea
2+ /dist /
Original file line number Diff line number Diff line change 1+ # This is an example .goreleaser.yml file with some sensible defaults.
2+ # Make sure to check the documentation at https://goreleaser.com
3+
4+ # The lines bellow are called `modelines`. See `:help modeline`
5+ # Feel free to remove those if you don't want/need to use them.
6+ # yaml-language-server: $schema=https://goreleaser.com/static/schema.json
7+ # vim: set ts=2 sw=2 tw=0 fo=cnqoj
8+
9+ before :
10+ hooks :
11+ # You may remove this if you don't use go modules.
12+ - go mod tidy
13+ # you may remove this if you don't need go generate
14+ - go generate ./...
15+
16+ builds :
17+ - env :
18+ - CGO_ENABLED=0
19+ goos :
20+ - linux
21+ - darwin
22+ main : ./cmd/gitfs
23+
24+ archives :
25+ - format : tar.gz
26+ # this name template makes the OS and Arch compatible with the results of `uname`.
27+ name_template : >-
28+ {{ .ProjectName }}_
29+ {{- title .Os }}_
30+ {{- if eq .Arch "amd64" }}x86_64
31+ {{- else if eq .Arch "386" }}i386
32+ {{- else }}{{ .Arch }}{{ end }}
33+ {{- if .Arm }}v{{ .Arm }}{{ end }}
34+ # use zip for windows archives
35+ format_overrides :
36+ - goos : windows
37+ format : zip
38+
39+ changelog :
40+ sort : asc
41+ filters :
42+ exclude :
43+ - " ^docs:"
44+ - " ^test:"
Original file line number Diff line number Diff line change @@ -4,39 +4,27 @@ import (
44 "fmt"
55 "github.com/spf13/cobra"
66 "runtime/debug"
7- "time"
87)
98
9+ var version string
10+
1011var versionCmd = & cobra.Command {
1112 Use : "version" ,
1213 Short : "Print version information" ,
1314 Run : func (cmd * cobra.Command , args []string ) {
14- fmt .Println (getVersionString ())
15+ cmd .Println (getVersionString ())
1516 },
1617}
1718
1819func getVersionString () string {
20+ if version != "" {
21+ return fmt .Sprintf ("gitfs: v%s" , version )
22+ }
23+
1924 info , ok := debug .ReadBuildInfo ()
2025 if ! ok {
2126 return "gitfs: unknown version"
2227 }
23- var revision string
24- var lastCommit time.Time
2528
26- for _ , kv := range info .Settings {
27- switch kv .Key {
28- case "vcs.revision" :
29- revision = kv .Value
30- case "vcs.time" :
31- lastCommit , _ = time .Parse (time .RFC3339 , kv .Value )
32- }
33- }
34- if revision == "" {
35- return fmt .Sprintf ("gitfs: version %s" , info .Main .Version )
36- }
37- return fmt .Sprintf (
38- "gitfs: version %s, build %s" ,
39- revision ,
40- lastCommit ,
41- )
29+ return fmt .Sprintf ("gitfs: %s" , info .Main .Version )
4230}
You can’t perform that action at this time.
0 commit comments