-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added version command and goreleaser (#100)
* added version command and goreleaser * added release to Makefile. adapted build and clean scripts to gorelease. changed version short text output * reverted clean and build scripts. changed path for builds * added dist field to goreleaser * added post hook * disabled archiving * added archive name template * changed archive name template * changed archive name template * changed goreleaser.yml * removed pre hooks
- Loading branch information
1 parent
63bdf3c
commit 5af3371
Showing
5 changed files
with
91 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
.env | ||
|
||
vendor/ | ||
build/ | ||
build/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
builds: | ||
- main: ./cli/main.go | ||
ldflags: | ||
- -s -w -X github.com/vulpemventures/nigiri/cli/cmd.version={{.Version}} -X github.com/vulpemventures/nigiri/cli/cmd.commit={{.Commit}} -X github.com/vulpemventures/nigiri/cli/cmd.date={{.Date}} | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
checksum: | ||
name_template: 'checksums.txt' | ||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
archives: | ||
- | ||
format: binary | ||
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/vulpemventures/nigiri/cli/constants" | ||
"github.com/vulpemventures/nigiri/cli/controller" | ||
) | ||
|
||
var ( | ||
version = "dev" | ||
commit = "none" | ||
date = "unknown" | ||
VersionCmd = &cobra.Command{ | ||
Use: "version", | ||
Short: "Show the current version", | ||
RunE: versionFunc, | ||
PreRunE: versionChecks, | ||
} | ||
) | ||
|
||
func versionChecks(cmd *cobra.Command, args []string) error { | ||
datadir, _ := cmd.Flags().GetString("datadir") | ||
|
||
ctl, err := controller.NewController() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if err := ctl.ParseDatadir(datadir); err != nil { | ||
return err | ||
} | ||
|
||
if isRunning, err := ctl.IsNigiriRunning(); err != nil { | ||
return err | ||
} else if !isRunning { | ||
return constants.ErrNigiriNotRunning | ||
} | ||
|
||
if err := ctl.ReadConfigFile(datadir); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func versionFunc(cmd *cobra.Command, address []string) error { | ||
fmt.Println("Version: " + version) | ||
fmt.Println("Commit: " + commit) | ||
fmt.Println("Date: " + date) | ||
return nil | ||
} |