From f5595236ecd758a0ae36ff7026eef7acb8e529ea Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Thu, 7 Feb 2019 14:06:40 -0800 Subject: [PATCH] Readd Makefile --- Makefile | 37 +++++++++++++++++++++++++++++++++++++ {ci => build}/nfpm.yml | 2 +- ci/script.sh | 15 ++------------- 3 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 Makefile rename {ci => build}/nfpm.yml (90%) diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6fabbd3 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +# builds .rpm and .deb packages +# requires dockerd to be running +# builds the packages for amd64 + +VERSION=$(shell go run main.go -v) +ARCHIVE="gotop_$(VERSION)_linux_amd64" + +.PHONY: all +all: dist/gotop.rpm dist/gotop.deb + +dist/gotop: + @GOOS=linux GOARCH=amd64 go build -o $@ + +dist: + @mkdir $@ + +dist/gotop.rpm: dist dist/gotop + @docker run --rm \ + -v "$(PWD)/build:/tmp/build" \ + -v "$(PWD)/dist:/tmp/dist" \ + -e "VERSION=$(VERSION)" \ + goreleaser/nfpm pkg \ + --config /tmp/build/nfpm.yml \ + --target /tmp/dist/$(ARCHIVE).rpm + +dist/gotop.deb: dist dist/gotop + @docker run --rm \ + -v "$(PWD)/build:/tmp/build" \ + -v "$(PWD)/dist:/tmp/dist" \ + -e "VERSION=$(VERSION)" \ + goreleaser/nfpm pkg \ + --config /tmp/build/nfpm.yml \ + --target /tmp/dist/$(ARCHIVE).deb + +.PHONY: clean +clean: + @-rm -rf dist diff --git a/ci/nfpm.yml b/build/nfpm.yml similarity index 90% rename from ci/nfpm.yml rename to build/nfpm.yml index a15824a..1e9501a 100644 --- a/ci/nfpm.yml +++ b/build/nfpm.yml @@ -12,4 +12,4 @@ homepage: "https://github.com/cjbassi/gotop" license: "GNU Affero General Public License v3.0" bindir: "/usr/local/bin" files: - /tmp/pkg/gotop: "/usr/local/bin/gotop" + /tmp/dist/gotop: "/usr/local/bin/gotop" diff --git a/ci/script.sh b/ci/script.sh index 3872b25..142d0cf 100755 --- a/ci/script.sh +++ b/ci/script.sh @@ -23,19 +23,8 @@ fi tar -czf dist/${FILE}.tgz ${NAME} || ERROR=true if [[ ${GOOS} == "linux" && ${GOARCH} == "amd64" ]]; then - VERSION=$(go run main.go -v) # used by nfpm - docker run --rm \ - -v $PWD:/tmp/pkg \ - -e VERSION=${VERSION} \ - goreleaser/nfpm pkg \ - --config /tmp/pkg/ci/nfpm.yml \ - --target /tmp/pkg/dist/${FILE}.deb || ERROR=true - docker run --rm \ - -v $PWD:/tmp/pkg \ - -e VERSION=${VERSION} \ - goreleaser/nfpm pkg \ - --config /tmp/pkg/ci/nfpm.yml \ - --target /tmp/pkg/dist/${FILE}.rpm || ERROR=true + make all || ERROR=true + rm dist/gotop fi if [ ${ERROR} == "true" ]; then