From a633ecef4cb8ce1fe35e9895eac314aeef79fd21 Mon Sep 17 00:00:00 2001 From: Stanislav Hejny Date: Thu, 27 Feb 2025 03:56:45 +0000 Subject: [PATCH] Update the Ci/CD pipline to publish AMQ as library --- .gitlab-ci.yml | 33 +++++++++++++++++++++++++++++++++ setup.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 setup.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b89912..16634f5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,11 @@ # This pipeline would run the test coverage report to satisfy Coverage-Check rule. stages: - test + - build + - publish + +variables: + PROJECT_ID: 217 # Define a cache for pip dependencies to speed up builds cache: @@ -30,3 +35,31 @@ test: coverage: '/^TOTAL.*\s+(\d+%)$/' # Regex to extract coverage percentage from the report #rules: # - if: $CI_COMMIT_BRANCH == "develop" # Run this job only on the 'develop' branch + +# Build the package +build: + stage: build + image: python:3.11 + before_script: + - pip install --upgrade pip + - pip install setuptools wheel + script: + - python setup.py sdist bdist_wheel + artifacts: + paths: + - dist/ + +# Publish the package to PyPI +publish: + stage: publish + image: python:3.11 + before_script: + - pip install --upgrade pip + - pip install twine + script: + # - twine upload --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD dist/* + - twine upload --repository-url https://git.cleverthis.com/api/v4/projects/$PROJECT_ID/packages/pypi --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD dist/* + only: + - main # Only publish from the main branch + rules: + - if: $CI_COMMIT_BRANCH == "main" diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..db0d66d --- /dev/null +++ b/setup.py @@ -0,0 +1,30 @@ +from setuptools import setup, find_packages + +setup( + name="amqp", + version="0.2.0", + author="Stanislav Hejny", + author_email="stanislav.hejny@cleverthis.com", + description="Adapter for RabbitMQ to integrate a CleverThis python-code Service with CleverMicro platform", + long_description=open("README.md").read(), + long_description_content_type="text/markdown", + url="https://git.cleverthis.com/cleverthis/clevermicro/amq-adapter-python", + packages=find_packages(), + install_requires=[ + # dependencies here + "aiohttp~=3.11.11", + "fastapi==0.115.6", + "pika~=1.3.2", + "opentelemetry-api", + "opentelemetry-sdk", + "opentelemetry-exporter-otlp", + "opentelemetry-exporter-prometheus", + "opentelemetry-instrumentation-pika" + ], + classifiers=[ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], + python_requires=">=3.11", +)