python-distributions.yml 2.6 KB

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