stages:          # List of stages for jobs, and their order of execution
  - build

build-job:       # This job runs in the build stage, which runs first.
  stage: build

  rules:
    - if: $CI_COMMIT_REF_NAME == "pypi" #when commit pushed in this branch it will trigger this job

  variables:
    TWINE_USERNAME: $USER_NAME
    TWINE_PASSWORD: $API_KEY
    TWINE_REPOSITORY: marl-factory-grid

  image: python:slim
  script:
    - echo "Compiling the code..."
    - pip install -U twine
    - python setup.py sdist bdist_wheel
    - twine check dist/*
    # try upload in test platform before the oficial
    - twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
    - echo "Upload complete."