From 44478e147e0a805dc4966d804c9e808b87a19f48 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Tue, 21 Jul 2020 18:04:36 +0100 Subject: [PATCH] Add tag-based version --- .github/workflows/release.yml | 12 ++++++------ cmd/version.go | 12 +++++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index db2c511..cbba5d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,12 +28,6 @@ jobs: dep ensure fi - - name: Build - run: go build -v . - - - name: Test - run: go test -v . - - name: Set env run: | echo '::set-env name=GO111MODULE::on' @@ -48,6 +42,12 @@ jobs: echo "::set-env name=RELEASE_VERSION::${RELEASE_VERSION}" echo "::set-output name=RELEASE_VERSION::${RELEASE_VERSION}" + - name: Build + run: go build -v -ldflags="-X cmd.ReleaseVersion=${RELEASE_VERSION}" . + + - name: Test + run: go test -v . + - name: Fetch xgo run: | go get github.com/suburbandad/xgo diff --git a/cmd/version.go b/cmd/version.go index aea9f58..12ea315 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -1,4 +1,4 @@ -// Copyright © 2019 Weald Technology Trading +// Copyright © 2019, 2020 Weald Technology Trading // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at @@ -22,15 +22,17 @@ import ( "github.com/spf13/viper" ) +var ReleaseVersion = "local build" + // versionCmd represents the version command var versionCmd = &cobra.Command{ Use: "version", - Short: "Version of Ethdo", - Long: `Obtain the version of Ethdo. For example: + Short: "Version of ethdo", + Long: `Obtain the version of ethdo. For example: - ethdo version.`, + ethdo version`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("1.5.0-prerelease") + fmt.Println(ReleaseVersion) if viper.GetBool("verbose") { buildInfo, ok := dbg.ReadBuildInfo() if ok {