-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.python-ci.yml
34 lines (31 loc) · 1.54 KB
/
.python-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# https://docs.gitlab.com/ee/user/packages/pypi_repository/#authenticate-with-a-ci-job-token
image: python:3.10
stages:
- lint
- deploy
publish_local:
stage: deploy
script:
- pip install build twine
- python -m build
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
rules:
# This task requires a lot of installation and should have ran locally before the commit
# We should only be needing this check before the merge request on the default branch
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
# Nb: push shouldn't be allowed on master
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"'
publish_pypi:
stage: deploy
script:
- pip install build twine
- python -m build
- TWINE_PASSWORD=${PYPI_TOKEN} TWINE_USERNAME=__token__ python -m twine upload dist/*
rules:
# This task requires a lot of installation and should have ran locally before the commit
# We should only be needing this check before the merge request on the default branch
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "main"'
# Nb: push shouldn't be allowed on master
- if: '$CI_PIPELINE_SOURCE == "push" && $CI_COMMIT_BRANCH == "main"'
# TODO: Check if the version of the package was updated before the merge
# (i.e. doesn't exist in the registry)