Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added makefile/package/travis config
- Loading branch information
1 parent
0ecb896
commit de82769
Showing
8 changed files
with
180 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Folders | ||
bin | ||
build | ||
|
||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
language: go | ||
sudo: required | ||
services: | ||
- docker | ||
go: | ||
- 1.7 | ||
env: | ||
global: | ||
- GOARCH=amd64 | ||
before_deploy: make ci | ||
deploy: | ||
provider: releases | ||
api_key: | ||
secure: IFy47qRhLVBND/gQskxy0+r8DVxKFe0xUQNocjNQWqjQT37lelnkBGDITjdlxco0sOgwhB71fA3xf2PD2WhAPxD2NHBGfTYvc9SrnaBUVFAAItMaX1C31NMnxwhWIQfT9UHeRSOLoIGZEkvIoFAtnOZDcaQC+rqI0fJtJ9ax7EvZoxUTxUhjrTbwUv3mDP5cYtJST657OIyXWwEGI1LGS9w9J8GZSXv7Uh0AjCbT8pTWtzg/Ixb7BlzGqtkE6tk6QbR/U8L5zB01D3hwbtCrhwW0B3UFAIe8EvJ28ql1vYfOojb8e4QTPTUDqJM05+0br8zhJ+DmuOrFQh68fpzMI9akxRsiX3lX/gs3H8x0IGL0LnN5xoNRXzoPEp+kE6ATUK2mE/ayoC087IthxdACK/xjdo2/ebqNcaO2cDdHHYyEE1Dl7QJ0zbHp2DAK72IMQlGrAVRIep0aS4lWtLHkycBWw29GutpujrMnSREOC/7KRDd4cALKRC+Nw3tesmSytOHdeR0WatIFdv1pF81Nqy7XBKQC8+Vnievx3Yb1lIzFzn5G06OtGJNXQ2YMpDsU9jLbCWrSp/Jpwsz38Y7vf70DZGxpqAR3lozR+dMBVuX/3CzHi0zekDCDuu5DS0XspuXQwd7pN2s0ap6gUaev3q3sOf9VBbV1fnHzOBgYFCs= | ||
file_glob: true | ||
file: | ||
- "build/rpm/*.rpm" | ||
- "build/tgz/*.tar.gz" | ||
skip_cleanup: true | ||
on: | ||
tags: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
GOTOOLS=github.com/mitchellh/gox/... | ||
|
||
NAME=cloudmonitor_exporter | ||
|
||
VERSION=0.1.3 | ||
BUILD_TIME=`date '+%F%T%z'` | ||
|
||
LDFLAGS=-ldflags "-X main.version=${VERSION} -X main.buildtime=${BUILD_TIME}" | ||
|
||
all: tools build | ||
|
||
build: | ||
@mkdir -p bin/ | ||
go build ${LDFLAGS} -o bin/${NAME} ${NAME}.go | ||
|
||
xbuild: clean | ||
@mkdir -p build | ||
gox \ | ||
-os="linux" \ | ||
-os="windows" \ | ||
-os="darwin" \ | ||
-arch="amd64" \ | ||
${LDFLAGS} \ | ||
-output="build/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)" | ||
|
||
package: xbuild | ||
$(eval FILES := $(shell ls build)) | ||
@mkdir -p build/tgz | ||
for f in $(FILES); do \ | ||
(cd $(shell pwd)/build && tar -zcvf tgz/$$f.tar.gz $$f); \ | ||
echo $$f; \ | ||
done | ||
|
||
clean: | ||
@rm -rf bin/ && rm -rf build/ | ||
|
||
tools: | ||
go get -u -v $(GOTOOLS) | ||
|
||
rpm: | ||
@mkdir -p build/rpm | ||
docker run --rm -it -v $(shell pwd):/docker centos:7 /docker/package/rpm/build_rpm.sh ${VERSION} | ||
|
||
ci: tools package rpm | ||
|
||
|
||
.PHONY: all build clean ci tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
os=$(uname) | ||
os=${os,,} | ||
arch=$(uname -m) | ||
[[ $arch == "x86_64" ]] && arch="amd64" | ||
|
||
package="cloudmonitor_exporter" | ||
echo "Provisioning started, installing packages..." | ||
yum -y install rpmdevtools mock | ||
|
||
echo "Setting up rpm dev tree..." | ||
rpmdev-setuptree | ||
|
||
echo "Copying files for build..." | ||
cp /docker/package/rpm/$package.spec $HOME/rpmbuild/SPECS/ | ||
find /docker/package/sources -type f -exec cp -f {} $HOME/rpmbuild/SOURCES/ \; | ||
cp /docker/build/${package}_${1}_${os}_${arch}/${package} $HOME/rpmbuild/SOURCES/${package} | ||
cd ${HOME} | ||
chown -R root:root rpmbuild | ||
echo "Downloading dependencies..." | ||
spectool -g -R rpmbuild/SPECS/$package.spec | ||
|
||
echo "Building rpm..." | ||
rpmbuild -ba --define "_version ${1}" rpmbuild/SPECS/$package.spec | ||
|
||
echo "Copying rpms back to build folder...." | ||
cp -f ${HOME}/rpmbuild/RPMS/x86_64/*.rpm /docker/build/rpm/ | ||
chmod 777 /docker/build/rpm/* | ||
|
||
echo "Successfully built RPM for version ${1}:" | ||
ls -altrh /docker/build/rpm/ | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
Name: cloudmonitor_exporter | ||
Version: %{_version} | ||
Release: 1 | ||
Summary: Prometheus exporter for Akamai Cloudmonitor. | ||
Group: System Environment/Daemons | ||
License: Apache Software License | ||
URL: https://github.com/ExpressenAB/cloudmonitor_exporter | ||
Source0: %{name} | ||
Source1: %{name}.service | ||
Source2: %{name}.sysconfig | ||
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) | ||
|
||
%description | ||
Prometheus exporter for Akamai Cloudmonitor. | ||
|
||
%install | ||
mkdir -p %{buildroot}/%{_sbindir} | ||
cp %{SOURCE0} %{buildroot}/%{_sbindir}/%{name} | ||
|
||
mkdir -p %{buildroot}/%{_sysconfdir}/sysconfig | ||
cp %{SOURCE2} %{buildroot}/%{_sysconfdir}/sysconfig/%{name} | ||
|
||
mkdir -p %{buildroot}/%{_unitdir} | ||
cp %{SOURCE1} %{buildroot}/%{_unitdir}/ | ||
|
||
%post | ||
%systemd_post %{name}.service | ||
|
||
%preun | ||
%systemd_preun %{name}.service | ||
|
||
%postun | ||
%systemd_postun_with_restart %{name}.service | ||
|
||
%clean | ||
rm -rf %{buildroot} | ||
|
||
|
||
%files | ||
%defattr(-,root,root,-) | ||
%config(noreplace) %{_sysconfdir}/sysconfig/%{name} | ||
%{_unitdir}/%{name}.service | ||
%attr(755, root, root) %{_sbindir}/* | ||
|
||
%doc | ||
|
||
|
||
%changelog | ||
* Mon Dec 4 2016 Rickard Karlsson <rickard.karlsson@bonniernews.se> | ||
- Release 0.1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Cloudmonitor_exporter | ||
Documentation=https://github.com/ExpressenAB/cloudmonitor_exporter/ | ||
After=network-online.target | ||
Wants=network-online.target | ||
|
||
[Service] | ||
EnvironmentFile=-/etc/sysconfig/cloudmonitor_exporter | ||
ExecStart=/usr/sbin/cloudmonitor_exporter $CMD_OPTS | ||
ExecReload=/bin/kill -HUP $MAINPID | ||
KillSignal=SIGINT | ||
Restart=on-failure | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# | ||
# Add specific environment variables here for cloudmonitor_exporter | ||
# |