python-distributions.yml 2.8 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. - name: Install native dependencies (Ubuntu)
  19. run: sudo apt-get update && sudo apt-get install -y libgpgme-dev libgpg-error-dev
  20. if: "matrix.os == 'ubuntu-latest'"
  21. - name: Install native dependencies (MacOS)
  22. run: brew install swig gpgme
  23. if: "matrix.os == 'macos-latest'"
  24. - name: Install dependencies
  25. run: |
  26. python -m pip install --upgrade pip
  27. pip install setuptools wheel cibuildwheel setuptools-rust
  28. - name: Set up QEMU
  29. uses: docker/setup-qemu-action@v3
  30. if: "matrix.os == 'ubuntu-latest'"
  31. - name: Build wheels
  32. run: python -m cibuildwheel --output-dir wheelhouse
  33. env:
  34. CIBW_BUILD: "${{ matrix.python-prefix }}*"
  35. - name: Upload wheels
  36. uses: actions/upload-artifact@v4
  37. with:
  38. name: artifact-${{ matrix.os }}-${{ matrix.python-prefix }}
  39. path: ./wheelhouse/*.whl
  40. build-sdist:
  41. runs-on: ubuntu-latest
  42. steps:
  43. - uses: actions/checkout@v4
  44. - uses: actions/setup-python@v5
  45. - name: Install dependencies
  46. run: |
  47. python -m pip install --upgrade pip
  48. pip install build
  49. - name: Build sdist
  50. run: python -m build --sdist
  51. - name: Upload sdist
  52. uses: actions/upload-artifact@v4
  53. with:
  54. name: artifact-source
  55. path: ./dist/*.tar.gz
  56. test-sdist:
  57. needs:
  58. - build-sdist
  59. runs-on: ubuntu-latest
  60. steps:
  61. - uses: actions/setup-python@v5
  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