Skip to content
Snippets Groups Projects
Commit 096afbd2 authored by Janis Streib's avatar Janis Streib :owl:
Browse files

UPD: dynamic version + publish in registry

parent b7120307
No related branches found
No related tags found
No related merge requests found
Pipeline #268861 failed
......@@ -20,11 +20,11 @@ before_script:
- apt-get -y update
- command -v git || apt-get -y install git
- command -v python3 || apt-get -y install python3
- command -v pip3 || apt-get -y install python3-pip
- command -v pip3 || apt-get -y install python3-pip twine
- python3 -V # Print out python version for debugging
- pip3 install build
- python3 -m venv || apt-get -y install python3-venv
- if [[ "$CI_COMMIT_BRANCH" != "master" ]]; then sed -i "s%git+https://git.scc.kit.edu/scc-net/net-suite/api-generator.git@master%git+https://git.scc.kit.edu/scc-net/net-suite/api-generator.git@${CI_COMMIT_BRANCH}%g" pyproject.toml; fi
- if [[ "$CI_COMMIT_BRANCH" != "main" ]]; then sed -i "s%git+https://git.scc.kit.edu/scc-net/net-suite/api-generator.git@master%git+https://git.scc.kit.edu/scc-net/net-suite/api-generator.git@${CI_COMMIT_BRANCH}%g" pyproject.toml; fi
- if [[ "$CI_COMMIT_BRANCH" == "devel" ]]; then export NETDB_ENDPOINT=${NETDB_DEVEL_ENDPOINT}; fi
......@@ -35,10 +35,11 @@ build:
stage: build
script:
- python3 -m build
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python3 -m twine upload --repository-url ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/pypi dist/*
artifacts:
paths:
- dist/*
expire_in: 2 days
only:
- master
- main
- devel
[build-system]
# Minimum requirements for the build system to execute.
requires = ["setuptools", "wheel", "net_api_generator @ git+https://git.scc.kit.edu/scc-net/net-suite/api-generator.git@master"]
requires = ["setuptools", "wheel", "net_api_generator @ git+https://git.scc.kit.edu/scc-net/net-suite/api-generator.git@master", "semver", "requests"]
build-backend = "setuptools.build_meta"
from setuptools import setup
from distutils.command.build_py import build_py
from setuptools.command.build_py import build_py
import subprocess
import os
import requests
import semver
vers = requests.get(f"https://{os.environ.get('NETDB_ENDPOINT')}").json()[0]
largest_ver = None
for v in vers:
sem_v = semver.Version.parse(v['numeric'])
if largest_ver is None or largest_ver < sem_v:
largest_ver = sem_v
class APIGenBuild(build_py):
def run(self):
build_versions = ['3.2', '4.0']
default_version = '4.0'
build_versions = [f'{v["major"]}.{v["minor"]}' for v in vers]
default_version = f'{largest_ver.major}.0'
environ = os.environ.copy()
for version in build_versions:
target_dir = os.path.join(self.build_lib, 'netdb_client', f"api{version.replace('.', '')}")
......@@ -18,15 +27,14 @@ class APIGenBuild(build_py):
environ['NETDB_VERSION'] = default_version
subprocess.run(['net-api-generator', 'python', f'--output-dir={target_dir}'], check=True, env=environ)
build_py.run(self)
setup(
name='netdb_client',
version='4.0',
author='Dr. Meta',
description='This is a meta package to install the automatically generated NET-API 3.0, 3.1, 3.2 and 4.0 definitions.',
version=f'{str(largest_ver)}+{os.environ.get("CI_COMMIT_BRANCH", "local")}-{os.environ.get("CI_COMMIT_SHORT_SHA", "HEAD")}',
author='NETVS-Team <netvs@scc.kit.edu>',
description='This is a meta package to install the automatically generated NET-API definitionsi for the currently supported API versions.',
url='https://git.scc.kit.edu/scc-net/net-suite/netdb-client-lib',
install_requires=['requests'],
install_requires=['requests', 'semver'],
python_requires='>=3.7',
packages=['netdb_client'],
cmdclass={'build_py': APIGenBuild}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment