Skip to content

Commit f23389d

Browse files
committed
CI: Add PyPI deployment to GHA worfklow
1 parent 00d3a52 commit f23389d

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
# Packages that use it probably do not want to continue testing with editable installations,
77
# quadrupling their test load.
88

9+
# For deployment, it will be necessary to create a PyPI API token and store it as a secret
10+
# https://docs.github.com/en/actions/reference/encrypted-secrets
11+
912
name: Python package
1013

1114
# Set once
@@ -15,11 +18,12 @@ env:
1518
on:
1619
push:
1720
branches: [ main ]
21+
tags: [ '*' ]
1822
pull_request:
1923
branches: [ main ]
2024

2125
jobs:
22-
build:
26+
test:
2327
runs-on: ubuntu-latest
2428
strategy:
2529
matrix:
@@ -50,3 +54,35 @@ jobs:
5054
- name: Test with pytest
5155
run: |
5256
pytest -sv --doctest-modules pydra/tasks/$SUBPACKAGE
57+
58+
deploy:
59+
needs: test
60+
runs-on: ubuntu-latest
61+
strategy:
62+
matrix:
63+
python-version: [3.9]
64+
steps:
65+
- uses: actions/checkout@v2
66+
with:
67+
submodules: recursive
68+
fetch-depth: 0
69+
- name: Set up Python ${{ matrix.python-version }}
70+
uses: actions/setup-python@v2
71+
with:
72+
python-version: ${{ matrix.python-version }}
73+
- name: Install build tools
74+
run: python -m pip install --upgrade pip setuptools wheel twine
75+
- name: Build source and wheel distributions
76+
run: python setup.py sdist bdist_wheel
77+
- name: Check distributions
78+
run: twine check dist/*
79+
- uses: actions/upload-artifact@v2
80+
with:
81+
name: distributions
82+
path: dist/
83+
- name: Upload to PyPI (on tags)
84+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
85+
uses: pypa/gh-action-pypi-publish@master
86+
with:
87+
user: __token__
88+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)