python-distributions.yml 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. name: Build Python distributions
  2. on:
  3. push:
  4. pull_request:
  5. schedule:
  6. - cron: "0 6 * * *" # Daily 6AM UTC build
  7. jobs:
  8. build-wheels:
  9. runs-on: ${{ matrix.os }}
  10. strategy:
  11. matrix:
  12. os: [ubuntu-latest, macos-latest, windows-latest]
  13. python-prefix: [pp, cp]
  14. fail-fast: true
  15. steps:
  16. - uses: actions/checkout@v4
  17. - uses: actions/setup-python@v5
  18. with:
  19. cache: pip
  20. - name: Install dependencies
  21. run: |
  22. python -m pip install --upgrade pip
  23. pip install setuptools wheel cibuildwheel setuptools-rust
  24. - name: Set up QEMU
  25. uses: docker/setup-qemu-action@v3
  26. if: "matrix.os == 'ubuntu-latest'"
  27. - name: Build wheels
  28. run: python -m cibuildwheel --output-dir wheelhouse
  29. env:
  30. CIBW_BUILD: "${{ matrix.python-prefix }}*"
  31. - name: Upload wheels
  32. uses: actions/upload-artifact@v4
  33. with:
  34. name: artifact-${{ matrix.os }}-${{ matrix.python-prefix }}
  35. path: ./wheelhouse/*.whl
  36. build-sdist:
  37. runs-on: ubuntu-latest
  38. steps:
  39. - uses: actions/checkout@v4
  40. - uses: actions/setup-python@v5
  41. with:
  42. cache: pip
  43. - name: Install dependencies
  44. run: |
  45. python -m pip install --upgrade pip
  46. pip install build
  47. - name: Build sdist
  48. run: python -m build --sdist
  49. - name: Upload sdist
  50. uses: actions/upload-artifact@v4
  51. with:
  52. name: artifact-source
  53. path: ./dist/*.tar.gz
  54. test-sdist:
  55. needs:
  56. - build-sdist
  57. runs-on: ubuntu-latest
  58. steps:
  59. - uses: actions/setup-python@v5
  60. with:
  61. cache: pip
  62. - name: Install dependencies
  63. run: |
  64. python -m pip install --upgrade pip
  65. pip install twine
  66. - name: Download sdist
  67. uses: actions/download-artifact@v4
  68. with:
  69. name: artifact-source
  70. path: dist
  71. - name: Test sdist
  72. run: twine check dist/*
  73. - name: Test installation from sdist
  74. run: pip install dist/*.tar.gz
  75. publish:
  76. runs-on: ubuntu-latest
  77. needs:
  78. - build-wheels
  79. - build-sdist
  80. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/dulwich-')
  81. permissions:
  82. id-token: write
  83. environment:
  84. name: pypi
  85. url: https://pypi.org/p/dulwich
  86. steps:
  87. - name: Download distributions
  88. uses: actions/download-artifact@v4
  89. with:
  90. merge-multiple: true
  91. pattern: artifact-*
  92. path: dist
  93. - name: Publish package distributions to PyPI
  94. uses: pypa/gh-action-pypi-publish@release/v1