|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: ['v*'] |
| 6 | + |
| 7 | +jobs: |
| 8 | + test: |
| 9 | + name: Test (${{ matrix.os }}, Python ${{ matrix.python-version }}) |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 15 | + python-version: ['3.9', '3.10', '3.11', '3.12'] |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + submodules: recursive |
| 21 | + |
| 22 | + - name: Set up Python |
| 23 | + uses: actions/setup-python@v5 |
| 24 | + with: |
| 25 | + python-version: ${{ matrix.python-version }} |
| 26 | + cache: 'pip' |
| 27 | + |
| 28 | + - name: Install system dependencies (Linux) |
| 29 | + if: runner.os == 'Linux' |
| 30 | + run: sudo apt-get update && sudo apt-get install -y cmake ninja-build libssl-dev |
| 31 | + |
| 32 | + - name: Install system dependencies (macOS) |
| 33 | + if: runner.os == 'macOS' |
| 34 | + run: brew install cmake ninja |
| 35 | + |
| 36 | + - name: Install system dependencies (Windows) |
| 37 | + if: runner.os == 'Windows' |
| 38 | + run: choco install cmake -y |
| 39 | + |
| 40 | + - name: Setup MSVC (Windows) |
| 41 | + if: runner.os == 'Windows' |
| 42 | + uses: microsoft/setup-msbuild@v2 |
| 43 | + |
| 44 | + - name: Setup vendor dependencies |
| 45 | + run: | |
| 46 | + chmod +x scripts/setup_vendors.sh |
| 47 | + ./scripts/setup_vendors.sh |
| 48 | + shell: bash |
| 49 | + |
| 50 | + - name: Install package |
| 51 | + run: pip install -e ".[dev]" |
| 52 | + |
| 53 | + - name: Lint |
| 54 | + run: ruff check src/ tests/ |
| 55 | + |
| 56 | + - name: Run tests |
| 57 | + run: pytest tests/ -v --cov=httpmorph --cov-report=xml |
| 58 | + |
| 59 | + build-wheels: |
| 60 | + name: Build Wheels (${{ matrix.os }}) |
| 61 | + needs: test |
| 62 | + runs-on: ${{ matrix.os }} |
| 63 | + strategy: |
| 64 | + matrix: |
| 65 | + os: [ubuntu-latest, macos-latest, windows-latest] |
| 66 | + |
| 67 | + steps: |
| 68 | + - uses: actions/checkout@v4 |
| 69 | + with: |
| 70 | + submodules: recursive |
| 71 | + |
| 72 | + - name: Build wheels |
| 73 | + uses: pypa/cibuildwheel@v2.16.2 |
| 74 | + env: |
| 75 | + CIBW_BUILD: cp39-* cp310-* cp311-* cp312-* |
| 76 | + CIBW_SKIP: "*-musllinux_*" |
| 77 | + CIBW_BEFORE_ALL_LINUX: apt-get update && apt-get install -y cmake ninja-build libssl-dev |
| 78 | + CIBW_BEFORE_ALL_MACOS: brew install cmake ninja |
| 79 | + |
| 80 | + - uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: wheels-${{ matrix.os }} |
| 83 | + path: ./wheelhouse/*.whl |
| 84 | + |
| 85 | + publish: |
| 86 | + name: Publish Release |
| 87 | + needs: build-wheels |
| 88 | + runs-on: ubuntu-latest |
| 89 | + |
| 90 | + steps: |
| 91 | + - uses: actions/checkout@v4 |
| 92 | + |
| 93 | + - name: Download wheels |
| 94 | + uses: actions/download-artifact@v4 |
| 95 | + with: |
| 96 | + path: dist/ |
| 97 | + |
| 98 | + - name: Flatten wheels |
| 99 | + run: | |
| 100 | + mkdir -p wheels |
| 101 | + find dist/ -name "*.whl" -exec cp {} wheels/ \; |
| 102 | + ls -lh wheels/ |
| 103 | +
|
| 104 | + - name: Create GitHub Release |
| 105 | + uses: softprops/action-gh-release@v1 |
| 106 | + with: |
| 107 | + files: wheels/*.whl |
| 108 | + generate_release_notes: true |
| 109 | + env: |
| 110 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 111 | + |
| 112 | + - name: Publish to PyPI |
| 113 | + if: env.PYPI_API_TOKEN != '' |
| 114 | + env: |
| 115 | + TWINE_USERNAME: __token__ |
| 116 | + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} |
| 117 | + run: | |
| 118 | + pip install twine |
| 119 | + twine upload wheels/*.whl --skip-existing |
0 commit comments