publish-release.yml 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. on:
  2. push:
  3. tags:
  4. - "v*" # Push events to matching `v*` version srings. e.g. v1.0, v20.15.10
  5. name: Create and Publish Release
  6. jobs:
  7. build:
  8. name: Build distribution
  9. runs-on: ubuntu-latest
  10. steps:
  11. - uses: actions/checkout@v4
  12. with:
  13. submodules: recursive
  14. fetch-depth: 0
  15. - name: Set up Python
  16. uses: actions/setup-python@v5
  17. with:
  18. python-version: '3.x'
  19. - name: Install release dependencies
  20. run: |
  21. python -m pip install --upgrade pip
  22. pip install --upgrade setuptools wheel build
  23. - name: Get release notes
  24. id: release_notes
  25. run: |
  26. # By default, GH Actions checkout will only fetch a single commit.
  27. # For us to extract the release notes, we need to fetch the tags
  28. # and tag annotations as well.
  29. # https://github.com/actions/checkout/issues/290
  30. git fetch --tags --force
  31. TAG_NAME=${GITHUB_REF/refs\/tags\//}
  32. echo "$(git tag -l --format='%(contents)' $TAG_NAME)" > "${{ runner.temp }}/CHANGELOG.md"
  33. - name: Create GitHub release
  34. id: create_release
  35. uses: actions/create-release@v1
  36. env:
  37. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  38. with:
  39. tag_name: ${{ github.ref }}
  40. release_name: ${{ github.ref }}
  41. body_path: "${{ runner.temp }}/CHANGELOG.md"
  42. draft: false
  43. prerelease: false
  44. - name: Build a binary wheel and a source tarball
  45. run: python3 -m build
  46. - name: Store the distribution packages
  47. uses: actions/upload-artifact@v4
  48. with:
  49. name: python-package-distributions
  50. path: dist/
  51. publish-to-pypi:
  52. name: >-
  53. Publish Python 🐍 distribution 📦 to PyPI
  54. if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
  55. needs:
  56. - build
  57. runs-on: ubuntu-latest
  58. environment:
  59. name: pypi
  60. url: https://pypi.org/p/gflanguages
  61. permissions:
  62. id-token: write # IMPORTANT: mandatory for trusted publishing
  63. steps:
  64. - name: Download all the dists
  65. uses: actions/download-artifact@v4
  66. with:
  67. name: python-package-distributions
  68. path: dist/
  69. - name: Publish distribution 📦 to PyPI
  70. uses: pypa/gh-action-pypi-publish@v1.8.14
  71. with:
  72. # repository-url: https://test.pypi.org/legacy/ # for testing purposes
  73. verify-metadata: false # twine previously didn't verify metadata when uploading