From 62dc816a6347396ccc21533a1fe2f22dc8f2c25a Mon Sep 17 00:00:00 2001 From: Shingo Kawamura Date: Mon, 24 Jul 2017 00:24:42 +0900 Subject: [PATCH] Add zip --- .gitignore | 1 + Makefile | 10 ++++++++-- zip | 28 ++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 zip 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"