Skip to content

Commit

Permalink
Add version command and tag major-version-latest docker images (#21)
Browse files Browse the repository at this point in the history
Fixes #20
  • Loading branch information
kamaln7 authored Feb 20, 2019
1 parent a7bb29d commit 2962278
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
16 changes: 10 additions & 6 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
builds:
- env:
- CGO_ENABLED=0
- binary: klein
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X "github.com/kamaln7/klein/cmd.Version={{.Version}}"
archive:
replacements:
darwin: Darwin
Expand All @@ -9,19 +12,20 @@ archive:
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
name_template: "{{ .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- "^docs:"
- "^test:"
dockers:
- dockerfile: Dockerfile-goreleaser
extra_files:
- 404.html
image_templates:
- "kamaln7/klein:{{ .Version }}"
- "kamaln7/klein:{{ .Major }}-latest"
- kamaln7/klein:latest
24 changes: 24 additions & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cmd

import (
"fmt"

"github.com/spf13/cobra"
)

func init() {
rootCmd.AddCommand(versionCmd)
}

// Version is the klein package version
// to be filled in at compile time using ldflags
var Version = "-dev"

var versionCmd = &cobra.Command{
Use: "version",
Short: "print the version number of klein",
Long: "print the version number of klein",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("klein v%s\n", Version)
},
}

0 comments on commit 2962278

Please sign in to comment.