forked from hashicorp/envconsul
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
94 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,57 @@ | ||
TEST?=./... | ||
NAME = $(shell awk -F\" '/^const Name/ { print $$2; exit }' main.go) | ||
NAME?=$(shell basename "${CURDIR}") | ||
VERSION = $(shell awk -F\" '/^const Version/ { print $$2; exit }' main.go) | ||
|
||
default: test | ||
|
||
# bin generates the releasable binaries for Consul Template | ||
# bin generates the binaries for all platforms. | ||
bin: generate | ||
@sh -c "'$(CURDIR)/scripts/build.sh'" | ||
@sh -c "'${CURDIR}/scripts/build.sh' '${NAME}'" | ||
|
||
# dev creates binares for testing locally. There are put into ./bin and $GOPAHT | ||
# dev creates binares for testing locally - they are put into ./bin and $GOPATH. | ||
dev: generate | ||
@CT_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'" | ||
@DEV=1 sh -c "'${CURDIR}/scripts/build.sh' '${NAME}'" | ||
|
||
# dist creates the binaries for distibution | ||
dist: bin | ||
@sh -c "'$(CURDIR)/scripts/dist.sh' $(VERSION)" | ||
# dist creates the binaries for distibution. | ||
dist: | ||
@sh -c "'${CURDIR}/scripts/dist.sh' '${NAME}' '${VERSION}'" | ||
|
||
# test runs the test suite and vets the code | ||
# test runs the test suite and vets the code. | ||
test: generate | ||
go test $(TEST) $(TESTARGS) -timeout=30s -parallel=4 | ||
@echo "==> Running tests..." | ||
@go list $(TEST) \ | ||
| grep -v "github.com/hashicorp/${NAME}/vendor" \ | ||
| xargs -n1 go test -timeout=60s -parallel=10 ${TESTARGS} | ||
|
||
# testrace runs the race checker | ||
testrace: generate | ||
go test -race $(TEST) $(TESTARGS) | ||
@echo "==> Running tests (race)..." | ||
@go list $(TEST) \ | ||
| grep -v "github.com/hashicorp/${NAME}/vendor" \ | ||
| xargs -n1 go test -timeout=60s -race ${TESTARGS} | ||
|
||
# updatedeps installs all the dependencies Consul Template needs to run and | ||
# build | ||
# updatedeps installs all the dependencies needed to run and build. | ||
updatedeps: | ||
go get -u github.com/mitchellh/gox | ||
go get -f -t -u ./... | ||
go list ./... \ | ||
| xargs go list -f '{{join .Deps "\n"}}' \ | ||
| grep -v github.com/hashicorp/envconsul \ | ||
| grep -v '/internal/' \ | ||
| sort -u \ | ||
| xargs go get -f -u | ||
|
||
# generate runs `go generate` to build the dynamically generated | ||
# source files. | ||
@echo "==> Updating dependencies..." | ||
@echo " Cleaning previous dependencies..." | ||
@rm -rf vendor/ | ||
@echo " Updating to newest dependencies..." | ||
@go get -f -t -u ./... | ||
@echo " Saving dependencies..." | ||
godep save | ||
|
||
# generate runs `go generate` to build the dynamically generated source files. | ||
generate: | ||
@echo "==> Generating..." | ||
@find . -type f -name '.DS_Store' -delete | ||
go generate ./... | ||
@go list ./... \ | ||
| grep -v "github.com/hashicorp/${NAME}/vendor" \ | ||
| xargs -n1 go generate | ||
|
||
# bootstrap installs the necessary go tools for development/build. | ||
bootstrap: | ||
@echo "==> Bootstrapping..." | ||
go get -u github.com/tools/godep | ||
go get -u github.com/mitchellh/gox | ||
|
||
.PHONY: default bin dev dist test testrace updatedeps vet generate | ||
.PHONY: default bin dev dist test testrace updatedeps vet generate bootstrap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,69 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Get the version from the command line | ||
VERSION=$1 | ||
# Get the name from the command line. | ||
NAME=$1 | ||
if [ -z $NAME ]; then | ||
echo "Please specify a name." | ||
exit 1 | ||
fi | ||
|
||
# Get the version from the command line. | ||
VERSION=$2 | ||
if [ -z $VERSION ]; then | ||
echo "Please specify a version." | ||
exit 1 | ||
echo "Please specify a version." | ||
exit 1 | ||
fi | ||
|
||
# Get the parent directory of where this script is. | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )" | ||
|
||
# Change into that dir because we expect that | ||
cd $DIR | ||
# Change into that dir because we expect that. | ||
cd "$DIR" | ||
|
||
# Build | ||
if [ -z $NOBUILD ]; then | ||
echo "==> Building..." | ||
docker run \ | ||
--rm \ | ||
--workdir="/go/src/github.com/hashicorp/${NAME}" \ | ||
--volume="$(pwd):/go/src/github.com/hashicorp/${NAME}" \ | ||
golang:1.6.2 /bin/sh -c "make bootstrap && make bin" | ||
fi | ||
|
||
# Generate the tag. | ||
if [ -z $NOTAG ]; then | ||
echo "==> Tagging..." | ||
git commit --allow-empty -a --gpg-sign=348FFC4C -m "Release v$VERSION" | ||
git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" master | ||
fi | ||
|
||
# Zip all the files. | ||
echo "==> Packaging..." | ||
for PLATFORM in $(find ./pkg -mindepth 1 -maxdepth 1 -type d); do | ||
OSARCH=$(basename ${PLATFORM}) | ||
echo "--> ${OSARCH}" | ||
|
||
pushd $PLATFORM >/dev/null 2>&1 | ||
zip ../${OSARCH}.zip ./* | ||
popd >/dev/null 2>&1 | ||
done | ||
|
||
# Zip all the files | ||
# Move everything into dist. | ||
rm -rf ./pkg/dist | ||
mkdir -p ./pkg/dist | ||
for FILENAME in $(find ./pkg -mindepth 1 -maxdepth 1 -type f); do | ||
FILENAME=$(basename $FILENAME) | ||
cp ./pkg/${FILENAME} ./pkg/dist/envconsul_${VERSION}_${FILENAME} | ||
cp ./pkg/${FILENAME} ./pkg/dist/${NAME}_${VERSION}_${FILENAME} | ||
done | ||
|
||
# Make the checksums | ||
# Make and sign the checksums. | ||
pushd ./pkg/dist | ||
shasum -a256 * > ./envconsul_${VERSION}_SHA256SUMS | ||
shasum -a256 * > ./${NAME}_${VERSION}_SHA256SUMS | ||
if [ -z $NOSIGN ]; then | ||
echo "==> Signing..." | ||
gpg --default-key 348FFC4C --detach-sig ./envconsul_${VERSION}_SHA256SUMS | ||
gpg --default-key 348FFC4C --detach-sig ./${NAME}_${VERSION}_SHA256SUMS | ||
fi | ||
popd |