|
| 1 | +name: Build and release to PyPI |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + reduce-release-tag: |
| 6 | + description: Reduce tag to build |
| 7 | + required: true |
| 8 | + default: v4.14 |
| 9 | + version-tag: |
| 10 | + description: Python package version to release to PyPI (without 'v') |
| 11 | + required: true |
| 12 | + default: 4.14.post7 |
| 13 | + dry-run: |
| 14 | + description: Dry run |
| 15 | + type: boolean |
| 16 | + default: false |
| 17 | + exclude-types: |
| 18 | + description: Commit types to exclude from the changelog |
| 19 | + required: false |
| 20 | + default: build,docs,style,other |
| 21 | + |
| 22 | +jobs: |
| 23 | + build-linux: |
| 24 | + runs-on: ${{ matrix.platform.runner }} |
| 25 | + strategy: |
| 26 | + matrix: |
| 27 | + platform: |
| 28 | + - runner: ubuntu-24.04 |
| 29 | + target: manylinux_2_17_x86_64.manylinux2014_x86_64 |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + - name: Install dependencies |
| 33 | + run: | |
| 34 | + pip install uv --user --break-system-packages |
| 35 | + uv tool install build |
| 36 | + uv tool install wheel |
| 37 | + - name: Build app |
| 38 | + run: | |
| 39 | + bash build_reduce_linux.sh ${{ inputs.reduce-release-tag }} |
| 40 | + - name: Build python wheel |
| 41 | + run: | |
| 42 | + bash build_python.sh wheel ${{ inputs.version-tag }} ${{ matrix.platform.target }} |
| 43 | + - name: Upload wheels |
| 44 | + uses: actions/upload-artifact@v4 |
| 45 | + with: |
| 46 | + name: wheel-linux-${{ matrix.platform.target }} |
| 47 | + path: build_python/dist/*.whl |
| 48 | + |
| 49 | + build-macos: |
| 50 | + runs-on: ${{ matrix.platform.runner }} |
| 51 | + strategy: |
| 52 | + matrix: |
| 53 | + platform: |
| 54 | + # Use the oldest version possible to maximize compatibility |
| 55 | + - runner: macos-13 |
| 56 | + target: macosx_10_12_x86_64 |
| 57 | + target_env: 10.12 |
| 58 | + - runner: macos-15 |
| 59 | + target: macosx_11_0_arm64 |
| 60 | + target_env: 11.0 |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + - name: Install dependencies |
| 64 | + run: | |
| 65 | + uname -a |
| 66 | + pip install uv --break-system-packages |
| 67 | + uv tool update-shell |
| 68 | + uv tool install build |
| 69 | + uv tool install wheel |
| 70 | + brew install gnu-sed |
| 71 | + - name: Build app |
| 72 | + run: | |
| 73 | + MACOSX_DEPLOYMENT_TARGET=${{ matrix.platform.target_env }} bash build_reduce_mac.sh ${{ inputs.reduce-release-tag }} |
| 74 | + - name: Build python wheel |
| 75 | + run: | |
| 76 | + export PATH="/Users/runner/.local/bin:$PATH" |
| 77 | + bash build_python.sh wheel ${{ inputs.version-tag }} ${{ matrix.platform.target }} |
| 78 | + - name: Upload wheels |
| 79 | + uses: actions/upload-artifact@v4 |
| 80 | + with: |
| 81 | + path: build_python/dist/*.whl |
| 82 | + name: wheel-macos-${{ matrix.platform.target }} |
| 83 | + |
| 84 | + test-ubuntu: |
| 85 | + runs-on: ${{ matrix.os }} |
| 86 | + strategy: |
| 87 | + matrix: |
| 88 | + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] |
| 89 | + os: [ubuntu-20.04, ubuntu-22.04, ubuntu-24.04] |
| 90 | + target: [manylinux_2_17_x86_64.manylinux2014_x86_64] |
| 91 | + # python-version: ['3.8'] |
| 92 | + # os: [ubuntu-20.04] |
| 93 | + needs: [build-linux] |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + - uses: actions/download-artifact@v4 |
| 97 | + with: |
| 98 | + path: dist |
| 99 | + name: wheel-linux-${{ matrix.target }} |
| 100 | + - uses: actions/setup-python@v5 |
| 101 | + with: |
| 102 | + python-version: ${{ matrix.python-version }} |
| 103 | + - name: Test wheel |
| 104 | + run: | |
| 105 | + pip install uv --break-system-packages |
| 106 | + uv venv |
| 107 | + source .venv/bin/activate |
| 108 | + uv pip install -r requirements_test.txt |
| 109 | + uv pip install dist/*.whl |
| 110 | + pytest |
| 111 | +
|
| 112 | + test-macos: |
| 113 | + runs-on: ${{ matrix.platform.runner }} |
| 114 | + strategy: |
| 115 | + matrix: |
| 116 | + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] |
| 117 | + platform: |
| 118 | + - runner: macos-12 |
| 119 | + target: macosx_10_12_x86_64 |
| 120 | + - runner: macos-13 |
| 121 | + target: macosx_10_12_x86_64 |
| 122 | + - runner: macos-14 |
| 123 | + target: macosx_11_0_arm64 |
| 124 | + - runner: macos-15 |
| 125 | + target: macosx_11_0_arm64 |
| 126 | + needs: [build-macos] |
| 127 | + steps: |
| 128 | + - uses: actions/checkout@v4 |
| 129 | + - uses: actions/download-artifact@v4 |
| 130 | + with: |
| 131 | + path: dist |
| 132 | + name: wheel-macos-${{ matrix.platform.target }} |
| 133 | + - uses: actions/setup-python@v5 |
| 134 | + with: |
| 135 | + python-version: ${{ matrix.python-version }} |
| 136 | + - name: Test wheel |
| 137 | + run: | |
| 138 | + pip install uv --break-system-packages |
| 139 | + uv venv |
| 140 | + source .venv/bin/activate |
| 141 | + uv pip install -r requirements_test.txt |
| 142 | + uv pip install dist/*.whl |
| 143 | + pytest |
| 144 | +
|
| 145 | + commit-changelog-and-release-github: |
| 146 | + needs: [test-ubuntu, test-macos] |
| 147 | + uses: deargen/workflows/.github/workflows/commit-changelog-and-release.yml@master |
| 148 | + with: |
| 149 | + version-tag: ${{ github.event.inputs.version-tag }} |
| 150 | + dry-run: ${{ github.event.inputs.dry-run == 'true' }} |
| 151 | + changelog-path: docs/CHANGELOG.md |
| 152 | + exclude-types: ${{ github.event.inputs.exclude-types }} |
| 153 | + |
| 154 | + release-to-pypi: |
| 155 | + name: Release to PyPI |
| 156 | + if: ${{ github.event.inputs.dry-run == 'false' }} |
| 157 | + runs-on: ubuntu-24.04 |
| 158 | + needs: [commit-changelog-and-release-github] |
| 159 | + steps: |
| 160 | + - uses: actions/download-artifact@v4 |
| 161 | + with: |
| 162 | + path: dist |
| 163 | + pattern: wheel-* |
| 164 | + merge-multiple: true |
| 165 | + - name: Build and upload to PyPI |
| 166 | + run: | |
| 167 | + pip install uv --break-system-packages |
| 168 | + uv tool install twine |
| 169 | + twine upload dist/* -u __token__ -p ${{ secrets.PYPI_API_TOKEN }} --non-interactive |
0 commit comments