Skip to content

Commit 41b7115

Browse files
committed
Add workflow to push to PyPi
1 parent 9dcd5db commit 41b7115

3 files changed

Lines changed: 65 additions & 4 deletions

File tree

File renamed without changes.

.github/workflows/publish-pypi.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
2+
on:
3+
release:
4+
types:
5+
- published
6+
jobs:
7+
publish:
8+
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
packages: write
13+
id-token: write
14+
environment:
15+
name: testpypi
16+
url: https://test.pypi.org/p/polypheny-prism-api
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up Python 3.8
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: 3.8
23+
- name: Set Version
24+
id: version
25+
run: |
26+
if [[ "${{ github.event_name }}" == "release" && "${{ github.event.action }}" == "published" ]]; then
27+
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
28+
else
29+
TIMESTAMP=$(date +'%Y%m%d%H%M%S')
30+
echo "VERSION=0.0.dev${TIMESTAMP}" >> $GITHUB_ENV
31+
fi
32+
- name: Download protobuf for Linux
33+
run: |
34+
curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v26.0/protoc-26.0-linux-x86_64.zip
35+
unzip protoc-26.0-linux-x86_64.zip
36+
- name: Build Protobuf Files
37+
run: bin/protoc --experimental_allow_proto3_optional -I . --python_out . org/polypheny/prism/*.proto
38+
- name: Build package
39+
run: python setup.py sdist
40+
env:
41+
VERSION: ${{ env.VERSION }}
42+
# - name: Publish distribution 📦 to Test PyPI
43+
# uses: pypa/gh-action-pypi-publish@release/v1
44+
# with:
45+
# repository-url: https://test.pypi.org/legacy/
46+
- name: Publish distribution 📦 to PyPI
47+
uses: pypa/gh-action-pypi-publish@release/v1

setup.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
import os
2+
import sys
23

34
from setuptools import setup
45

5-
version = os.getenv('version', '0.0')
6-
major, minor = version.split('.')
6+
# Retrieve 'VERSION' environment variable, default to '0.0' if not found.
7+
version = os.getenv('VERSION', '0.0')
8+
9+
# Attempt to split the version number, default to '0' for both if it fails
10+
try:
11+
major, minor = version.split('.')
12+
except ValueError:
13+
major, minor = '0', '0' # Default to '0.0' if the version isn't in a 'major.minor' format
14+
715

816
with open('org/polypheny/prism/version.py', 'w') as f:
917
f.write(f'MAJOR_VERSION = {major}\n')
1018
f.write(f'MINOR_VERSION = {minor}\n')
1119

12-
setup(name='polyphenyprism',
20+
21+
with open('README.md', 'r', encoding='utf-8') as f:
22+
long_description = f.read()
23+
24+
setup(name='polypheny-prism-api',
1325
version=version,
14-
description='Protobuf files for Polypheny',
26+
description='Polypheny Prism API files for Python',
27+
long_description=long_description,
28+
long_description_content_type='text/markdown',
1529
packages=['org/polypheny/prism'],
1630
install_requires=[
1731
"protobuf==4.24.3",

0 commit comments

Comments
 (0)