---
include:
  - remote: https://jobs.just-ci.dev/recos/python/generic.yml

variables:
  TWINE_USERNAME: gitlab-ci-token
  TWINE_PASSWORD: ${CI_JOB_TOKEN}
  TWINE_REPOSITORY_URL: ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi
  TWINE_DEFAULT_ARGS: --disable-progress-bar --non-interactive --verbose
  TWINE_EXTRA_ARGS: "" # Use --skip-existing when uploading to PyPI
  TWINE_DIST: dist/*

python:twine:
  extends: .python:pre
  stage: .post
  variables:
    JOB_PACKAGE: twine build
  script:
    - !reference [".python:pre", script]
    - python3 -m build
    - python3 -m build --version
    - twine --version
    - twine upload ${TWINE_DEFAULT_ARGS} ${TWINE_EXTRA_ARGS} ${TWINE_DIST}
