cd.yml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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.11'
  18. - name: Install Poetry
  19. run: |
  20. curl -sSL https://install.python-poetry.org | python3 -
  21. echo "$HOME/.local/bin" >> $GITHUB_PATH
  22. - name: Install dependencies
  23. run: poetry install
  24. - name: Build a binary wheel and a source tarball
  25. run: poetry build
  26. - name: Publish distribution 📦 to Test PyPI
  27. uses: pypa/gh-action-pypi-publish@release/v1
  28. with:
  29. repository_url: https://test.pypi.org/legacy/
  30. - name: Publish distribution 📦 to PyPI
  31. if: startsWith(github.ref, 'refs/tags')
  32. uses: pypa/gh-action-pypi-publish@release/v1