build-publish.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. push:
  10. branches: [master]
  11. pull_request:
  12. branches: [master]
  13. release:
  14. types: [published]
  15. jobs:
  16. build-wheels:
  17. runs-on: ubuntu-latest
  18. steps:
  19. - uses: actions/checkout@v3
  20. - name: Set up Python
  21. uses: actions/setup-python@v4
  22. with:
  23. python-version: '3.x'
  24. - name: Install pypa/build
  25. run: >-
  26. python -m
  27. pip install -U
  28. build
  29. - name: Build a binary wheel and a source tarball
  30. run: >-
  31. python -m
  32. build
  33. --sdist
  34. --wheel
  35. --outdir dist/
  36. .
  37. - name: Store wheels
  38. uses: actions/upload-artifact@v3
  39. with:
  40. path: dist
  41. publish:
  42. runs-on: ubuntu-latest
  43. needs:
  44. - build-wheels
  45. if: github.event_name == 'release' && github.event.action == 'published'
  46. steps:
  47. - name: Download dists
  48. uses: actions/download-artifact@v3
  49. with:
  50. name: artifact
  51. path: dist
  52. - name: Publish
  53. uses: pypa/gh-action-pypi-publish@release/v1
  54. with:
  55. password: ${{ secrets.PYPI_API_TOKEN }}