\subsection{Automatic deployment and roll-out}

The source code of the \textit{ESPer} project is published into a GIT repository which is provided by the Hackerspace.
To avoid interferences between different build environments on developers computers and roll out new versions as early as possible, the code has been integrated into a continuous integration (CI) system.
The CI based on \textit{drone}\autocite{drone}, provided as part of the hackerspace infrastructure, allows to execute commands on each version published into the GIT repository.
Therefore a \textit{drone} configuration file as shown in Snippet~\ref{lst:drone} has been added to the source code as \texttt{.drone.yml}.

\begin{figure}[h]
\begin{lstlisting}[language=]
build:
  image: maglab/sming
  environment:
    - CONFIG=maglab
    - WIFI_PWD=$$WIFI_PWD
    - VERSION=$${COMMIT:0:8}
  commands:
    - make clean
    - make
publish:
  sftp:
    host: eddie.maglab.space
    username: esper
    files:
      - dist/*
    destination_path: './'
    when:
      branch: master
\end{lstlisting}
\caption{The \textit{drone} configuration for the \textit{ESPer} project.}
\label{lst:drone}
\end{figure}

As shown in the configuration Snippet, the build environment includes some special settings.
First, the \texttt{CONFIG=maglab} option let the build system use \texttt{Configurion.mk.maglab} instead of the default configuration file.
This configuration file is stored inside the repository, too.
To keep the WiFi password secret, it is not written down in the configuration but mus be specified in the environment.
To include secrets into a build process while allowing to keep the configuration public, \textit{drone} allows to encrypt these with a repository specific key.
Using this method, the password is stored as \texttt{.drone.sec} file inside the repository from where it is injected into the build environment.
At last, the firmware version is configured to be made out of the first 8 letters of the GIT commit hash, which uniquely identifies a version of the source code.

For deployment, only the master branch is considered.
After a successful build, all distribution files (the binary firmware files and the version files) of all devices are copied to the machine running the home automation controller software into a directory served by a HTTP server.
The used configuration file references this server as source of updates.

