Release AIKernel.Cuda13.0 v0.1.2 external accelerator boundary (#3) #1
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: publish-python | |
| on: | |
| push: | |
| tags: | |
| - "v*" | |
| - "py-aikernel-cuda13-libtorch2-12-win-x64-*" | |
| workflow_dispatch: | |
| inputs: | |
| channel: | |
| description: Publish channel | |
| required: true | |
| default: stable | |
| type: choice | |
| options: | |
| - stable | |
| - dev | |
| version: | |
| description: Python package version | |
| required: true | |
| default: 0.1.0 | |
| managed_package_version: | |
| description: AIKernel managed dependency version | |
| required: true | |
| default: 0.1.0 | |
| release_tag: | |
| description: GitHub Release tag for dev wheels | |
| required: false | |
| default: v0.1.0-python-dev | |
| libtorch_path: | |
| description: Path to LibTorch 2.12.0 + CUDA 13.0 on the self-hosted Windows runner | |
| required: true | |
| default: runtime/win-x64/libtorch | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-python: | |
| name: Build Python wheel | |
| runs-on: [self-hosted, Windows, X64, CUDA13] | |
| outputs: | |
| channel: ${{ steps.meta.outputs.channel }} | |
| defaults: | |
| run: | |
| working-directory: python | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Resolve publish metadata | |
| id: meta | |
| shell: pwsh | |
| run: | | |
| $channel = "${{ github.event.inputs.channel }}" | |
| if ([string]::IsNullOrWhiteSpace($channel)) { | |
| $channel = "stable" | |
| } | |
| $version = "${{ github.event.inputs.version }}" | |
| if ([string]::IsNullOrWhiteSpace($version)) { | |
| $tag = "${{ github.ref_name }}" | |
| if ($tag.StartsWith("v")) { | |
| $version = $tag.Substring(1) | |
| } elseif ($tag -match "(\d+\.\d+\.\d+(?:[A-Za-z0-9.\-]*)?)$") { | |
| $version = $Matches[1] | |
| } else { | |
| throw "Unable to resolve Python package version from tag '$tag'." | |
| } | |
| } | |
| $managedPackageVersion = "${{ github.event.inputs.managed_package_version }}" | |
| if ([string]::IsNullOrWhiteSpace($managedPackageVersion)) { | |
| $managedPackageVersion = $version | |
| } | |
| $releaseTag = "${{ github.event.inputs.release_tag }}" | |
| if ([string]::IsNullOrWhiteSpace($releaseTag)) { | |
| $releaseTag = "${{ github.ref_name }}" | |
| } | |
| $libtorchPath = "${{ github.event.inputs.libtorch_path }}" | |
| if ([string]::IsNullOrWhiteSpace($libtorchPath)) { | |
| $libtorchPath = "runtime/win-x64/libtorch" | |
| } | |
| "channel=$channel" >> $env:GITHUB_OUTPUT | |
| "version=$version" >> $env:GITHUB_OUTPUT | |
| "managed_package_version=$managedPackageVersion" >> $env:GITHUB_OUTPUT | |
| "release_tag=$releaseTag" >> $env:GITHUB_OUTPUT | |
| "libtorch_path=$libtorchPath" >> $env:GITHUB_OUTPUT | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install build tools | |
| run: py -m pip install --upgrade build twine pytest | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 10.0.x | |
| - name: Configure native bridge | |
| working-directory: .. | |
| env: | |
| AIKERNEL_LIBTORCH_PATH: ${{ steps.meta.outputs.libtorch_path }} | |
| run: cmake -S native -B native/build/win-x64 -A x64 | |
| - name: Build native bridge | |
| working-directory: .. | |
| env: | |
| AIKERNEL_LIBTORCH_PATH: ${{ steps.meta.outputs.libtorch_path }} | |
| run: cmake --build native/build/win-x64 --config Release | |
| - name: Restore managed capability | |
| working-directory: .. | |
| run: dotnet restore AIKernel.Cuda13.0.Libtorch2.12.win-x64.slnx -p:AIKernelPackageVersion=${{ steps.meta.outputs.managed_package_version }} | |
| - name: Build managed capability | |
| working-directory: .. | |
| run: dotnet build AIKernel.Cuda13.0.Libtorch2.12.win-x64.slnx -c Release --no-restore -p:Version=${{ steps.meta.outputs.managed_package_version }} -p:AIKernelPackageVersion=${{ steps.meta.outputs.managed_package_version }} | |
| - name: Stage lightweight binaries | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force src/aikernel_cuda13_libtorch2_12_win_x64/managed | Out-Null | |
| New-Item -ItemType Directory -Force src/aikernel_cuda13_libtorch2_12_win_x64/native/win-x64 | Out-Null | |
| Copy-Item ../src/AIKernel.Cuda13.0.Libtorch2.12.win-x64/bin/Release/net10.0/AIKernel.Cuda13.0.Libtorch2.12.win-x64.dll src/aikernel_cuda13_libtorch2_12_win_x64/managed/ | |
| Copy-Item ../native/build/win-x64/Release/libtorch_bridge.dll src/aikernel_cuda13_libtorch2_12_win_x64/native/win-x64/ | |
| - name: Apply package channel and version | |
| shell: pwsh | |
| run: | | |
| $pyproject = Get-Content pyproject.toml -Raw | |
| $init = Get-Content src/aikernel_cuda13_libtorch2_12_win_x64/__init__.py -Raw | |
| if ("${{ steps.meta.outputs.channel }}" -eq "dev") { | |
| $pyproject = $pyproject -replace 'name = "aikernel-cuda13-libtorch2-12-win-x64"', 'name = "aikernel-cuda13-libtorch2-12-win-x64-dev"' | |
| $init = $init -replace 'PACKAGE_NAME = "aikernel-cuda13-libtorch2-12-win-x64"', 'PACKAGE_NAME = "aikernel-cuda13-libtorch2-12-win-x64-dev"' | |
| } | |
| $pyproject = $pyproject -replace 'version = "[^"]+"', 'version = "${{ steps.meta.outputs.version }}"' | |
| $init = $init -replace '__version__ = "[^"]+"', '__version__ = "${{ steps.meta.outputs.version }}"' | |
| Set-Content pyproject.toml -Value $pyproject -NoNewline | |
| Set-Content src/aikernel_cuda13_libtorch2_12_win_x64/__init__.py -Value $init -NoNewline | |
| - name: Test Python package | |
| run: py -m pytest | |
| - name: Build wheel | |
| run: py -m build --wheel | |
| - name: Check wheel | |
| run: py -m twine check dist/* | |
| - name: Upload stable wheel artifact | |
| if: steps.meta.outputs.channel == 'stable' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pypi-dist-aikernel-cuda13-libtorch2-12-win-x64 | |
| path: python/dist/* | |
| if-no-files-found: error | |
| - name: Upload development wheel to GitHub Release | |
| if: steps.meta.outputs.channel == 'dev' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ steps.meta.outputs.release_tag }} | |
| prerelease: true | |
| files: python/dist/* | |
| body: | | |
| Development Python wheel for AIKernel CUDA Capability tooling. | |
| Stable Python packages are published to PyPI. This GitHub Release | |
| asset is intended for CI/CD and compatibility testing. | |
| publish-stable-python: | |
| name: Publish stable wheel to PyPI | |
| runs-on: ubuntu-latest | |
| needs: build-python | |
| if: needs.build-python.outputs.channel == 'stable' | |
| environment: | |
| name: pypi | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Download stable wheel artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: pypi-dist-aikernel-cuda13-libtorch2-12-win-x64 | |
| path: dist | |
| - name: Show trusted publisher claims | |
| run: | | |
| echo "PyPI project: aikernel-cuda13-libtorch2-12-win-x64" | |
| echo "Expected owner: AIKernel-NET" | |
| echo "Expected repository: AIKernel.Cuda13.0" | |
| echo "Expected workflow: publish-python.yml" | |
| echo "Expected environment: pypi" | |
| echo "Actual repository: ${GITHUB_REPOSITORY}" | |
| echo "Actual workflow ref: ${GITHUB_WORKFLOW_REF}" | |
| echo "Actual ref: ${GITHUB_REF}" | |
| - name: Publish distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |