Skip to content

Commit f59d8b5

Browse files
committed
Updated workflows
1 parent 4071f11 commit f59d8b5

File tree

2 files changed

+43
-20
lines changed

2 files changed

+43
-20
lines changed

.github/workflows/publish.yml

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,69 @@
1-
name: Upload Python Package to PyPI
1+
name: Publish Python Distribution [PyPi & GH Release | TestPyPi]
22

33
on:
44
push:
55
branches:
66
- main
7+
tags:
8+
- '*'
79
workflow_dispatch:
810

911
jobs:
10-
deploy:
12+
prepare-and-check:
1113
runs-on: ubuntu-latest
12-
14+
outputs:
15+
publish_to_pypi: ${{ steps.version_check.outputs.publish_to_pypi }}
16+
publish_to_testpypi: ${{ steps.version_check.outputs.publish_to_testpypi }}
1317
steps:
14-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v4
1519

1620
- name: Set up Python
17-
uses: actions/setup-python@v2
21+
uses: actions/setup-python@v5
1822
with:
1923
python-version: '3.x'
2024

21-
- name: Install dependencies
25+
- name: Install dependencies for version check
2226
run: |
2327
python -m pip install --upgrade pip
24-
pip install setuptools wheel twine requests
25-
pip install -r requirements.txt
28+
pip install requests
2629
27-
# Check if the current version is already on PyPI
28-
- name: Check version on PyPI
30+
- name: Check version on PyPI or TestPyPI
2931
id: version_check
3032
run: |
31-
python3 check_version.py
32-
continue-on-error: true
33+
python3 check_version.py ${{ github.ref }}
34+
env:
35+
GITHUB_OUTPUT: ${{ github.output }}
36+
37+
build-and-publish:
38+
needs: prepare-and-check
39+
if: needs.prepare-and-check.outputs.publish_to_pypi == 'true' || needs.prepare-and-check.outputs.publish_to_testpypi == 'true'
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- name: Set up Python
44+
uses: actions/setup-python@v5
45+
with:
46+
python-version: '3.x'
47+
48+
- name: Install build dependencies
49+
run: |
50+
python -m pip install --upgrade pip
51+
pip install setuptools wheel twine
3352
34-
# Build the package (folder exclusion is handled by MANIFEST.in)
3553
- name: Build package
36-
if: steps.version_check.outputs.version_exists != 'true'
3754
run: |
3855
python setup.py sdist bdist_wheel
3956
40-
- name: Upload to PyPI
41-
if: steps.version_check.outputs.version_exists != 'true'
57+
- name: Publish to PyPI
58+
if: needs.prepare-and-check.outputs.publish_to_pypi == 'true'
59+
run: twine upload dist/*
4260
env:
4361
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
4462
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
45-
run: |
46-
twine upload dist/*
63+
64+
- name: Publish to TestPyPI
65+
if: needs.prepare-and-check.outputs.publish_to_testpypi == 'true'
66+
run: twine upload --repository-url https://test.pypi.org/legacy/ dist/*
67+
env:
68+
TWINE_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
69+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
runs-on: ubuntu-latest
1818

1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121
- name: Set up Python 3.10
22-
uses: actions/setup-python@v3
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: "3.10"
2525
- name: Install dependencies

0 commit comments

Comments
 (0)