summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile37
-rw-r--r--build/nfpm.yml (renamed from ci/nfpm.yml)2
-rwxr-xr-xci/script.sh15
3 files changed, 40 insertions, 14 deletions
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
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