Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Commit

Permalink
Merge pull request #92 from crawford/build
Browse files Browse the repository at this point in the history
build: various fixes to the build programs
  • Loading branch information
crawford committed Jul 14, 2017
2 parents 66d84b2 + b43e7ba commit 390af23
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 45 deletions.
55 changes: 32 additions & 23 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,50 @@
export CGO_ENABLED:=0
# kernel-style V=1 build verbosity
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE = $(V)
endif

VERSION=$(shell git describe --dirty)
LD_FLAGS="-w -X github.com/coreos/container-linux-config-transpiler/internal/version.Raw=$(VERSION)"
ifeq ($(BUILD_VERBOSE),1)
Q =
else
Q = @
endif

VERSION=$(shell git describe --dirty)
REPO=github.com/coreos/container-linux-config-transpiler
LD_FLAGS="-w -X $(REPO)/internal/version.Raw=$(VERSION)"

all: build
export GOPATH=$(shell pwd)/gopath
export CGO_ENABLED:=0

build: bin/ct
.PHONY: all
all: bin/ct

bin/ct:
@go build -o $@ -v -ldflags $(LD_FLAGS) $(REPO)/internal
gopath:
$(Q)mkdir -p gopath/src/github.com/coreos
$(Q)ln -s ../../../.. gopath/src/$(REPO)

.PHONY: test
test:
@./test
$(Q)./test

.PHONY: vendor
vendor:
@glide update --strip-vendor
@glide-vc --use-lock-file --no-tests --only-code
$(Q)glide update --strip-vendor
$(Q)glide-vc --use-lock-file --no-tests --only-code

.PHONY: clean
clean:
@rm -rf bin
@rm -rf _output
$(Q)rm -rf bin

.PHONY: release
release: \
_output/unknown-linux-gnu/ct \
_output/apple-darwin/ct \
_output/pc-windows-gnu/ct

_output/unknown-linux-gnu/ct: GOARGS = GOOS=linux GOARCH=amd64
_output/apple-darwin/ct: GOARGS = GOOS=darwin GOARCH=amd64
_output/pc-windows-gnu/ct: GOARGS = GOOS=windows GOARCH=amd64
bin/ct-$(VERSION)-x86_64-unknown-linux-gnu \
bin/ct-$(VERSION)-x86_64-apple-darwin \
bin/ct-$(VERSION)-x86_64-pc-windows-gnu.exe

_output/%/ct: NAME=_output/ct-$(VERSION)-x86_64-$*
_output/%/ct:
$(GOARGS) go build -o $(NAME) -ldflags $(LD_FLAGS) $(REPO)/internal
bin/ct-%-x86_64-unknown-linux-gnu: GOARGS = GOOS=linux GOARCH=amd64
bin/ct-%-x86_64-apple-darwin: GOARGS = GOOS=darwin GOARCH=amd64
bin/ct-%-x86_64-pc-windows-gnu.exe: GOARGS = GOOS=windows GOARCH=amd64

.PHONY: all build clean test
bin/%: | gopath
$(Q)$(GOARGS) go build -o $@ -ldflags $(LD_FLAGS) $(REPO)/internal
32 changes: 32 additions & 0 deletions release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

set -e

[ $# == 1 ] || { echo "usage: $0 version" && exit 1; }

VER=$1

[[ "${VER}" =~ ^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$ ]] || {
echo "malformed version: \"${VER}\""
exit 2
}

if test -n "$(git ls-files --others | \
grep --invert-match '\(gopath/src/github.com/coreos/container-linux-config-transpiler\|bin/ct\)')";
then
echo "directory has untracked files"
exit 1
fi

if ! $(git diff-index --quiet HEAD --); then
echo "directory has uncommitted files"
exit 1
fi

make test

git tag --sign --message "Config-Transpiler ${VER}" "${VER}"

git verify-tag --verbose "${VER}"

make release
22 changes: 0 additions & 22 deletions tag_release.sh

This file was deleted.

0 comments on commit 390af23

Please sign in to comment.