release.yml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. name: Build and publish
  2. # Run on PR requests. And on master itself.
  3. on:
  4. push:
  5. branches:
  6. - main # just build the sdist skip release
  7. tags:
  8. - "*"
  9. pull_request: # also build on PRs touching some files
  10. paths:
  11. - ".github/workflows/release.yml"
  12. - "MANIFEST.in"
  13. - "pyproject.toml"
  14. jobs:
  15. build:
  16. name: Build
  17. runs-on: ubuntu-latest
  18. steps:
  19. - name: Checkout source
  20. uses: actions/checkout@v3
  21. - name: Set up Python
  22. uses: actions/setup-python@v4
  23. with:
  24. python-version: "3.10"
  25. - name: Build a source tarball
  26. run: |
  27. python -m pip install build
  28. python -m build
  29. - uses: actions/upload-artifact@v3
  30. with:
  31. path: ./dist/*
  32. retention-days: 5
  33. publish:
  34. name: Publish on GitHub and PyPI
  35. needs: [build]
  36. runs-on: ubuntu-latest
  37. # release on every tag
  38. if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/')
  39. steps:
  40. - uses: actions/download-artifact@v3
  41. with:
  42. name: artifact
  43. path: dist
  44. - name: Upload Github release
  45. id: upload-release-asset
  46. uses: softprops/action-gh-release@v1
  47. - name: Upload Release Assets to PyPI
  48. uses: pypa/gh-action-pypi-publish@release/v1
  49. with:
  50. password: ${{ secrets.PYPI_UPLOAD_TOKEN }}