Skip to content

Commit

Permalink
Travis CI: build Debian packages
Browse files Browse the repository at this point in the history
fixes #3
  • Loading branch information
Al2Klimov committed Sep 22, 2018
1 parent 4efb080 commit fffa070
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
87 changes: 87 additions & 0 deletions .travis-ci/mk-pkgs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash

set -e
set -o pipefail
set -x


function mkDeb {
ARGS=("$@")

GO_ARCH="${ARGS[0]}"
DEB_ARCH="${ARGS[1]}"
GO_ENV=('GOOS=linux' "GOARCH=$GO_ARCH" "${ARGS[@]:2}")

GO_OUT="$(echo "${GO_ENV[@]}")"
GO_OUT="${GO_OUT//=/_}"
GO_OUT="${BIN_CACHE}/${GO_OUT// /-}.bin"

echo "$DEB_ARCH"

if ! [ -e "$GO_OUT" ]; then
for e in "${GO_ENV[@]}"; do
export $e
done

go build -o "$GO_OUT" .
fi

cp "$GO_OUT" "pkgroot/usr/sbin/masif-upgrader-agent"

rm -f pkgpayload.tar

pushd pkgroot

tar -cf ../pkgpayload.tar *

popd

fpm -s tar -t deb --log debug --verbose --debug \
-n "$PKG_NAME" \
-v "$PKG_VERSION" \
-a "$DEB_ARCH" \
-m 'Alexander A. Klimov <[email protected]>' \
--description 'The Masif Upgrader agent is a component of Masif Upgrader.
Consult Masif Upgrader'"'"'s manual on its purpose and the agent'"'"'s role in its architecture:
https://github.com/masif-upgrader/manual' \
--url 'https://github.com/masif-upgrader/agent' \
-p "${PKG_NAME}-${PKG_VERSION}-${DEB_ARCH}.deb" \
-d apt -d bash -d systemd --no-auto-depends \
--config-files /etc/masif-upgrader/agent.ini \
--after-install packaging/daemon-reload.sh --after-upgrade packaging/daemon-reload.sh --after-remove packaging/daemon-reload.sh \
pkgpayload.tar
}


export BIN_CACHE="$(mktemp -d)"
export PKG_VERSION="$(git describe)"
export PKG_VERSION="${PKG_VERSION/v/}"
export PKG_NAME="masif-upgrader-agent"

mkdir -p pkgroot/usr/sbin
mkdir -p pkgroot/etc/masif-upgrader
mkdir -p pkgroot/lib/systemd/system

cp packaging/config.ini pkgroot/etc/masif-upgrader/agent.ini
cp packaging/systemd.service pkgroot/lib/systemd/system/masif-upgrader-agent.service


go generate

mkDeb amd64 amd64 GO386=387
mkDeb 386 i386 GO386=387

mkDeb mips mips GOMIPS=softfloat
mkDeb mipsle mipsel GOMIPS=softfloat
mkDeb mips64le mips64el

mkDeb ppc64le ppc64el
mkDeb s390x s390x

mkDeb arm armel GOARM=5
mkDeb arm armhf GOARM=7
mkDeb arm64 arm64

mkDeb arm armv6l GOARM=6
mkDeb arm armv7l GOARM=7
mkDeb arm64 aarch64
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: go

go:
- "1.x"
- master

before_script:
- gem install fpm

script:
- .travis-ci/mk-pkgs.sh

deploy:
provider: releases
api_key:
secure: Xma3nJjkAt7/nCO7zoAdw36Wnd0ACuUhxxrMeHqStMU4zMZjCkCZX49tAbq2fvscpcYPnjlJSZvSDQqEzZ9PbwTuON5T3uqOB3OTjysfB2pc1zzxcMgj5coJ/p+pQiiAe/5Y9J81e6JNFycb2L+yGPDE2uYR7V8Wef7tQGxj3GHAMpZckQLiApWCv7lFdOfT16OCYjvasfOssZ53DKZMTmbPvcyftGbDYm69o+Db7cb8Z/RAvbKvHUqoToiFpjLv0ZIIiOHkkep1qGrVnsjF8ftjuajBS0tKc+OL0Lpd5U08HTSJvn7L5V4Z4RYb1yNYMZLEsDo33qIWgWQIyYKiwFW5A+5aITrWnIawNAocEPkdIbOkpx8f0cGC/KFfgryI9qjbNBNaELjS+bLRXEafceGuOLUaqR4wAHNbFKg7lFhbN8ygt4DaTL0M+a49bPbOfMJ7IHMER6qxkVo+AP648hfMR21chzBBeSnG6TNO4HDLrbJHbCGt7RoEPOYlq4+o2soE3XoZCRAu1aM5otz81rxELuJzBw2ZTlax8/xjX23r7gnaEPaU9ECqghfz2P+u9zrPkap1xoQSZecqw+WXXbmJovr2k7ZBwQZb9moZZ/2cJHAhLyEMN1/Yc/k8xEa/2qNW8A6ikkswPoTeZVBIq5vfs2FcDN9bw++581MOGOQ=
file_glob: true
file: masif-*.deb
skip_cleanup: true
on:
tags: true
go: "1.x"
12 changes: 12 additions & 0 deletions packaging/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[interval]
check=
report=
retry=

[master]
host=

[tls]
cert=
key=
ca=
3 changes: 3 additions & 0 deletions packaging/daemon-reload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
set -e
exec /bin/systemctl daemon-reload
14 changes: 14 additions & 0 deletions packaging/systemd.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Unit]
Description=Masif Upgrader (agent)
After=syslog.target

[Service]
ExecStart=/usr/sbin/masif-upgrader-agent --config /etc/masif-upgrader/agent.ini
StandardOutput=syslog
StandardError=syslog
KillMode=process
TimeoutStopSec=infinity
Restart=always

[Install]
WantedBy=multi-user.target

0 comments on commit fffa070

Please sign in to comment.