Readd Makefile

This commit is contained in:
Caleb Bassi 2019-02-07 14:06:40 -08:00
parent e2c26cd7ac
commit f5595236ec
3 changed files with 40 additions and 14 deletions

37
Makefile Normal file
View File

@ -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

View File

@ -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"

View File

@ -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