From a90778449aef0afb10d8afad1bef53feafa7d9ae Mon Sep 17 00:00:00 2001 From: Julian Rother <julian@jrother.eu> Date: Fri, 23 Jul 2021 16:34:27 +0200 Subject: [PATCH] Added .gitlab-ci.yml to auto-publish tags as pip packages --- .gitlab-ci.yml | 9 +++++++++ setup.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..a501fa8 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,9 @@ +publish: + stage: deploy + image: python:3.7 + script: + - pip install build twine + - PACKAGE_VERSION="${CI_COMMIT_TAG#v}" python -m build + - python -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/* + rules: + - if: '$CI_COMMIT_TAG =~ /v[0-9]+[.][0-9]+[.][0-9]+.*/' diff --git a/setup.py b/setup.py index ddeba47..3c83100 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,4 @@ +import os import setuptools with open('README.md', 'r', encoding='utf-8') as f: @@ -5,7 +6,7 @@ with open('README.md', 'r', encoding='utf-8') as f: setuptools.setup( name='ldapserver', - version='0.0.1.dev0', + version=os.environ.get('PACKAGE_VERSION', 'local'), author='Julian Rother', author_email='python-ldapserver@jrother.eu', description='LDAP server request handler', -- GitLab