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.
This commit is contained in:
Tobi Smethurst 2021-06-28 12:17:20 +02:00 committed by GitHub
commit 4f3b3f5c0b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 11 deletions

View file

@ -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)
}