publish.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # This workflow will build and (if release) publish Python distributions to PyPI
  2. # For more information see:
  3. # - https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
  4. # - https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
  5. #
  6. ---
  7. name: build-publish
  8. on:
  9. release:
  10. types: [published]
  11. jobs:
  12. build-wheels:
  13. runs-on: ubuntu-latest
  14. permissions:
  15. contents: read
  16. steps:
  17. - uses: actions/checkout@v4
  18. - name: Set up Python
  19. uses: actions/setup-python@v5
  20. with:
  21. python-version: '3.10'
  22. - name: Install pypa/build
  23. run: python -m pip install -U build
  24. - name: Build a binary wheel and a source tarball
  25. run: python -m build --sdist --wheel --outdir dist/ .
  26. - name: Store wheels
  27. uses: actions/upload-artifact@v4
  28. with:
  29. path: dist
  30. publish:
  31. runs-on: ubuntu-latest
  32. needs:
  33. - build-wheels
  34. if: github.event_name == 'release' && github.event.action == 'published'
  35. steps:
  36. - name: Download dists
  37. uses: actions/download-artifact@v5
  38. with:
  39. name: artifact
  40. path: dist
  41. - name: Publish
  42. uses: pypa/gh-action-pypi-publish@release/v1
  43. with:
  44. password: ${{ secrets.PYPI_API_TOKEN }}