forked from meltano/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
95 lines (87 loc) · 2.44 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
stages:
- setup
- test
- publish
include:
- template: Security/License-Scanning.gitlab-ci.yml
default:
before_script:
- python -V
- python -m pip install pipx
- python -m pipx ensurepath
- python -m pipx install poetry
# Force update PATH to include pipx executables
- export PATH=$PATH:/root/.local/bin
# Create virtual environment and make sure pip and setuptools are up-to-date
- poetry env use python
- poetry run pip install --upgrade pip setuptools
- poetry install --no-root
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
LM_PYTHON_VERSION: 3
cache:
paths:
- .cache/pip
- venv/
generate_requirements:
stage: setup
image:
name: python:3.8
before_script:
# Install poetry
- python -V
- python -m pip install pipx
- python -m pipx ensurepath
- python -m pipx install poetry
# Force update PATH to include pipx executables
- export PATH=$PATH:/root/.local/bin
script:
- poetry export --format requirements.txt --output requirements.txt
artifacts:
paths:
- requirements.txt
license_scanning:
stage: test
before_script: [] # negate defaults above
dependencies:
- generate_requirements
pypi_publish:
# release:
# name: '$CI_COMMIT_TAG'
# tag_name: '$CI_COMMIT_TAG'
# description: '$CI_COMMIT_TAG'
only:
- tags
stage: publish
parallel:
matrix:
- PYTHON_VERSION: ["3.8"]
image: python:${PYTHON_VERSION}
script:
- |
echo "Publishing tag '$CI_COMMIT_TAG' to PyPi, Ref='$CI_COMMIT_REF_NAME' and Namespace='$CI_PROJECT_NAMESPACE'..."
echo "Detected poetry version: v$(poetry version --short)"
if [[ "$CI_COMMIT_TAG" == "v$(poetry version --short)" ]];
then
echo -e "\nPublishing to version ref 'v$(poetry version --short)'...\n\n"
poetry publish --build
else
echo -e "\nERROR - Tag '$CI_COMMIT_TAG' did not match detected version 'v$(poetry version --short)'."
exit 1
fi
pypi_prerelease:
when: manual
except:
- tags
stage: publish
parallel:
matrix:
- PYTHON_VERSION: ["3.8"]
image: python:${PYTHON_VERSION}
script:
- |
echo "Publishing to PyPi, Ref='$CI_COMMIT_REF_NAME' and Namespace='$CI_PROJECT_NAMESPACE'..."
poetry version $(poetry version --short)-dev.$CI_JOB_ID
poetry version --short
echo -e "\nPublishing to version ref '$(poetry version --short)'...\n\n"
poetry publish --build