image: python:3.9-buster

variables:
  GIT_SUBMODULE_STRATEGY: recursive
  POETRY_REPOSITORIES_GITLAB_URL: "$CI_API_V4_URL/projects/257/packages/pypi"

stages:
  - build
  - publish
  - downstream

build_dist:
  interruptible: true
  stage: build
  before_script:
    - pip3 install poetry babel jinja2
    - apt -y update
    - apt -y install make
  script:
    - if ! [ x$CI_COMMIT_REF_NAME = x$CI_COMMIT_TAG ]; then
        poetry version $(poetry version | cut -d" " -f2)+$(date --date=${CI_COMMIT_TIMESTAMP} +%Y%m%d%H%M%S);
      fi
    - make dist
  artifacts:
    paths:
      - dist/

deploy_gitlab:
  interruptible: true
  stage: publish
  before_script:
    - pip3 install poetry
  script:
    - poetry version $(poetry version | cut -d" " -f2)+$(date --date=${CI_COMMIT_TIMESTAMP} +%Y%m%d%H%M%S);
    - poetry publish -u gitlab-ci-token -p ${CI_JOB_TOKEN} -r gitlab

trigger_teckids_org:
  stage: downstream
  trigger: Teckids/teckids.org
  only:
    - master

trigger_schulfrei_dev:
  stage: downstream
  trigger: schul-frei/schul-frei.dev
  only:
    - master

trigger_hacknfun_camp:
  stage: downstream
  trigger: hacknfun/hacknfun.camp
  only:
    - master

trigger_leopard_institute:
  stage: downstream
  trigger: LEOPARD/leopard.institute
  only:
    - master