diff --git a/.gitignore b/.gitignore index 8a9b7d9..0e27b06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -gotop* dist/ +build/gotop +pkg/ \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7ddce40 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ + +VERSION=$(shell awk '/([0-9]{1}.?){3}/ {print $$4;}' main.go) + +.PHONY: all +all: pkg/gotop.rpm pkg/gotop.deb + +build/gotop: + @GOOS=linux GOARCH=amd64 go build -o $@ + +pkg: + @mkdir $@ + +pkg/gotop.rpm: pkg build/gotop + @docker run --rm \ + -v "$(PWD)/build:/tmp/pkg" \ + -e "VERSION=$(VERSION)" \ + goreleaser/nfpm pkg \ + --config /tmp/pkg/gotop-nfpm.yaml \ + --target /tmp/pkg/gotop.rpm \ + && mv ./build/gotop.rpm $@ + +pkg/gotop.deb: pkg build/gotop + @docker run --rm \ + -v "$(PWD)/build:/tmp/pkg" \ + -e "VERSION=$(VERSION)" \ + goreleaser/nfpm pkg \ + --config /tmp/pkg/gotop-nfpm.yaml \ + --target /tmp/pkg/gotop.deb \ + && mv ./build/gotop.deb $@ + +.PHONY: clean +clean: + @-rm -f build/gotop + @-rm -rf pkg \ No newline at end of file diff --git a/README.md b/README.md index a9076a0..0cb6b6d 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,17 @@ To make a custom colorscheme, check out the [template](https://github.com/cjbass `-p`, `--percpu` Show each CPU in the CPU widget. `-a`, `--averagecpu` Show average CPU in the CPU widget. + +## Building deb/rpms + +To build dep/rpms using [nfpm](https://github.com/goreleaser/nfpm): + +```bash +make all +``` + +This will place the built packages into the `pkg` folder. + ## Credits - [mdnazmulhasan27771](https://github.com/mdnazmulhasan27771) for the [logo](https://github.com/cjbassi/gotop/blob/master/assets/logo.png) diff --git a/build/gotop-nfpm.yaml b/build/gotop-nfpm.yaml new file mode 100644 index 0000000..a15824a --- /dev/null +++ b/build/gotop-nfpm.yaml @@ -0,0 +1,15 @@ +name: "gotop" +arch: "amd64" +platform: "linux" +version: "v${VERSION}" +section: "default" +priority: "extra" +maintainer: "Caleb Bassi " +description: | + A terminal based graphical activity monitor inspired by gtop and vtop +vendor: "Caleb Bassi" +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"