publish-to-pypi.yml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. name: Publish Python 🐍 distribution 📦 to PyPI
  2. on: push
  3. env:
  4. G4F_VERSION: ${{ github.ref_name }}
  5. jobs:
  6. build:
  7. name: Build distribution 📦
  8. if: startsWith(github.ref, 'refs/tags/')
  9. runs-on: ubuntu-latest
  10. steps:
  11. - uses: actions/checkout@v4
  12. - name: Set up Python
  13. uses: actions/setup-python@v4
  14. with:
  15. python-version: "3.x"
  16. - name: Install pypa/build
  17. run: >-
  18. python3 -m
  19. pip install
  20. build
  21. --user
  22. - name: Build a binary wheel and a source tarball
  23. run: python3 -m build
  24. - name: Store the distribution packages
  25. uses: actions/upload-artifact@v3
  26. with:
  27. name: python-package-distributions
  28. path: dist/
  29. publish-to-pypi:
  30. name: >-
  31. Publish distribution on PyPI 🐍
  32. if: startsWith(github.ref, 'refs/tags/')
  33. needs:
  34. - build
  35. runs-on: ubuntu-latest
  36. environment:
  37. name: pypi
  38. url: https://pypi.org/p/g4f
  39. permissions:
  40. id-token: write
  41. steps:
  42. - name: Download all the dists
  43. uses: actions/download-artifact@v3
  44. with:
  45. name: python-package-distributions
  46. path: dist/
  47. - name: Publish distribution 📦 to PyPI
  48. uses: pypa/gh-action-pypi-publish@release/v1