release.yml 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. name: Publish
  2. # (tagged versions to PyPI, commits to TestPyPI)
  3. on:
  4. # Triggers the workflow on push events but only for the master branch
  5. push:
  6. branches: master
  7. tags:
  8. - '*'
  9. jobs:
  10. build-n-publish:
  11. name: Build and publish Python distributions to PyPI and TestPyPI
  12. runs-on: ubuntu-latest
  13. steps:
  14. - uses: actions/checkout@master
  15. with:
  16. fetch-depth: 0
  17. - name: Set up Python 3.10
  18. uses: actions/setup-python@v3
  19. with:
  20. python-version: "3.10"
  21. - name: Install pypa/build
  22. run: >-
  23. python -m
  24. pip install
  25. build
  26. --user
  27. - name: Build a binary wheel and a source tarball
  28. run: >-
  29. python -m
  30. build
  31. --sdist
  32. --wheel
  33. --outdir dist/
  34. .
  35. - name: Publish distribution to Test PyPI
  36. uses: pypa/gh-action-pypi-publish@release/v1
  37. with:
  38. password: ${{ secrets.TEST_PYPI_API_TOKEN }}
  39. repository_url: https://test.pypi.org/legacy/
  40. skip_existing: true
  41. - name: Publish distribution to PyPI
  42. if: startsWith(github.ref, 'refs/tags')
  43. uses: pypa/gh-action-pypi-publish@release/v1
  44. with:
  45. password: ${{ secrets.PYPI_API_TOKEN }}