Fix Version
This commit is contained in:
parent
fb8ac67d45
commit
feacc1a323
17
magefile.go
17
magefile.go
|
@ -13,17 +13,17 @@
|
|||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
// +build mage
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/magefile/mage/mg"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/magefile/mage/mg"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -40,16 +40,21 @@ var (
|
|||
Version = "dev"
|
||||
)
|
||||
|
||||
func init() {
|
||||
Tags = os.Getenv("Tags")
|
||||
versionCmd := exec.Command("git", "describe", "--tags", "--always", "--abbrev=10") //, " | sed 's/-/+/'", " | sed 's/^v//'", " | sed 's/-g/-/'")
|
||||
func setVersion() {
|
||||
versionCmd := exec.Command("git", "describe", "--tags", "--always", "--abbrev=10")
|
||||
version, err := versionCmd.Output()
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting version: %s\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
Version = strings.Trim(string(version), "\n")
|
||||
fmt.Printf("Version: %s\n", Version)
|
||||
Version = strings.Replace(Version, "-", "+", 1)
|
||||
Version = strings.Replace(Version, "-g", "-", 1)
|
||||
}
|
||||
|
||||
func init() {
|
||||
Tags = os.Getenv("TAGS")
|
||||
setVersion()
|
||||
Ldflags = `-X "` + PACKAGE + `/pkg/version.Version=` + Version + `" -X "main.Tags=` + Tags + `"`
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue