Skip to content

Commit

Permalink
Define proper version when releasing
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Sep 19, 2023
1 parent 1145175 commit 5c76ff0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ brews:
# actual formula things
commit_msg_template: "Brew formula update for jalapeno version {{ .Tag }}"
test: |
system "#{bin}/jalapeno --version"
system "#{bin}/jalapeno --version"
19 changes: 19 additions & 0 deletions cmd/jalapeno/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,36 @@ package main
import (
"fmt"
"os"
"time"

"github.com/carlmjohnson/versioninfo"
"github.com/futurice/jalapeno/internal/cli"
)

var (
// https://goreleaser.com/cookbooks/using-main.version/
version string
)

func main() {
cmd, err := cli.NewRootCmd()
if err != nil {
fmt.Printf("%+v", err)
os.Exit(1)
}

if version != "" {
cmd.Version = fmt.Sprintf("Jalapeno version %s", version)
} else {
cmd.Version = fmt.Sprintf(
"Jalapeno version %s (Built on %s from Git SHA %s)",
versioninfo.Version,
versioninfo.Revision,
versioninfo.LastCommit.Format(time.RFC3339),
)

}

if err = cmd.Execute(); err != nil {
os.Exit(1)
}
Expand Down
11 changes: 0 additions & 11 deletions internal/cli/root.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package cli

import (
"fmt"
"time"

"github.com/carlmjohnson/versioninfo"
"github.com/spf13/cobra"
)

Expand All @@ -16,13 +12,6 @@ func NewRootCmd() (*cobra.Command, error) {
Long: "",
}

cmd.Version = fmt.Sprintf(
"%s (Built on %s from Git SHA %s)",
versioninfo.Version,
versioninfo.Revision,
versioninfo.LastCommit.Format(time.RFC3339),
)

cmd.AddCommand(
NewCreateCmd(),
NewUpgradeCmd(),
Expand Down

0 comments on commit 5c76ff0

Please sign in to comment.