-
Notifications
You must be signed in to change notification settings - Fork 11
/
.gitlab-ci.yml
48 lines (41 loc) · 1010 Bytes
/
.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
image: python:3.8
stages:
- test
- tag
- release
pytest:
stage: test
except:
- tags
script:
- pip install tox
- tox -e py38
flake8:
stage: test
except:
- tags
script:
- pip install tox
- tox -e flake8
.write_permission: &write_permission |
git config --global user.email "gitlab-ci"; git config --global user.name "gitlab-ci"
url_host=`git remote get-url origin | sed -e "s/https:\/\/gitlab-ci-token:.*@//g"`
git remote set-url origin "https://gitlab-ci-token:${CI_TAG_UPLOAD_TOKEN}@${url_host}"
tag:
stage: tag
only:
- main
script:
- *write_permission
- export VERSION=$(echo $(awk -F "'" '/version=/{print $2}' setup.py))
- git tag -a $VERSION -m "Version created by gitlab-ci Build"
- git push origin $VERSION
pypi-package:
stage: release
only:
- tags
script:
- pip install twine
- rm -f dist/* # Clear any old/cached builds
- python setup.py sdist bdist_wheel
- python -m twine upload dist/*