Skip to content

Commit

Permalink
Add files for releasing binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
mizzy committed Nov 29, 2016
1 parent 7908211 commit 2de717d
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
bin/
vendor/
.vagrant/
pkg/

17 changes: 13 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
NAME := walter
VERSION := $(shell git describe --tags --abbrev=0)
VERSION := $(shell grep 'Version string' version.go | sed -E 's/.*"(.+)"$$/\1/')
REVISION := $(shell git rev-parse --short HEAD)
LDFLAGS := -X 'main.version=$(VERSION)' -X 'main.revision=$(REVISION)'
LDFLAGS := -X 'main.GitCommit=$(REVISION)'

setup:
go get github.com/Masterminds/glide
go get github.com/golang/lint/golint
go get golang.org/x/tools/cmd/goimports
go get github.com/mitchellh/gox

deps: setup
glide install

test: deps
test: deps lint
go test $$(glide novendor)
go test -race $$(glide novendor)

Expand All @@ -24,8 +25,16 @@ lint: setup
fmt: setup
goimports -w $$(glide nv -x)

build: test
build: deps
go build -ldflags "$(LDFLAGS)" -o bin/$(NAME)

clean:
rm $(GOPATH)/bin/$(NAME)
rm bin/$(NAME)

package: deps
@sh -c "'$(CURDIR)/scripts/package.sh'"

ghr:
ghr -u walter-cd $(VERSION) pkg/dist/$(VERSION)

16 changes: 15 additions & 1 deletion glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions scripts/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

set -e

DIR=$(cd $(dirname ${0})/.. && pwd)
cd ${DIR}

XC_ARCH=${XC_ARCH:-386 amd64}
XC_OS=${XC_OS:-darwin linux}

COMMIT=`git describe --always`

rm -rf pkg/
gox \
-ldflags "-X main.GitCommit=${COMMIT}" \
-parallel=5 \
-os="${XC_OS}" \
-arch="${XC_ARCH}" \
-output "pkg/{{.OS}}_{{.Arch}}/{{.Dir}}"
36 changes: 36 additions & 0 deletions scripts/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -e

DIR=$(cd $(dirname ${0})/.. && pwd)
cd ${DIR}

VERSION=$(grep "const Version " version.go | sed -E 's/.*"(.+)"$/\1/')
REPO="ghr"

# Run Compile
./scripts/compile.sh

if [ -d pkg ];then
rm -rf ./pkg/dist
fi

# Package all binary as .zip
mkdir -p ./pkg/dist/${VERSION}
for PLATFORM in $(find ./pkg -mindepth 1 -maxdepth 1 -type d); do
PLATFORM_NAME=$(basename ${PLATFORM})
ARCHIVE_NAME=${REPO}_${VERSION}_${PLATFORM_NAME}

if [ $PLATFORM_NAME = "dist" ]; then
continue
fi

pushd ${PLATFORM}
zip ${DIR}/pkg/dist/${VERSION}/${ARCHIVE_NAME}.zip ./*
popd
done

# Generate shasum
pushd ./pkg/dist/${VERSION}
shasum -a 256 * > ./${VERSION}_SHASUMS
popd

0 comments on commit 2de717d

Please sign in to comment.