From 4f3b3f5c0b00b8c47c7e7d8e6c2dda624e114cde Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Mon, 28 Jun 2021 12:17:20 +0200 Subject: put version in binary properly (#73) Addresses #71 : Set version on the CLI framework. Add a build.sh script that injects variables into the build tooling using git and a version file. Set version in config. --- cmd/gotosocial/main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'cmd') diff --git a/cmd/gotosocial/main.go b/cmd/gotosocial/main.go index 27810a80b..9729f7706 100644 --- a/cmd/gotosocial/main.go +++ b/cmd/gotosocial/main.go @@ -33,12 +33,19 @@ import ( "github.com/urfave/cli/v2" ) +// Version is the software version of GtS being used +var Version string + +// Commit is the git commit of GtS being used +var Commit string + func main() { flagNames := config.GetFlagNames() envNames := config.GetEnvNames() defaults := config.GetDefaults() app := &cli.App{ - Usage: "a fediverse social media server", + Version: Version + " " + Commit[:7], + Usage: "a fediverse social media server", Flags: []cli.Flag{ // GENERAL FLAGS &cli.StringFlag{ @@ -399,7 +406,7 @@ func runAction(c *cli.Context, a cliactions.GTSAction) error { return fmt.Errorf("error creating config: %s", err) } // ... and the flags set on the *cli.Context by urfave - if err := conf.ParseCLIFlags(c); err != nil { + if err := conf.ParseCLIFlags(c, c.App.Version); err != nil { return fmt.Errorf("error parsing config: %s", err) } -- cgit v1.2.3