cd.yml 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. name: Publish Python 🐍 distributions 📦 to PyPI and TestPyPI
  2. on:
  3. release:
  4. types: [published] # This will trigger the workflow when you create a new release
  5. jobs:
  6. build-n-publish:
  7. name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
  8. runs-on: ubuntu-latest
  9. permissions:
  10. # IMPORTANT: this permission is mandatory for trusted publishing
  11. id-token: write
  12. steps:
  13. - uses: actions/checkout@v2
  14. - name: Set up Python
  15. uses: actions/setup-python@v2
  16. with:
  17. python-version: 3.10
  18. - name: Install pep517
  19. run: |
  20. python -m pip install pep517 --user
  21. - name: Build a binary wheel and a source tarball
  22. run: python -m pep517.build .
  23. - name: Publish distribution 📦 to Test PyPI
  24. uses: pypa/gh-action-pypi-publish@release/v1
  25. with:
  26. repository_url: https://test.pypi.org/legacy/
  27. - name: Publish distribution 📦 to PyPI
  28. if: startsWith(github.ref, 'refs/tags')
  29. uses: pypa/gh-action-pypi-publish@release/v1