Skip to content

Commit

Permalink
bundle build date into running blob
Browse files Browse the repository at this point in the history
Signed-off-by: António Meireles <[email protected]>
  • Loading branch information
AntonioMeireles committed Jan 7, 2016
1 parent 330736c commit 6514fef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ export GOOS=darwin
export CGO_ENABLED=1

VERSION := $(shell git describe --abbrev=6 --dirty=-unreleased --always --tags)
BUILDDATE = $(shell /bin/date "+%FT%T%Z")

ifeq ($(DEBUG),true)
GO_GCFLAGS := -gcflags "-N -l"
else
GO_LDFLAGS := $(GO_LDFLAGS) -w -s
endif

GO_LDFLAGS := $(GO_LDFLAGS) -X main.Version=$(VERSION)
GO_LDFLAGS := $(GO_LDFLAGS) -X main.Version=$(VERSION) \
-X main.BuildDate=$(BUILDDATE)

all: corectl docs
@git status
Expand Down
11 changes: 7 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"log"
"os"
"strings"
"time"

"github.com/google/go-github/github"
"github.com/spf13/cobra"
Expand All @@ -45,7 +46,7 @@ var (
engine sessionContext
// -ldflags "-X main.Version=
// `git describe --abbrev=6 --dirty=-unreleased --always --tags`"
Version string
Version, BuildDate string
)

func main() {
Expand All @@ -72,13 +73,15 @@ func init() {

func versionCommand(cmd *cobra.Command, args []string) {
var (
err error
latest *github.RepositoryRelease
err error
latest *github.RepositoryRelease
stamp, _ = time.Parse("2006-01-02T15:04:05MST", BuildDate)
)
fmt.Printf("%s\n%s\n\n", "CoreOS over OSX made simple.",
"❯❯❯ http://github.com/TheNewNormal/corectl")
fmt.Printf("Installed version: %s (built at %v)\n",
strings.TrimPrefix(Version, "v"), stamp)

fmt.Println("Installed version:", strings.TrimPrefix(Version, "v"))
if latest, _, err =
github.NewClient(nil).Repositories.GetLatestRelease("TheNewNormal",
"corectl"); err != nil {
Expand Down

0 comments on commit 6514fef

Please sign in to comment.