Skip to content

Commit

Permalink
Add workflow to push to PyPi
Browse files Browse the repository at this point in the history
  • Loading branch information
vogti committed May 8, 2024
1 parent 9dcd5db commit 41b7115
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
File renamed without changes.
47 changes: 47 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -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
22 changes: 18 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 41b7115

Please sign in to comment.