-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
92 lines (84 loc) · 1.92 KB
/
.gitlab-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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
image: python:latest
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# https://pip.pypa.io/en/stable/topics/caching/
cache:
paths:
- .cache/pip
stages:
- test
- build
- pypi
- release
test:
stage: test
tags:
- docker
image: "python:$VERSION"
script:
- python --version ; pip --version # For debugging
- pip install pytest tox click
- tox -e py${VERSION}
parallel:
matrix:
- VERSION: ['3.9', '3.11']
artifacts:
when: always
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
coverage: '/TOTAL.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
build:
stage: build
tags:
- docker
image: "python:latest"
script:
- pip install build
- python3 -m build
artifacts:
paths:
- dist/
pypi_test:
stage: pypi
tags:
- docker
image: "python:latest"
rules:
- if: $CI_COMMIT_TAG
when: never
- when: on_success
variables:
TWINE_USERNAME: $PYPI_TEST_USERNAME
TWINE_PASSWORD: $PYPI_TEST_PASSWORD
script:
- pip install twine
- python3 -m twine upload --repository testpypi --skip-existing dist/*
pypi_prod:
stage: pypi
tags:
- docker
image: "python:latest"
rules:
- if: $CI_COMMIT_TAG
variables:
TWINE_USERNAME: $PYPI_PROD_USERNAME
TWINE_PASSWORD: $PYPI_PROD_PASSWORD
script:
- pip install twine
- python3 -m twine upload dist/*
release_job:
stage: release
tags:
- docker
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created
script:
- echo "running release_job"
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: '$CI_COMMIT_TAG'
description: '$CI_COMMIT_TAG'