-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
112 lines (102 loc) · 2.4 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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:
- prepare
- test
- build
- pypi
- release
workflow:
rules:
- if: $CI_COMMIT_TITLE =~ /Add changelog for version .*/
when: never
- when: always
prepare:
stage: prepare
tags:
- docker
image: "python:latest"
rules:
- if: $CI_COMMIT_TAG # Run this job when a tag is created
script:
- 'curl -H "PRIVATE-TOKEN: $CI_API_TOKEN" -X POST "$CI_API_V4_URL/projects/$CI_PROJECT_ID/repository/changelog?version=$CI_COMMIT_TAG"'
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
junit: report.xml
paths:
- report.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'