---

makepkg:
  stage: build
  rules:
  - if: '$CI_COMMIT_TAG'
  when: manual
  script:
  - seblu-x86_64-build
  artifacts:
    name: $CI_PROJECT_NAME-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHA
    expire_in: 3 month
    paths:
    - config.x86_64
    - "*.pkg.tar.*"

commitpkg:
  stage: deploy
  rules:
  - if: '$CI_COMMIT_TAG'
  script:
  - eval $(ssh-agent -s)
  # - trap "kill $SSH_AGENT_PID" 0
  # trap is broken in gitlab runner, see:
  # https://gitlab.com/gitlab-org/gitlab-runner/issues/3009
  # use a workaournd with sleep and kill:
  - sleep 300 && kill "$SSH_AGENT_PID" & disown
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
  - seblu-push
