From 25158190266fe5985b1a672568db494954425fe9 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Sun, 3 Sep 2017 10:41:14 +0100 Subject: [PATCH] Add version stuff on root Former-commit-id: 4dcf3117e274fe2b656af6fd2ee98db386143620 [formerly df3bd216ef1020e9ca6a0ba57ef1c4bad5a6e04d] [formerly e5eded7248098655cd60112a6ec5fec06fd99ff2 [formerly 044575d2af0c58ddd042ee06371907c2d68b7d24]] Former-commit-id: 8fe1a523af24c490eef9d7cd2b1bc3de656002de [formerly 73aea3062fa487a5c6c89f8f04bd86c177c783f3] Former-commit-id: 6fd9e5260feacfe6b9d96515a7c3ab28c31f17db --- cmd/filemanager/main.go | 11 +---------- filemanager.go | 3 +++ publish.sh | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 publish.sh diff --git a/cmd/filemanager/main.go b/cmd/filemanager/main.go index eaa3f11f..5a14afc7 100644 --- a/cmd/filemanager/main.go +++ b/cmd/filemanager/main.go @@ -41,7 +41,6 @@ var ( allowNew bool allowPublish bool showVer bool - version = "master" ) func init() { @@ -102,15 +101,7 @@ func setupViper() { } func printVersion() { - version = strings.TrimSpace(version) - - if version == "" { - fmt.Println("filemanager is at an untracked version") - } else { - version = strings.TrimPrefix(version, "v") - fmt.Println("filemanager version", version) - } - + fmt.Println("filemanager version", filemanager.Version) os.Exit(0) } diff --git a/filemanager.go b/filemanager.go index b07a9d09..61717408 100644 --- a/filemanager.go +++ b/filemanager.go @@ -20,6 +20,9 @@ import ( "github.com/robfig/cron" ) +// Version is the current File Manager version. +const Version = "(untracked version)" + var ( ErrExist = errors.New("the resource already exists") ErrNotExist = errors.New("the resource does not exist") diff --git a/publish.sh b/publish.sh new file mode 100644 index 00000000..85333efc --- /dev/null +++ b/publish.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +echo "Releasing version $1" +sed -i "s|(untracked version)|$1|g" filemanager.go + +echo "Building assets" +./build.sh + +echo "Commiting..." +git add -A +git commit -m "Version $1" +git push + +echo "Creating the tag..." +git tag "v$1" +git push --tags + +echo "Commiting untracked version notice..." +sed -i "s|$1|(untracked version)|g" filemanager.go +git add -A +git commit -m "untracked version `date`" +git push + +echo "Done!"