diff --git a/.github/workflows/publish.yml b/.github/workflows/publish-maven-central.yml similarity index 100% rename from .github/workflows/publish.yml rename to .github/workflows/publish-maven-central.yml diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml new file mode 100644 index 0000000..e3d65b0 --- /dev/null +++ b/.github/workflows/publish-pypi.yml @@ -0,0 +1,47 @@ +name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI +on: + release: + types: + - published +jobs: + publish: + name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + id-token: write + environment: + name: testpypi + url: https://test.pypi.org/p/polypheny-prism-api + steps: + - uses: actions/checkout@v4 + - name: Set up Python 3.8 + uses: actions/setup-python@v5 + with: + python-version: 3.8 + - name: Set Version + id: version + run: | + if [[ "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "published" ]]; then + echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV + else + TIMESTAMP=$(date +'%Y%m%d%H%M%S') + echo "VERSION=0.0.dev${TIMESTAMP}" >> $GITHUB_ENV + fi + - name: Download protobuf for Linux + run: | + curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v26.0/protoc-26.0-linux-x86_64.zip + unzip protoc-26.0-linux-x86_64.zip + - name: Build Protobuf Files + run: bin/protoc --experimental_allow_proto3_optional -I . --python_out . org/polypheny/prism/*.proto + - name: Build package + run: python setup.py sdist + env: + VERSION: ${{ env.VERSION }} +# - name: Publish distribution 📦 to Test PyPI +# uses: pypa/gh-action-pypi-publish@release/v1 +# with: +# repository-url: https://test.pypi.org/legacy/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/setup.py b/setup.py index 970df6d..dfb13e8 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,31 @@ import os +import sys from setuptools import setup -version = os.getenv('version', '0.0') -major, minor = version.split('.') +# Retrieve 'VERSION' environment variable, default to '0.0' if not found. +version = os.getenv('VERSION', '0.0') + +# Attempt to split the version number, default to '0' for both if it fails +try: + major, minor = version.split('.') +except ValueError: + major, minor = '0', '0' # Default to '0.0' if the version isn't in a 'major.minor' format + with open('org/polypheny/prism/version.py', 'w') as f: f.write(f'MAJOR_VERSION = {major}\n') f.write(f'MINOR_VERSION = {minor}\n') -setup(name='polyphenyprism', + +with open('README.md', 'r', encoding='utf-8') as f: + long_description = f.read() + +setup(name='polypheny-prism-api', version=version, - description='Protobuf files for Polypheny', + description='Polypheny Prism API files for Python', + long_description=long_description, + long_description_content_type='text/markdown', packages=['org/polypheny/prism'], install_requires=[ "protobuf==4.24.3",