Skip to content

Commit

Permalink
Merge pull request #34 from tnozicka/release-tooling
Browse files Browse the repository at this point in the history
Add release tooling
  • Loading branch information
kadel authored Feb 24, 2017
2 parents b93f320 + 9bbb42e commit d0edfd9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
opencompose
opencompose*.tar.xz
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,28 @@ all: build

SHELL :=/bin/bash

GIT_VERSION =$(shell git describe --tags --abbrev=0 2>/dev/null)
GIT_EXACT_VERSION =$(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
GIT_COMMIT =$(shell git rev-parse --short HEAD 2>/dev/null)
GIT_TREE_STATE =$(shell (test -z "$$(git status --porcelain 2>/dev/null)" && echo clean) || echo dirty)

GOFMT :=gofmt -s
GOIMPORTS :=goimports -e

GO_IMPORT_PATH :=github.com/redhat-developer/opencompose
GO_FILES :=$(shell find . -name '*.go' -not -path './vendor/*' -print)
GO_PACKAGES = $(shell glide novendor)

GO_PACKAGES =$(shell glide novendor)
ifneq ($(and $(GIT_VERSION),$(GIT_COMMIT),$(GIT_TREE_STATE)),)
GO_LDFLAGS =-ldflags="-X $(GO_IMPORT_PATH)/pkg/version.gitVersion=$(GIT_VERSION) -X $(GO_IMPORT_PATH)/pkg/version.gitCommit=$(GIT_COMMIT) -X $(GO_IMPORT_PATH)/pkg/version.gitTreeState=$(GIT_TREE_STATE)"
endif

.PHONY: build
build:
go build
go build $(GO_LDFLAGS)

.PHONY: install
install:
go install
go install $(GO_LDFLAGS)

.PHONY: test
test:
Expand Down Expand Up @@ -73,3 +81,10 @@ update-vendor:
.PHONY: strip-vendor
strip-vendor:
$(do-strip-vendor)

.PHONY: release
release: build
ifeq ($(and $(GIT_EXACT_VERSION),$(GIT_COMMIT)),)
$(error GIT_EXACT_VERSION or GIT_COMMIT is not set or this is not a tagged commit)
endif
tar -cJf opencompose-$(GIT_EXACT_VERSION)-$(GIT_COMMIT)-linux-64bit.tar.xz ./opencompose ./LICENSE ./README.md
4 changes: 2 additions & 2 deletions pkg/version/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ package version
var (
// semantic version
gitVersion string = "v0.0.0"
gitCommit string = "00000000000000000000" // sha1 from git, output of $(git rev-parse HEAD)
gitTreeState string = "not a git tree" // state of git tree, either "clean" or "dirty"
gitCommit string = "000000" // sha1 from git, output of $(git rev-parse HEAD)
gitTreeState string = "not_a_git_tree" // state of git tree, either "clean" or "dirty"
)

0 comments on commit d0edfd9

Please sign in to comment.