python-distributions.yml 2.9 KB

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