Skip to content

Commit

Permalink
Travis CI: build Debian packages
Browse files Browse the repository at this point in the history
fixes #5
  • Loading branch information
Al2Klimov committed Sep 22, 2018
1 parent f34d676 commit 6f46e72
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-master"

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 master is a component of Masif Upgrader.
Consult Masif Upgrader'"'"'s manual on its purpose and the master'"'"'s role in its architecture:
https://github.com/masif-upgrader/manual' \
--url 'https://github.com/masif-upgrader/master' \
-p "${PKG_NAME}-${PKG_VERSION}-${DEB_ARCH}.deb" \
-d bash -d systemd --no-auto-depends \
--config-files /etc/masif-upgrader/master.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-master"

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/master.ini
cp packaging/systemd.service pkgroot/lib/systemd/system/masif-upgrader-master.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: F73BchrcJ7nfQT2LRlPyn1SYNBDFV2R/HzBjrR6a8tstkFnJYGXrFY44sWYAiMfont+3MaPb3zU8+qJTwvqvYrOwoWOSNu4ZO8x8Sc74rP+dP7c4/xpTTT3z3TcAouEmo5+yeE7sGBkVEux3v7CRZ4ejNnqHCydsIvuOdcj5IXILanEEknyYQ4x3ckBnAaZiDjgPyuh70IkllQaYfo/a4V3gV2FMbpQdMGEJnNxoXpgt8tKtkd7B91Lhn5fEVurchn8nYczwOzuN/vSkEpkecOZnPTUShJqREX9LjTbHmg2P++1uNLcsduhhE/lksacCcCUkVU1VKHyoZpVNZRVTYWmFW7nkvJFlc/RR9puTx/4u5UIQc3twg2dg1lNLBSqsQ4al371xlwKinOwMqmuo+ogJwOT/AlzyH1QXPYVdEpXEM5L6AUYhbMZBBOML0oj8LvRQdakOQOgQui5zK1nNyHpbnLKkOmO0gdMGuxaUEjuWKqbGjy4x1+Qqa8jl5MUWGYC11owyNeBVJ+9pD4478ILJKAgwDNMY1qr7CksNDQJSmbnPSiIHa8un4WsUZPnfF2UJalUAIMmlLM8aUCgH6XYnPcV8KrKIALXjzafBruloT/nQbL1y/DZkkRNBGzHKyTghO6SkTeBJPBjcSET+TxaLkTgOPON0ZkyLqeuKSUE=
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 @@
[api]
listen=0.0.0.0:8150

[tls]
cert=
key=
ca=
crl=

[db]
type=mysql
dsn=
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 (master)
After=syslog.target

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

[Install]
WantedBy=multi-user.target

0 comments on commit 6f46e72

Please sign in to comment.