Skip to content

Build Release and Publish windows wheels #453

Build Release and Publish windows wheels

Build Release and Publish windows wheels #453

name: Build Release and Publish windows wheels
on:
workflow_dispatch:
schedule:
# Runs at 11:00 AM UTC, which is 3:00 AM PST (UTC-8)
- cron: '0 11 * * *'
# Ensure that only a single job or workflow using the same
# concurrency group will run at a time. This would cancel
# any in-progress jobs in the same github workflow and github
# ref (e.g. refs/heads/main or refs/pull/<pr_number>/merge).
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_x64_msvc:
name: windows x86_64 msvc Build
runs-on: windows-2022
defaults:
run:
shell: bash
# Elevates permissions for `GITHUB_TOKEN`'s content scope (to allow this action to make a release)
permissions:
contents: write
# Don't run this in everyone's forks on schedule but allow to run via dispatch.
if: ${{ github.repository_owner == 'llvm' || github.event_name != 'schedule' }}
strategy:
matrix:
package: [torch-mlir]
py_version: ['3.10', '3.11', '3.12']
include:
- py_version: '3.10'
py_tag: 'cp310-cp310'
- py_version: '3.11'
py_tag: 'cp311-cp311'
- py_version: '3.12'
py_tag: 'cp312-cp312'
steps:
- name: Checkout torch-mlir
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
repository: llvm/torch-mlir
ref: refs/heads/main
submodules: 'true'
- name: Setup workspace and python
uses: ./.github/actions/setup-build
with:
python-version: ${{ matrix.py_version }}
- name: Verify python version
run: |
# extract python major.minor version, for example, extract 3.10 from version 3.10.12
actual_version=$(python --version | cut -d' ' -f2 | cut -d'.' -f1,2)
expected_version="${{ matrix.py_version }}"
if [ "$actual_version" != "$expected_version" ]; then
echo "ERROR: Python version mismatch! Expected $expected_version but got $actual_version"
exit 1
fi
echo "Python version verified: Expected $expected_version and got $actual_version"
- name: "Configuring MSVC"
uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0
- name: Build torch-mlir
run: |
cd $GITHUB_WORKSPACE
./build_tools/python_deploy/build_windows_ci.sh
- name: Build Python wheels and smoke test
run: |
tm_package_version="$(printf '%(%Y%m%d)T.${{ github.run_number }}')"
echo "tm_package_version=${tm_package_version}" >> $GITHUB_ENV
printf "TORCH_MLIR_PYTHON_PACKAGE_VERSION=%s\n" ${tm_package_version} > ./torch_mlir_package_version
pip install delvewheel
TORCH_MLIR_PYTHON_PACKAGE_VERSION=${tm_package_version} TORCH_MLIR_CMAKE_BUILD_DIR="build" TORCH_MLIR_CMAKE_ALREADY_BUILT=1 python setup.py bdist_wheel
delvewheel repair --add-path ./build/tools/torch-mlir/python_packages/torch_mlir/torch_mlir/_mlir_libs --add-dll TorchMLIRAggregateCAPI.dll --no-dll 'c10.dll;torch_python.dll;torch_cpu.dll' -v dist/torch_mlir*.whl -w dist
- name: Upload python wheels
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
if-no-files-found: error
name: snapshot-${{ matrix.package }}-${{ matrix.py_tag }}-${{ env.tm_package_version }}
path: dist
- name: Release python wheels
uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0
with:
artifacts: dist/*.whl
token: "${{ secrets.GITHUB_TOKEN }}"
tag: "dev-wheels"
name: "dev-wheels"
body: "Automatic snapshot release of torch-mlir python wheels."
removeArtifacts: false
allowUpdates: true
replacesArtifacts: true
makeLatest: true
artifactErrorsFailBuild: true