This repository has been archived by the owner on Sep 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
79 lines (72 loc) · 1.81 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
variables:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: ""
POSTGRES_HOST_AUTH_METHOD: 'trust'
stages:
- test
- release
services:
- postgres:latest
cache:
key: "$CI_PROJECT_NAME"
paths:
- $HOME/.cache/pip
precommit:
stage: test
image: python:3
variables:
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
script:
- pip3 install pre-commit
- pre-commit run --all-files
cache:
paths:
- ${PRE_COMMIT_HOME}
test:
stage: test
image: "registry.gitlab.com/thelabnyc/python:${IMAGE}"
script:
- pip install tox
- tox
coverage: '/^TOTAL.+?(\d+\%)$/'
parallel:
matrix:
- IMAGE: py310
TOX_SKIP_ENV: "^(?!py310-)"
- IMAGE: py311
TOX_SKIP_ENV: "^(?!py311-)"
- IMAGE: py312
TOX_SKIP_ENV: "^(?!py312-)"
publish_pkg:
image: registry.gitlab.com/thelabnyc/python:py311
stage: release
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED
script:
- pip install twine
- poetry build
# Publish to PyPI
- export TWINE_USERNAME=__token__
- export TWINE_PASSWORD=${PYPI_TOKEN}
- python -m twine upload
--repository-url https://upload.pypi.org/legacy/
dist/*
# Publish to Gitlab
- export TWINE_USERNAME=gitlab-ci-token
- export TWINE_PASSWORD=${CI_JOB_TOKEN}
- python -m twine upload
--repository-url https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi
dist/*
publish_gitlab_release:
image: registry.gitlab.com/gitlab-org/release-cli:latest
stage: release
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED
script:
- echo 'release job'
release:
name: 'Release $CI_COMMIT_TAG'
description: 'Release $CI_COMMIT_TAG. Tagged by $GITLAB_USER_LOGIN'
tag_name: '$CI_COMMIT_TAG'
ref: '$CI_COMMIT_TAG'