# ---------------------------------------------------------------------------- #
## \file gitlab-ci.yml
## \author Sebastien Beaugrand
## \sa http://beaugrand.chez.com/
## \copyright CeCILL 2.1 Free Software license
# ---------------------------------------------------------------------------- #
variables:
  PROJECT: libsimple-amqp-client
  VERSION: 2.5.1
include:
  - local: /../makefiles/package.yml
build:
  stage: build
  variables:
    URL: https://github.com/alanxz/SimpleAmqpClient/archive/refs/tags
    TGZ: v$VERSION.tar.gz
  script:
    - mkdir -p build
    - cd build
    - test -f $TGZ || curl -OL $URL/$TGZ
    - test -d SimpleAmqpClient-$VERSION || tar xzf $TGZ
    - cmake SimpleAmqpClient-$VERSION
    - make --no-print-directory clean
    - make --no-print-directory -j`nproc`
package:
  stage: package
  script:
    - export DEBEMAIL=`git config --global --get user.email`
    - export DEBFULLNAME=`git config --global --get user.name`
    - mkdir -p build/$PROJECT-$VERSION/data
    - cd build/$PROJECT-$VERSION
    - dh_make --native --single --yes || true
    - cat /dev/null >debian/$PROJECT.install
    - test ! -d ../../debian || cp -a ../../debian/* debian/
    - |
      sed -i '/^Description: /,${d}' debian/control
    - |
      echo 'Description: Simple C++ Interface to rabbitmq-c' >>debian/control
    - |
      echo ' SimpleAmqpClient is an easy-to-use C++ wrapper around the rabbitmq-c C library.
       It derives inspiration from the puka AMQP library in that it abstracts away the
       underlying AMQP wire concept of channels and uses them as an error/consumer scope.
       This should make writing simple single-threaded AMQP-enabled apps easy.' >>debian/control
    - |
      sed -i 's/Section: .*/Section: libdevel/' debian/control
    - |
      sed -i 's#Homepage: .*#Homepage: https://github.com/alanxz/SimpleAmqpClient#' debian/control
    - find .. -maxdepth 1 -type f -name "*.so*" -exec cp -a {} data/ \;
    - cp -a ../SimpleAmqpClient-$VERSION/src/SimpleAmqpClient/*.h data/
    - cp -a ../*.pc data/
    - SOURCE_DATE_EPOCH=`date +%s` dpkg-buildpackage --no-sign