diff --git a/.gitignore b/.gitignore index 762d693..a717e17 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ scv +archives/ ### https://raw.github.com/github/gitignore/c0c1a480a906df0e023f3250cf2ad82f1612be67/Go.gitignore diff --git a/Makefile b/Makefile index 526dffa..a4ea869 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,16 @@ -.PHONY: all clean test +.PHONY: all zip build clean test -all: +all: build + +zip: build + @./zip + +build: @go build -ldflags "-X github.com/blp1526/scv/cmd.version="$(shell ./version) clean: @go clean + @rm -rf archives test: @go test ./... diff --git a/zip b/zip new file mode 100755 index 0000000..2c66779 --- /dev/null +++ b/zip @@ -0,0 +1,28 @@ +#!/bin/bash + +unames=$(uname -s) +if [ ${unames} = "Linux" ]; then + GOOS="linux" +elif [ ${unames} = "Darwin" ]; then + GOOS="darwin" +else + echo "fatal: Unsupported OS" + exit 1 +fi + +unamem=$(uname -m) +if [ ${unamem} = "x86_64" ]; then + GOARCH="amd64" +else + echo "fatal: Unsupported ARCH" + exit 1 +fi + +rm -rf "archives" +path="archives/scv_${GOOS}_${GOARCH}" +mkdir -p ${path} +mv scv ${path} +zip -r "${path}.zip" ${path} > /dev/null +rm -rf "${path}" + +echo "${path}.zip created"