python-distributions.yml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 native dependencies (Ubuntu)
  21. run: sudo apt-get update && sudo apt-get install -y libgpgme-dev libgpg-error-dev
  22. if: "matrix.os == 'ubuntu-latest'"
  23. - name: Install native dependencies (MacOS)
  24. run: brew install swig gpgme
  25. if: "matrix.os == 'macos-latest'"
  26. - name: Install dependencies
  27. run: |
  28. python -m pip install --upgrade pip
  29. pip install setuptools wheel cibuildwheel setuptools-rust
  30. - name: Set up QEMU
  31. uses: docker/setup-qemu-action@v3
  32. if: "matrix.os == 'ubuntu-latest'"
  33. - name: Build wheels
  34. run: python -m cibuildwheel --output-dir wheelhouse
  35. env:
  36. CIBW_BUILD: "${{ matrix.python-prefix }}*"
  37. - name: Upload wheels
  38. uses: actions/upload-artifact@v4
  39. with:
  40. name: artifact-${{ matrix.os }}-${{ matrix.python-prefix }}
  41. path: ./wheelhouse/*.whl
  42. build-sdist:
  43. runs-on: ubuntu-latest
  44. steps:
  45. - uses: actions/checkout@v4
  46. - uses: actions/setup-python@v5
  47. with:
  48. cache: pip
  49. - name: Install dependencies
  50. run: |
  51. python -m pip install --upgrade pip
  52. pip install build
  53. - name: Build sdist
  54. run: python -m build --sdist
  55. - name: Upload sdist
  56. uses: actions/upload-artifact@v4
  57. with:
  58. name: artifact-source
  59. path: ./dist/*.tar.gz
  60. test-sdist:
  61. needs:
  62. - build-sdist
  63. runs-on: ubuntu-latest
  64. steps:
  65. - uses: actions/setup-python@v5
  66. with:
  67. cache: pip
  68. - name: Install dependencies
  69. run: |
  70. python -m pip install --upgrade pip
  71. pip install twine
  72. - name: Download sdist
  73. uses: actions/download-artifact@v4
  74. with:
  75. name: artifact-source
  76. path: dist
  77. - name: Test sdist
  78. run: twine check dist/*
  79. - name: Test installation from sdist
  80. run: pip install dist/*.tar.gz
  81. publish:
  82. runs-on: ubuntu-latest
  83. needs:
  84. - build-wheels
  85. - build-sdist
  86. if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/dulwich-')
  87. permissions:
  88. id-token: write
  89. environment:
  90. name: pypi
  91. url: https://pypi.org/p/dulwich
  92. steps:
  93. - name: Download distributions
  94. uses: actions/download-artifact@v4
  95. with:
  96. merge-multiple: true
  97. pattern: artifact-*
  98. path: dist
  99. - name: Publish package distributions to PyPI
  100. uses: pypa/gh-action-pypi-publish@release/v1