From c16279862186b3d9d7d0ba4346820bb473e3ab81 Mon Sep 17 00:00:00 2001 From: Kamil Samigullin Date: Thu, 10 Aug 2017 13:22:51 +0300 Subject: [PATCH] fix issue #69: complete goreleaser.yml --- Makefile | 5 ++++- cmd/semaphore/build.go | 7 +++++++ cmd/semaphore/main.go | 1 + goreleaser.yml | 4 ++-- makes/env.mk | 2 +- 5 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 cmd/semaphore/build.go diff --git a/Makefile b/Makefile index 3c536a2..4c2b41d 100644 --- a/Makefile +++ b/Makefile @@ -69,7 +69,10 @@ test-cmd: -v '$(GOPATH)/src/$(GO_PACKAGE)':'/go/src/$(GO_PACKAGE)' \ -w '/go/src/$(GO_PACKAGE)' \ golang:1.7 \ - /bin/sh -c 'go install -ldflags "-X 'main.Version=test'" ./cmd/semaphore \ + /bin/sh -c 'go install -ldflags "-s -w -X main.version=test \ + -X main.commit=$(GIT_REV) \ + -X main.date=$(DATE)" \ + ./cmd/semaphore \ && semaphore create --capacity=1 --timeout=10s \ && semaphore add -- curl example.com \ && semaphore add -- curl example.com \ diff --git a/cmd/semaphore/build.go b/cmd/semaphore/build.go new file mode 100644 index 0000000..a66d231 --- /dev/null +++ b/cmd/semaphore/build.go @@ -0,0 +1,7 @@ +package main + +var ( + commit = "none" + date = "unknown" + version = "dev" +) diff --git a/cmd/semaphore/main.go b/cmd/semaphore/main.go index 9992bfe..1553e14 100644 --- a/cmd/semaphore/main.go +++ b/cmd/semaphore/main.go @@ -9,4 +9,5 @@ import ( func main() { flag.Parse() fmt.Println(strings.Join(flag.Args(), ", ")) + fmt.Println(commit, date, version) } diff --git a/goreleaser.yml b/goreleaser.yml index 23e13c4..889ed23 100644 --- a/goreleaser.yml +++ b/goreleaser.yml @@ -1,5 +1,5 @@ homepage: &home https://github.com/kamilsk/semaphore -description: &desc Semaphore pattern implementation with timeout of lock/unlock operations based on channels. +description: &desc Semaphore pattern implementation with a timeout of lock/unlock operations based on channels. archive: files: @@ -37,7 +37,7 @@ build: - darwin - linux - windows - ldflags: -s -w -X 'main.Version="{{.Version}} ({{.Date}})"' + ldflags: -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} main: ./cmd/semaphore release: diff --git a/makes/env.mk b/makes/env.mk index 0133432..68145a9 100644 --- a/makes/env.mk +++ b/makes/env.mk @@ -4,7 +4,7 @@ endif CWD := $(patsubst %/,%,$(dir $(abspath $(firstword $(MAKEFILE_LIST))))) CID := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))) -DATE := $(shell date -u "+%Y-%m-%d %H:%M:%S") +DATE := $(shell date -u "+%Y-%m-%d_%H:%M:%S") GO_VERSION := $(shell go version | awk '{print $$3}' | tr -d 'go') GIT_REV := $(shell git rev-parse --short HEAD)