python-distributions.yml 3.0 KB

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