Add deploy stage and publish job to CI/CD pipeline

The commit adds a new deployment stage and a publish job to the .gitlab-ci.yml file. The deploy stage is placed after the test stage, and the publish job is defined to run only on tags. The publish job installs Hatchling, Twine, and Build packages, builds the project, and uploads the distribution files to PyPI using the provided token as the password.
This commit is contained in:
Kumi 2023-08-25 08:02:26 +02:00
parent aa3eb4dacf
commit 86e4be00ad
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -2,6 +2,7 @@ image: python:3.10
stages: stages:
- test - test
- deploy
before_script: before_script:
- python -V - python -V
@ -9,10 +10,20 @@ before_script:
- source venv/bin/activate - source venv/bin/activate
- pip install -U pip - pip install -U pip
- pip install . - pip install .
- echo "[KeyDelivery]" > config.ini
- echo "key = ${API_KEY}" >> config.ini
- echo "secret = ${API_SECRET}" >> config.ini
test: test:
stage: test stage: test
script: python -m unittest test.py script:
- echo "[KeyDelivery]" > config.ini
- echo "key = ${API_KEY}" >> config.ini
- echo "secret = ${API_SECRET}" >> config.ini
- python -m unittest test.py
publish:
stage: publish
script:
- pip install -U hatchling twine build
- python -m build .
- python -m twine upload --username __token__ --password ${PYPI_TOKEN} dist/*
only:
- tags