From 60bd564519213d5b6ce53f44d1ece7c667a617d2 Mon Sep 17 00:00:00 2001 From: AlexAkulov Date: Fri, 25 Mar 2016 21:10:44 +0500 Subject: [PATCH] create packages on travis --- .gitignore | 1 + .travis.yml | 50 ++++++++++++++++++---------- Makefile | 33 ++++++++++++++---- pkg/{rpm => }/moira-notifier.service | 0 pkg/{rpm => }/postinst | 0 5 files changed, 60 insertions(+), 24 deletions(-) rename pkg/{rpm => }/moira-notifier.service (100%) rename pkg/{rpm => }/postinst (100%) mode change 100755 => 100644 diff --git a/.gitignore b/.gitignore index 8c0417a..57f80be 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ notifier/notifier .coverprofile build/ +.vscode diff --git a/.travis.yml b/.travis.yml index c33c283..e2726d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,7 @@ language: go -sudo: false go: - - 1.4 - - 1.5 + - 1.5.3 - 1.6 -before_install: - - make prepare - - go get github.com/axw/gocov/gocov - - go get github.com/mattn/goveralls - - go get golang.org/x/tools/cmd/cover - - go get github.com/modocache/gover - - go get github.com/golang/lint/golint -script: - - go vet -x ./... - - golint ./... - - cd tests - - ginkgo -r --randomizeAllSpecs -cover --failOnPending -coverpkg=../ --trace --race - - gover - - goveralls -coverprofile=gover.coverprofile -service=travis-ci notifications: webhooks: urls: @@ -25,3 +9,35 @@ notifications: on_success: change on_failure: always on_start: never +before_install: + - sudo apt-get install -y rpm + - gem install fpm + - go get github.com/axw/gocov/gocov + - go get github.com/mattn/goveralls + - go get golang.org/x/tools/cmd/cover + - go get github.com/modocache/gover + - go get github.com/golang/lint/golint +install: + - go vet -x ./... + - golint ./... + - make test + - gover + - goveralls -coverprofile=gover.coverprofile -service=travis-ci +script: + - make packages +before_deploy: + - export RELEASE_PKG_TAR=$(ls build/moira-notifier*.tar.gz) + - export RELEASE_PKG_RPM=$(ls build/moira-notifier*.rpm) + - export RELEASE_PKG_DEB=$(ls build/moira-notifier*.deb) +deploy: + provider: releases + api_key: + secure: kuNhaWPMfrzfLblZShTW6qD8K88l2Gmwc1AcmW74LqpqIgzjAP33DVvRP2vHLpRE1tDWB+79k1Z6sKEij+tbQfJ+KI31dzcLxB3TtCqnaxX3wa6oTlgvv3lVWJavKIZ4I9W8EJqQUa+FTIoAuTPpr8hNh5STCIztPmVX0uAJ+RpcNhiP/rJGL+Q7CFUmkJSc9i4wztULMVb1W/zBDYKFc8c49yb9ZkrqbCLLXr9itlMRSx5Dhpq/ad6rIXcrcpTL5Qf2Bs0TluSjl0dow2wbQuQci/DcG0gSDZIsaT3FOtBjDK1oc5hkQfzkMumZIBj4AHue0rtag61OfdDzvQUJe6WwCLfhtCYyqi1I7VE2wPK5WoroRB9S8aBn0UOWbnef3gXnXZhJisMhsXOaElKddKs1Sz1OvzVwe1vRWDAThjQmG59iQaTql9W26qhPc4ATr87PTWrFJZVe3Ty8++pU9yAxGCiGoNG1SVAwz382b0GtkOkrGDCLNukek+pI/MZEAc4eMbejIFoX5WgR2k34ANBOry1gBB/TMPvEhSzxogzg4YHjeuz1Y04g/O8PHJudlMe1BtX3b7ZdBEAY/4fC5oCz0sVi08uEiC/CG5CcpVHmXgWNPipJDvr9EnFnM5HLujxyDSM/WvHUx2VtPigQKG8aUILt05McO9FCHEESkIE= + file: + - "${RELEASE_PKG_TAR}" + - "${RELEASE_PKG_RPM}" + - "${RELEASE_PKG_DEB}" + skip_cleanup: true + on: + tags: true + condition: $TRAVIS_GO_VERSION = 1.5.3 diff --git a/Makefile b/Makefile index f45f015..3ad8f3b 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ build: go build -ldflags "-X main.Version=$(VERSION)-$(RELEASE)" -o build/moira-notifier github.com/moira-alert/notifier/notifier test: prepare - ginkgo -r --randomizeAllSpecs --randomizeSuites --failOnPending --trace --race --progress tests + ginkgo -r --randomizeAllSpecs --randomizeSuites -cover -coverpkg=../ --failOnPending --trace --race --progress tests .PHONY: test @@ -22,25 +22,44 @@ prepare: clean: rm -rf build -rpm: clean build +tar: mkdir -p build/root/usr/local/bin mkdir -p build/root/usr/lib/systemd/system mkdir -p build/root/etc/logrotate.d/ mv build/moira-notifier build/root/usr/local/bin/ - cp pkg/rpm/moira-notifier.service build/root/usr/lib/systemd/system/moira-notifier.service + cp pkg/moira-notifier.service build/root/usr/lib/systemd/system/moira-notifier.service cp pkg/logrotate build/root/etc/logrotate.d/moira-notifier + tar -czvPf build/moira-notifier-$(VERSION)-$(RELEASE).tar.gz -C build/root . + +rpm: fpm -t rpm \ - -s "dir" \ + -s "tar" \ + --description "Moira Notifier" \ + --vendor $(VENDOR) \ + --url $(URL) \ + --license $(LICENSE) \ + --name "moira-notifier" \ + --version "$(VERSION)" \ + --iteration "$(RELEASE)" \ + --after-install "./pkg/postinst" \ + --depends logrotate \ + -p build \ + build/moira-notifier-$(VERSION)-$(RELEASE).tar.gz +deb: + fpm -t deb \ + -s "tar" \ --description "Moira Notifier" \ - -C build/root \ --vendor $(VENDOR) \ --url $(URL) \ --license $(LICENSE) \ --name "moira-notifier" \ --version "$(VERSION)" \ --iteration "$(RELEASE)" \ - --after-install "./pkg/rpm/postinst" \ + --after-install "./pkg/postinst" \ --depends logrotate \ - -p build + -p build \ + build/moira-notifier-$(VERSION)-$(RELEASE).tar.gz + +packages: clean build tar rpm deb diff --git a/pkg/rpm/moira-notifier.service b/pkg/moira-notifier.service similarity index 100% rename from pkg/rpm/moira-notifier.service rename to pkg/moira-notifier.service diff --git a/pkg/rpm/postinst b/pkg/postinst old mode 100755 new mode 100644 similarity index 100% rename from pkg/rpm/postinst rename to pkg/postinst