Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Test PyPi Wheels on Windows | |
| on: | |
| push: | |
| branches: [ "main", "feat/win-compilation-test" ] | |
| workflow_dispatch: | |
| inputs: | |
| publish_target: | |
| description: 'Publish Destination' | |
| required: true | |
| default: 'testpypi' | |
| type: choice | |
| options: | |
| - testpypi | |
| - pypi | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref || '' }}-${{ github.base_ref || '' }}-${{ github.ref != 'refs/heads/main' || github.sha }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| compute_matrix: | |
| runs-on: [ linux_x64, ubuntu-slim ] | |
| outputs: | |
| matrix: ${{ steps.set.outputs.matrix }} | |
| steps: | |
| - id: set | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.publish_target }}" = "pypi" ]; then | |
| echo 'matrix={"include":[{"platform":"windows-2025"}]}' >> "$GITHUB_OUTPUT" | |
| else | |
| echo 'matrix={"include":[{"platform":"windows-amd"},{"platform":"windows-g9i"},{"platform":"windows-2022"},{"platform":"windows-2025"}]}' >> "$GITHUB_OUTPUT" | |
| fi | |
| build_wheels_linux_x64: | |
| needs: compute_matrix | |
| name: Build wheels on ${{ matrix.platform }} (x64) for TestPyPi | |
| strategy: | |
| fail-fast: true | |
| max-parallel: 1 | |
| matrix: ${{ fromJson(needs.compute_matrix.outputs.matrix) }} | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - name: Show env info | |
| run: | | |
| Get-CimInstance -ClassName Win32_Processor | |
| where cl | |
| & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -all -products * -prerelease -format json | |
| shell: powershell | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| submodules: recursive | |
| - name: Cleanup left marker files | |
| run: | | |
| git submodule foreach --recursive 'git reset --hard && git clean -ffdx' | |
| shell: powershell | |
| - name: Set up Python (for cibuildwheel controller) | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: '3.11' | |
| - name: Install cibuildwheel | |
| run: | | |
| pip install --upgrade pip | |
| pip install cibuildwheel==3.4.0 | |
| - name: Build wheels using cibuildwheel | |
| shell: powershell | |
| run: | | |
| python -m cibuildwheel --output-dir wheelhouse | |
| $wheels = Get-ChildItem wheelhouse/*.whl | Select-Object -ExpandProperty FullName | |
| if ($env:GITHUB_STEP_SUMMARY) { | |
| $wheels | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append | |
| } | |
| "wheels=$($wheels -join ' ')" | Out-File -FilePath $env:GITHUB_ENV -Append | |
| - name: Publish to PyPI | |
| if: success() | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ inputs.publish_target == 'pypi' && secrets.PYPI_API_TOKEN || secrets.TEST_PYPI_API_TOKEN }} | |
| TWINE_REPOSITORY_URL: ${{ inputs.publish_target == 'pypi' && 'https://upload.pypi.org/legacy/' || 'https://test.pypi.org/legacy/' }} | |
| run: | | |
| pip install twine | |
| twine upload --skip-existing --verbose wheelhouse/*.whl | |
| - name: Smoke test from PyPI | |
| if: success() | |
| shell: powershell | |
| env: | |
| PUBLISH_TARGET: ${{ inputs.publish_target || 'testpypi' }} | |
| run: | | |
| $wheel = Get-ChildItem wheelhouse/zvec-*.whl | Select-Object -First 1 | |
| $filename = $wheel.Name | |
| $version = [regex]::Match($filename, '^zvec-([^-]+)-').Groups[1].Value | |
| if ($env:PUBLISH_TARGET -eq 'testpypi') { | |
| $indexArgs = @("--index-url", "https://test.pypi.org/simple/", "--extra-index-url", "https://pypi.org/simple/") | |
| Write-Host "Waiting for zvec==$version to become available on TestPyPI..." | |
| } else { | |
| $indexArgs = @() | |
| Write-Host "Waiting for zvec==$version to become available on PyPI..." | |
| } | |
| $ErrorActionPreference = 'Continue' | |
| $PSNativeCommandUseErrorActionPreference = $false | |
| $found = $false | |
| for ($i = 1; $i -le 30; $i++) { | |
| python -m pip install @indexArgs --dry-run "zvec==$version" 1>$null 2>$null | |
| if ($LASTEXITCODE -eq 0) { | |
| Write-Host "Version $version is available." | |
| $found = $true | |
| break | |
| } | |
| Write-Host "Attempt $i/30: not yet available, retrying in 10s..." | |
| Start-Sleep -Seconds 10 | |
| } | |
| if (-not $found) { | |
| Write-Host "ERROR: Timed out waiting for zvec==$version." | |
| exit 1 | |
| } | |
| python -m venv test_env | |
| $venvPython = "test_env/Scripts/python.exe" | |
| & $venvPython -m pip install --upgrade pip | |
| & $venvPython -m pip install @indexArgs "zvec==$version" | |
| & $venvPython -c "import zvec; print('Import OK:', zvec.__version__)" | |