Skip to content

Commit c1808ee

Browse files
committed
python.yml: Configure upload_pypi.
1 parent 68fea26 commit c1808ee

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

.github/workflows/python.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ on:
1919
- 'c/*.[ch]p?p?'
2020
# Manual run
2121
workflow_dispatch:
22+
release:
23+
types:
24+
- published
2225

2326
concurrency:
2427
group: ${{ github.workflow }}-${{ github.ref }}
@@ -102,7 +105,7 @@ jobs:
102105
- name: Publish artifacts
103106
uses: actions/upload-artifact@v4
104107
with:
105-
name: dist-${{ matrix.os }}-${{ matrix.python-version }}
108+
name: moocore-dist-${{ matrix.os }}-${{ matrix.python-version }}
106109
path: python/dist/
107110

108111
build-doc:
@@ -229,9 +232,31 @@ jobs:
229232

230233
- uses: actions/upload-artifact@v4
231234
with:
232-
name: wheels-${{ matrix.os }}-${{ matrix.python-version }}
235+
name: moocore-wheels-${{ matrix.os }}-${{ matrix.python-version }}
233236
path: wheelhouse/*.whl
234237

238+
upload_pypi:
239+
name: Publish Python 🐍 distribution 📦 to PyPI
240+
needs: [wheels, build-package]
241+
runs-on: ubuntu-latest
242+
environment: pypi
243+
permissions:
244+
id-token: write
245+
if: github.event_name == 'release' && github.event.action == 'published'
246+
# or, alternatively, upload to PyPI on every tag starting with 'v' (remove on: release above to use this)
247+
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
248+
steps:
249+
- uses: actions/download-artifact@v4
250+
with:
251+
# unpacks all moocore artifacts into dist/
252+
pattern: moocore-*
253+
path: dist
254+
merge-multiple: true
255+
256+
- uses: pypa/gh-action-pypi-publish@release/v1
257+
with:
258+
# To test: repository-url: https://test.pypi.org/legacy/
259+
235260
upload:
236261
name: Store wheels
237262
needs: wheels
@@ -244,7 +269,7 @@ jobs:
244269
- uses: actions/download-artifact@v4
245270
with:
246271
path: wheelhouse
247-
pattern: wheels-*
272+
pattern: moocore-wheels-*
248273
merge-multiple: true
249274

250275
- name: List wheels

0 commit comments

Comments
 (0)