@@ -257,3 +257,68 @@ jobs:
257
257
with :
258
258
branch : gh-pages
259
259
folder : dist
260
+
261
+ publish-pypi :
262
+ name : Publish to PyPI
263
+ needs : test
264
+ if : github.ref == 'refs/heads/main'
265
+ runs-on : ubuntu-latest
266
+ steps :
267
+ - name : Check out the repository
268
+ uses : actions/checkout@v4
269
+ with :
270
+ fetch-depth : 2
271
+
272
+ - name : Set up Python
273
+ uses : actions/setup-python@v5
274
+ with :
275
+ python-version : ' 3.13'
276
+ - name : Upgrade pip
277
+ run : |
278
+ python -m pip install --upgrade pip
279
+ pip --version
280
+ pip install wheel .[tests]
281
+ - name : run tests
282
+ run : pytest --disable-pytest-warnings
283
+
284
+ - name : Check if there is a parent commit
285
+ id : check-parent-commit
286
+ run : |
287
+ echo "sha=$(git rev-parse --verify --quiet HEAD^)" >> $GITHUB_OUTPUT
288
+
289
+ - name : Detect new version
290
+ id : check-version
291
+ if : steps.check-parent-commit.outputs.sha
292
+
293
+ with :
294
+ create-tag : false
295
+ version-command : |
296
+ bash -o pipefail -c "cat bioimageio/core/VERSION | jq -r '.version'"
297
+
298
+ - name : Push tag
299
+ id : tag-version
300
+ if : steps.check-version.outputs.previous-version != steps.check-version.outputs.current-version
301
+ uses :
mathieudutour/[email protected]
302
+ with :
303
+ github_token : ${{ secrets.GITHUB_TOKEN }}
304
+ custom_tag : ${{ steps.check-version.outputs.current-version }}
305
+
306
+ - name : Build package
307
+ run : |
308
+ python setup.py sdist bdist_wheel
309
+
310
+ - name : Publish package on PyPI
311
+ if : steps.tag-version.outputs.new_tag
312
+ uses : pypa/gh-action-pypi-publish@release/v1.10
313
+ with :
314
+ user : __token__
315
+ password : " ${{ secrets.PYPI_TOKEN }}"
316
+ packages-dir : dist/
317
+ verbose : true
318
+ - name : Publish the release notes
319
+ uses :
release-drafter/[email protected]
320
+ with :
321
+ publish : " ${{ steps.tag-version.outputs.new_tag != '' }}"
322
+ tag : " ${{ steps.tag-version.outputs.new_tag }}"
323
+ env :
324
+ GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
0 commit comments