include:
    - project: "AlekSIS/official/AlekSIS"
      file: /ci/general.yml
    - project: "AlekSIS/official/AlekSIS"
      file: /ci/prepare/lock.yml
    - project: "AlekSIS/official/AlekSIS"
      file: /ci/test/security.yml
    - project: "AlekSIS/official/AlekSIS"
      file: /ci/build/dist.yml
    - project: "AlekSIS/official/AlekSIS"
      file: /ci/docker/dist.yml

variables:
  GIT_SUBMODULE_STRATEGY: recursive
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
  FF_NETWORK_PER_BUILD: "true"
  POETRY_REPOSITORIES_GITLAB_URL: "$CI_API_V4_URL/projects/${CI_PROJECT_ID}/packages/pypi"
  POETRY_HTTP_BASIC_GITLAB_USERNAME: gitlab-ci-token
  POETRY_HTTP_BASIC_GITLAB_PASSWORD: "$CI_JOB_TOKEN"
  POETRY_PYPI_TOKEN_PYPI: "$TICDESK_PUBLISH_TOKEN"

deploy_gitlab:
  interruptible: true
  stage: publish
  script:
    - if [ x$CI_COMMIT_REF_NAME = x$CI_COMMIT_TAG ]; then
       if ! [ "$(poetry version | cut -d" " -f2)" = $CI_COMMIT_REF_NAME ]; then
        echo "Package version does not match tag. Aborting build of tag!" >/dev/fd/2 ;
        exit 1 ;
       fi ;
      else
       poetry version $(poetry version | cut -d" " -f2)+$(date --date=${CI_COMMIT_TIMESTAMP} +%Y%m%d%H%M%S).${CI_COMMIT_SHORT_SHA} ;
      fi
    - poetry publish -r gitlab
