-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update makefile to make nicer release binaries
Fixes #46
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 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 +1,2 @@ | ||
cmd/promxy/promxy | ||
build/* |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
BUILD := build | ||
GO ?= go | ||
GOFILES := $(shell find . -name "*.go" -type f ! -path "./vendor/*") | ||
GOFMT ?= gofmt -s | ||
|
||
.PHONY: clean | ||
clean: | ||
$(GO) clean -i ./... | ||
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA) | ||
|
||
.PHONY: fmt | ||
fmt: | ||
$(GOFMT) -w $(GOFILES) | ||
|
||
.PHONY: test | ||
test: | ||
$(GO) test ./... | ||
|
||
.PHONY: release | ||
release: | ||
./build.bash github.com/jacksontj/promxy/cmd/promxy $(BUILD) |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
VERSION=`git describe --tags` | ||
|
||
package=$1 | ||
destination=$2 | ||
if [[ -z "$package" ]]; then | ||
echo "usage: $0 <package-name> <destination>" | ||
exit 1 | ||
fi | ||
package_split=(${package//\// }) | ||
package_name=${package_split[-1]} | ||
|
||
platforms=("linux/amd64" "linux/386" "darwin/amd64") | ||
|
||
for platform in "${platforms[@]}" | ||
do | ||
platform_split=(${platform//\// }) | ||
GOOS=${platform_split[0]} | ||
GOARCH=${platform_split[1]} | ||
output_name=$package_name'-'$VERSION'-'$GOOS'-'$GOARCH | ||
if [ $GOOS = "windows" ]; then | ||
output_name+='.exe' | ||
fi | ||
|
||
env GOOS=$GOOS GOARCH=$GOARCH CGO_ENABLED=0 go build -o $destination/$output_name $package | ||
if [ $? -ne 0 ]; then | ||
echo 'An error has occurred! Aborting the script execution...' | ||
exit 1 | ||
fi | ||
done | ||
|