Skip to content

Commit 5abdbce

Browse files
committed
PyPI publishing rules added.
1 parent 1c93ee1 commit 5abdbce

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

.github/workflows/publish.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Upload Python Package to PyPI when a Release is Created
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
pypi-publish:
9+
name: Publish release to PyPI
10+
runs-on: ubuntu-latest
11+
environment:
12+
name: pypi
13+
url: https://pypi.org/p/iksemel
14+
permissions:
15+
id-token: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Set up Python
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: "3.x"
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install setuptools wheel
26+
- name: Build package
27+
run: |
28+
python setup.py sdist bdist_wheel # Could also be python -m build
29+
- name: Publish package distributions to PyPI
30+
uses: pypa/gh-action-pypi-publish@release/v1

setup.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
import glob
1515
import shutil
1616
import subprocess
17-
from distutils.core import setup, Extension
18-
from distutils.command.install import install
17+
from setuptools import setup, Extension
18+
from setuptools.command.install import install
19+
import unittest
1920

2021
version = '1.6.2'
2122

@@ -40,17 +41,20 @@
4041
"""
4142

4243
if 'test' in sys.argv:
43-
import unittest
4444
test_loader = unittest.TestLoader()
4545
test_suite = test_loader.discover('python/test/', pattern='*.py')
46-
if test_suite:
47-
print("all tests passed :)")
46+
test_result = unittest.TextTestRunner().run(test_suite)
47+
if test_result.wasSuccessful():
48+
print("All tests passed :)")
4849
sys.exit(0)
49-
sys.exit(1)
50+
else:
51+
print("Some tests failed :(")
52+
sys.exit(1)
5053

5154

5255
class Install(install):
5356
def finalize_options(self):
57+
# Uncomment and modify if specific install locations are needed
5458
# if os.path.exists("/etc/sulin-release"):
5559
# self.install_platlib = '$base/lib/sulin'
5660
# self.install_purelib = '$base/lib/sulin'
@@ -83,3 +87,4 @@ def run(self):
8387
'install': Install
8488
}
8589
)
90+

0 commit comments

Comments
 (0)