Commit 3801ca23 authored by Kamil Trzciński's avatar Kamil Trzciński 🔴 Committed by Kamil Trzciński

Added deb and rpm creation for sysv, upstart and systemd

parent f3e90501
......@@ -2,18 +2,26 @@ sudo: false
language: go
go:
- '1.4'
env:
global:
secure: COMQYKj9O6GUuoDRa5OVfOT8i4m1f/JDH6LaGLI8Nkb84oaq9fgvpjVMBgUcWbYT52UXt3NNy7N8B3d8VEmCHvBIjZh296OhHsAvFf9hvcjx5POjKXODV1rwdgtyYafaLUPllCBe/lLKn819ktD3PB1tjxQ0//r4APW82W4wpYs=
install:
- go get github.com/tools/godep
- godep restore
before_script:
- echo -e "package commands\n\nconst VERSION = \"${TRAVIS_TAG:-$TRAVIS_BRANCH} ($(git rev-parse --short HEAD))\"\n" > commands/version.go
- cat commands/version.go | grep VERSION
- make version
script:
- make test
before_deploy:
- go get github.com/mitchellh/gox
- gox -build-toolchain -os="linux" -os="darwin" -os="windows"
- gem install package_cloud
- gem install fpm
- make build
- make deb
- make rpm
- make packagecloud-deb
- make packagecloud-rpm
deploy:
provider: releases
api_key:
......
NAME := gitlab-ci-multi-runner
REVISION := $(shell git rev-parse --short HEAD || echo unknown)
VERSION := $(shell git describe --tags || cat VERSION || echo dev)
VERSION := $(shell echo $(VERSION) | sed -e 's/^v//g')
ITTERATION := $(shell date +%s)
all: build
build:
......@@ -15,3 +21,66 @@ deploy2:
gox -osarch="linux/amd64" -output="out/{{.Dir}}-{{.OS}}-{{.Arch}}"
scp out/gitlab-ci-multi-runner-linux-amd64 gitlab_ci_runner@lab-docker:
ssh gitlab_ci_runner@lab-docker ./gitlab-ci-multi-runner-linux-amd64 --debug run
version: FORCE
echo "package commands\n\nconst VERSION = \"$(VERSION) ($(REVISION))\"\nconst REVISION = \"$(REVISION)\"" > commands/version.go
deb:
make build-deb ARCH=amd64 TYPE=sysv
make build-deb ARCH=386 TYPE=sysv
make build-deb ARCH=amd64 TYPE=upstart
make build-deb ARCH=386 TYPE=upstart
make build-deb ARCH=amd64 TYPE=systemd
make build-deb ARCH=386 TYPE=systemd
rpm:
make build-rpm ARCH=amd64 TYPE=systemd
make build-rpm ARCH=386 TYPE=systemd
build-deb:
mkdir -p out/deb/$(TYPE)/$(ARCH)/
fpm -s dir -t deb -n $(NAME) -v $(VERSION) \
-p out/deb/$(TYPE)/$(ARCH)/$(NAME).deb \
--deb-priority optional --category admin \
--force \
--deb-compression bzip2 \
--after-install packaging/$(TYPE)/scripts/postinst.deb \
--before-remove packaging/$(TYPE)/scripts/prerm.deb \
--url https://github.com/ayufan/gitlab-ci-multi-runner \
--description "GitLab CI Multi-purpose Runner" \
-m "Kamil Trzciński <ayufan@ayufan.eu>" \
--license "MIT" \
--vendor "ayufan.eu" \
-a $(ARCH) \
--config-files /etc/default/gitlab-ci-multi-runner \
out/gitlab-ci-multi-runner-linux-$(ARCH)=/usr/bin/gitlab-ci-multi-runner \
packaging/$(TYPE)/root/=/
build-rpm:
mkdir -p out/rpm/$(TYPE)/$(ARCH)/
fpm -s dir -t rpm -n $(NAME) -v $(VERSION) \
-p out/rpm/$(TYPE)/$(ARCH)/$(NAME).rpm \
--rpm-compression bzip2 --rpm-os linux \
--force \
--deb-compression bzip2 \
--after-install packaging/$(TYPE)/scripts/postinst.rpm \
--before-remove packaging/$(TYPE)/scripts/prerm.rpm \
--url https://github.com/ayufan/gitlab-ci-multi-runner \
--description "GitLab CI Multi-purpose Runner" \
-m "Kamil Trzciński <ayufan@ayufan.eu>" \
--license "MIT" \
--vendor "ayufan.eu" \
-a $(ARCH) \
out/gitlab-ci-multi-runner-linux-$(ARCH)=/usr/bin/gitlab-ci-multi-runner \
packaging/$(TYPE)/root/=/
packagecloud-deb:
package_cloud push ayufan/gitlab-ci-multi-runner/debian/wheezy out/deb/sysv/*/*.deb
package_cloud push ayufan/gitlab-ci-multi-runner/debian/jessie out/deb/systemd/*/*.deb
package_cloud push ayufan/gitlab-ci-multi-runner/ubuntu/trusty out/deb/upstart/*/*.deb
package_cloud push ayufan/gitlab-ci-multi-runner/ubuntu/utopic out/deb/systemd/*/*.deb
packagecloud-rpm:
package_cloud push ayufan/gitlab-ci-multi-runner/centos/7 out/rpm/systemd/*/*.deb
FORCE:
......@@ -31,7 +31,52 @@ This project was made as Go learning opportunity. The initial release was create
* Easy to use setup with support for docker, docker-ssh, parallels or ssh running environments
* Enables caching of Docker containers
### Install and initial configuration
### Install and initial configuration (For Debian and Ubuntu)
1. If you want to use Docker runnner install it before:
```bash
curl -sSL https://get.docker.com/ | sh
```
1. Add package to apt-get
```bash
curl https://packagecloud.io/install/repositories/ayufan/gitlab-ci-multi-runner/script.deb | sudo bash
```
1. Install `gitlab-ci-multi-runner`
```bash
apt-get install gitlab-ci-multi-runner
```
1. Setup the runner
```bash
$ cd ~gitlab_ci_multi_runner
$ gitlab-ci-multi-runner-linux setup
Please enter the gitlab-ci coordinator URL (e.g. http://gitlab-ci.org:3000/ )
https://ci.gitlab.org/
Please enter the gitlab-ci token for this runner
xxx
Please enter the gitlab-ci description for this runner
my-runner
INFO[0034] fcf5c619 Registering runner... succeeded
Please enter the executor: shell, docker, docker-ssh, ssh?
docker
Please enter the Docker image (eg. ruby:2.1):
ruby:2.1
INFO[0037] Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!
```
1. You are ready to build your projects!
#### Update
1. Simply execute to install latest version
```bash
apt-get update
apt-get install gitlab-ci-multi-runner
```
### Install and initial configuration (For other systems)
1. Simply download one of this binaries for your system:
```bash
......@@ -295,6 +340,7 @@ TBD
### Future
* It should be simple to add additional executors: DigitalOcean? Amazon EC2?
* Deb package
* Tests!
### Author
......
#
# systemd unit file for CentOS 7, Ubuntu bleeding edge
#
[Unit]
Description=GitLab CI-Multi Runner
# start us only once the network and logging subsystems are available
After=syslog.target network.target
# See these pages for lots of options:
# http://0pointer.de/public/systemd-man/systemd.service.html
# http://0pointer.de/public/systemd-man/systemd.exec.html
[Service]
Type=simple
User=gitlab_ci_multi_runner
Group=gitlab_ci_multi_runner
WorkingDirectory=/home/gitlab_ci_multi_runner
ExecStart=/usr/bin/gitlab-ci-multi-runner run
# if we crash, restart
RestartSec=1
Restart=on-failure
# use syslog for logging
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=gitlab-ci-multi-runner
[Install]
WantedBy=multi-user.target
#!/bin/sh
set -e
case "$1" in
abort-upgrade|abort-remove|abort-deconfigure)
;;
configure)
if ! id -u gitlab_ci_multi_runner >/dev/null 2>/dev/null; then
adduser --disabled-login --gecos 'GitLab CI Multi Runner' gitlab_ci_multi_runner
fi
usermod -aG docker gitlab_ci_multi_runner || true
touch ~gitlab_ci_multi_runner/config.toml
chown gitlab_ci_multi_runner:gitlab_ci_multi_runner ~gitlab_ci_multi_runner/config.toml
chmod 0600 ~gitlab_ci_multi_runner/config.toml
if which systemctl > /dev/null; then
systemctl daemon-reload || :
systemctl enable gitlab-ci-multi-runner || :
systemctl restart gitlab-ci-multi-runner || :
else
echo "Couldn't find systemd to control GitLab CI Multi Runner, cannot proceed."
echo "Open an issue and tell us about your system."
exit 1
fi
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0
#!/bin/sh
set -e
if ! id -u gitlab_ci_multi_runner >/dev/null 2>/dev/null; then
adduser --disabled-login --gecos 'GitLab CI Multi Runner' gitlab_ci_multi_runner
fi
usermod -aG docker gitlab_ci_multi_runner || true
touch ~gitlab_ci_multi_runner/config.toml
chown gitlab_ci_multi_runner:gitlab_ci_multi_runner ~gitlab_ci_multi_runner/config.toml
chmod 0600 ~gitlab_ci_multi_runner/config.toml
if which systemctl > /dev/null; then
systemctl daemon-reload || :
systemctl enable gitlab-ci-multi-runner || :
systemctl restart gitlab-ci-multi-runner || :
else
echo "Couldn't find systemd to control GitLab CI Multi Runner, cannot proceed."
echo "Open an issue and tell us about your system."
exit 1
fi
exit 0
#!/bin/sh
set -e
if [ $1 = "remove" ] ; then
if which systemctl > /dev/null; then
systemctl --no-reload disable gitlab-ci-multi-runner || :
systemctl stop gitlab-ci-multi-runner || :
fi
fi
#!/bin/sh
set -e
if which systemctl > /dev/null; then
systemctl --no-reload disable gitlab-ci-multi-runner || :
systemctl stop gitlab-ci-multi-runner || :
fi
#! /bin/bash
### BEGIN INIT INFO
# Provides: gitlab-ci-multi-runner
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: GitLab CI-Multi Runner init.d script
# Description: Enables automatic start of runners at boot time in the background.
### END INIT INFO
DESC="GitLab CI-Multi Runner"
USER="gitlab_ci_multi_runner"
GROUP="gitlab_ci_multi_runner"
CHDIR="~$USER"
NAME="gitlab-ci-multi-runner"
DAEMON="/usr/bin/gitlab-ci-multi-runner"
PIDFILE="/var/run/gitlab-ci-multi-runner.pid"
LOGFILE="/var/log/gitlab-ci-multi-runner.log"
# Exit if the package is not installed
if [ ! -x "$DAEMON" ]; then
echo "$DAEMON not present or not executable"
exit 1
fi
# Read configuration variable file if it is present
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
# Define LSB log_* functions.
. /lib/lsb/init-functions
## Check to see if we are running as root first.
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root"
exit 1
fi
eval CHDIR=$CHDIR
do_start() {
start-stop-daemon --start \
--pidfile "$PIDFILE" \
--chdir "$CHDIR" \
--background \
--make-pidfile \
--chuid "$USER:$GROUP" \
--no-close \
--exec "$DAEMON" -- "run" &>> $LOGFILE
}
do_stop() {
start-stop-daemon --stop --pidfile "$PIDFILE" --user "$USER" --exec "$DAEMON" --quiet
}
case "$1" in
start)
log_daemon_msg "Starting $DESC"
do_start
log_end_msg $?
;;
stop)
log_daemon_msg "Stopping $DESC"
do_stop
log_end_msg $?
;;
restart)
$0 stop
$0 start
;;
status)
status_of_proc -p "$PIDFILE" "$DAEMON" "$DESC"
;;
*)
echo "Usage: sudo service gitlab-ci-multi-runner {start|stop|restart|status}" >&2
exit 1
;;
esac
exit 0
#!/bin/sh
set -e
case "$1" in
abort-upgrade|abort-remove|abort-deconfigure)
;;
configure)
if ! id -u gitlab_ci_multi_runner >/dev/null 2>/dev/null; then
adduser --disabled-login --gecos 'GitLab CI Multi Runner' gitlab_ci_multi_runner
fi
usermod -aG docker gitlab_ci_multi_runner || true
touch ~gitlab_ci_multi_runner/config.toml
chown gitlab_ci_multi_runner:gitlab_ci_multi_runner ~gitlab_ci_multi_runner/config.toml
chmod 0600 ~gitlab_ci_multi_runner/config.toml
service gitlab-ci-multi-runner start || :
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0
#!/bin/sh
set -e
service gitlab-ci-multi-runner stop || :
# Upstart configuration file for gitlab-ci-multi-runner
# Control with:
#
# sudo service gitlab-ci-multi-runner start
#
description "GitLab CI-Multi Runner upstart script"
author "Kamil Trzcinski <ayufan@ayufan.eu>"
start on runlevel [2345]
# Always restart the runner if it dies / exits
respawn
# Log to /var/log/upstart/
console log
# Run the process as gitlab_ci_runner:gitlab_ci_runner
setuid gitlab_ci_multi_runner
setgid gitlab_ci_multi_runner
# This is where you installed the gitlab-ci-runner source code
chdir /home/gitlab_ci_multi_runner/
script
# optional: set PATH or other environment variables
# export PATH=/home/gitlab_ci_runner/.rvm/rubies/default/bin:$PATH
export HOME=/home/gitlab_ci_multi_runner
exec /usr/bin/gitlab-ci-multi-runner run
end script
#!/bin/sh
set -e
case "$1" in
abort-upgrade|abort-remove|abort-deconfigure)
;;
configure)
if ! id -u gitlab_ci_multi_runner >/dev/null 2>/dev/null; then
adduser --disabled-login --gecos 'GitLab CI Multi Runner' gitlab_ci_multi_runner
fi
usermod -aG docker gitlab_ci_multi_runner || true
touch ~gitlab_ci_multi_runner/config.toml
chown gitlab_ci_multi_runner:gitlab_ci_multi_runner ~gitlab_ci_multi_runner/config.toml
chmod 0600 ~gitlab_ci_multi_runner/config.toml
initctl start gitlab-ci-multi-runner || :
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0
#!/bin/sh
set -e
initctl stop gitlab-ci-multi-runner || :
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment