diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..0710119 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,52 @@ +language: go + +go: + - 1.11.x + +os: + - linux + - osx + +git: + depth: 1 + +env: + global: + - NAME=gotop + +install: true +script: + - ./ci/script.sh + +matrix: + include: + # Linux + - env: _GOOS=linux _GOARCH=amd64 + os: linux + - env: _GOOS=linux _GOARCH=386 + os: linux + - env: _GOOS=linux _GOARCH=arm GOARM=5 + os: linux + - env: _GOOS=linux _GOARCH=arm GOARM=6 + os: linux + - env: _GOOS=linux _GOARCH=arm GOARM=7 + os: linux + - env: _GOOS=linux _GOARCH=arm64 + os: linux + + # OSX + - env: _GOOS=darwin _GOARCH=amd64 + os: osx + +deploy: + provider: releases + api_key: $GITHUB_TOKEN + file_glob: true + file: "./dist/*" + skip_cleanup: true + on: + tags: true + +notifications: + email: + on_success: never diff --git a/Makefile b/Makefile deleted file mode 100644 index a1af5f4..0000000 --- a/Makefile +++ /dev/null @@ -1,32 +0,0 @@ -VERSION=$(shell awk '/([0-9]{1}.?){3}/ {print $$4;}' main.go) - -.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/gotop-nfpm.yml \ - --target /tmp/dist/gotop.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/gotop-nfpm.yml \ - --target /tmp/dist/gotop.deb - -.PHONY: clean -clean: - @-rm -rf dist diff --git a/README.md b/README.md index bce4364..51addb2 100644 --- a/README.md +++ b/README.md @@ -98,16 +98,6 @@ To make a custom colorscheme, check out the [template](./colorschemes/template.g `-s`, `--statusbar` Show a statusbar with the time. `-b`, `--battery` Show battery level widget (`minimal` turns off). [widget preview](./assets/battery.png) -## 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 `dist` folder. - ## Credits - [mdnazmulhasan27771](https://github.com/mdnazmulhasan27771) for the [logo](./assets/logo.png) @@ -119,7 +109,7 @@ This will place the built packages into the `dist` folder. - [nsf/termbox](https://github.com/nsf/termbox-go) - [exrook/drawille-go](https://github.com/exrook/drawille-go) - [shirou/gopsutil](https://github.com/shirou/gopsutil) -- [goreleaser/goreleaser](https://github.com/goreleaser/goreleaser) +- [goreleaser/nfpm](https://github.com/goreleaser/nfpm) - [distatus/battery](https://github.com/distatus/battery) ## Stargazers over time diff --git a/build/.goreleaser.yml b/build/.goreleaser.yml deleted file mode 100644 index 9bc1d5d..0000000 --- a/build/.goreleaser.yml +++ /dev/null @@ -1,22 +0,0 @@ -builds: - - binary: gotop - goos: - - linux - goarch: - - amd64 - - 386 - - arm - - arm64 - goarm: - - 5 - - 6 - - 7 - hooks: - post: ./build/build-darwin-cgo.sh -archive: - name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}{{ .Arm }}{{ end }}" - replacements: - arm64: arm8 - format: tgz - files: - - none* diff --git a/build/build-darwin-cgo.sh b/build/build-darwin-cgo.sh deleted file mode 100755 index bc728a8..0000000 --- a/build/build-darwin-cgo.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/usr/bin/env bash - -version=$(go run main.go -v) - -xgo --targets="darwin/386,darwin/amd64" . - -mv gotop-darwin-10.6-386 gotop -tar czf gotop_${version}_darwin_386.tgz gotop -rm -f gotop - -mv gotop-darwin-10.6-amd64 gotop -tar czf gotop_${version}_darwin_amd64.tgz gotop -rm -f gotop diff --git a/build/build_steps.txt b/build/build_steps.txt deleted file mode 100644 index 8b8e26e..0000000 --- a/build/build_steps.txt +++ /dev/null @@ -1,21 +0,0 @@ -Dependencies: -- goreleaser: `go get github.com/goreleaser/goreleaser` -- xgo: `docker pull karalabe/xgo-latest; go get github.com/karalabe/xgo` -- dockerd - -make sure gotop builds and runs -update version number in main.go -commit changes -tag commit with version number -push changes -export GitHub token in shell -make sure dockerd is running -run `goreleaser --rm-dist -f build/.goreleaser.yml` -update GitHub release with Darwin builds -update homebrew-gotop - version numbers (there's 3) - sha256 (run `sha256sum {archived file}`) -update gotop and gotop-bin AUR packages - reset pkgrel - version number - sha256sum diff --git a/build/gotop-nfpm.yml b/ci/nfpm.yml similarity index 90% rename from build/gotop-nfpm.yml rename to ci/nfpm.yml index 1e9501a..a15824a 100644 --- a/build/gotop-nfpm.yml +++ b/ci/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/dist/gotop: "/usr/local/bin/gotop" + /tmp/pkg/gotop: "/usr/local/bin/gotop" diff --git a/ci/script.sh b/ci/script.sh new file mode 100755 index 0000000..596ee29 --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +GOARCH=${_GOARCH} +GOOS=${_GOOS} + +if [[ ! ${GOARCH} ]]; then + exit +fi + +env GOOS=${GOOS} GOARCH=${GOARCH} GOARM=${GOARM} go build -o ${NAME} + +mkdir -p dist + +if [[ ${GOARCH} == "arm64" ]]; then + FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_arm8 +else + FILE=${NAME}_${TRAVIS_BRANCH}_${GOOS}_${GOARCH}${GOARM} +fi + +tar -czf dist/${FILE}.tgz ${NAME} + +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 + 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 +fi