Add goreleaser configuration

parent e4caab7d
Pipeline #39474222 passed with stage
in 43 seconds
builds:
- env:
- CGO_ENABLED=0
main: ./cmd/container-inventory/main.go
goos:
- linux
- darwin
goarch:
- amd64
archive:
replacements:
darwin: macos
linux: linux
amd64: x86_64
checksum:
name_template: 'checksums.txt'
sign:
artifacts: checksum
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
......@@ -17,6 +17,12 @@ var repository string
var verbose bool
var sessions *sessionfile.Manager
var longNames bool
var showVersion bool
var (
version = "dev"
commit = "none"
date = "unknown"
)
func showSubcommandsList(cmd *cobra.Command) {
fmt.Println("Please use one of the following sub-commands:")
......@@ -31,6 +37,10 @@ var rootCmd = &cobra.Command{
showSubcommandsList(cmd)
},
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if showVersion {
fmt.Printf("%v, commit %v, built at %v", version, commit, date)
os.Exit(0)
}
if verbose {
logger = logger.Level(zerolog.DebugLevel)
} else {
......@@ -51,6 +61,7 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&sessionName, "session", "s", "", "Session name")
rootCmd.PersistentFlags().BoolVarP(&longNames, "long", "l", false, "Display long names of tags and repositories including the registry path")
rootCmd.PersistentFlags().BoolVar(&verbose, "verbose", false, "Verbose logging")
rootCmd.PersistentFlags().BoolVar(&showVersion, "version", false, "Show version information")
}
func MustExecute() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment