Skip to content

windows

windows #82

Workflow file for this run

name: windows
on:
workflow_dispatch:
jobs:
windows:
strategy:
fail-fast: false
matrix:
ver:
- { onnx: v1.18.0, python: 3.8.10, jdk: 11, gradle: 8.6 }
list:
- { win_ver: 2022, vs_name: vs2022, vs_ver: v143, vs_path: 'C:\Program Files\Microsoft Visual Studio\2022\Enterprise' }
arch:
[
x64,
x86,
arm64,
]
crt:
[
md,
mt,
]
runs-on: windows-${{ matrix.list.win_ver }}
name: windows-${{ matrix.list.vs_name }}-${{ matrix.arch }}-${{ matrix.crt }}
env:
BUILD_SCRIPT: build-onnxruntime-win.ps1
SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-windows-${{ matrix.list.vs_name }}-${{ matrix.arch }}-shared-${{ matrix.crt }}
STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-windows-${{ matrix.list.vs_name }}-${{ matrix.arch }}-static-${{ matrix.crt }}
JAVA_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-windows-${{ matrix.list.vs_name }}-java-${{ matrix.arch }}-${{ matrix.crt }}
steps:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '${{ matrix.ver.python }}'
# Setup JDK
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '${{ matrix.ver.jdk }}'
distribution: 'adopt'
- uses: gradle/actions/setup-gradle@v3
with:
gradle-version: ${{ matrix.ver.gradle }}
- name: test gradle
run: gradle --version
# 检出代码
- uses: actions/checkout@v4
# 检出onnxruntime
- name: checkout onnxruntime
uses: actions/checkout@v4
with:
repository: microsoft/onnxruntime
path: onnxruntime-${{ matrix.ver.onnx }}
ref: ${{ matrix.ver.onnx }}
submodules: recursive
# 复制
- name: copy
run: |
cp ${{ env.BUILD_SCRIPT }} onnxruntime-${{ matrix.ver.onnx }}
cp Launch-VsDevShell.ps1 onnxruntime-${{ matrix.ver.onnx }}
- name: build
shell: powershell
run: |
cd onnxruntime-${{ matrix.ver.onnx }}
if ("${{ matrix.arch }}" -eq "x64" )
{
& '.\Launch-VsDevShell.ps1' -VsInstallationPath '${{ matrix.list.vs_path }}' -SkipAutomaticLocation -HostArch amd64 -Arch amd64
}
else
{
& '.\Launch-VsDevShell.ps1' -VsInstallationPath '${{ matrix.list.vs_path }}' -SkipAutomaticLocation -HostArch amd64 -Arch ${{ matrix.arch }}
}
.\${{ env.BUILD_SCRIPT }} -VsArch ${{ matrix.arch }} -VsVer ${{ matrix.list.vs_ver }} -VsCRT ${{ matrix.crt }}
# install文件夹改名,并使用7z压缩
- name: 7zip pack shared libs
run: |
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-${{ matrix.arch }}-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/Release/install ${{ env.SHARED_PKG_NAME }}
7z a ${{ env.SHARED_PKG_NAME }}.7z ${{ env.SHARED_PKG_NAME }}
rm ${{ env.SHARED_PKG_NAME }} -r -fo
- name: 7zip pack static libs
run: |
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-${{ matrix.arch }}-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/Release/install-static ${{ env.STATIC_PKG_NAME }}
7z a ${{ env.STATIC_PKG_NAME }}.7z ${{ env.STATIC_PKG_NAME }}
rm ${{ env.STATIC_PKG_NAME }} -r -fo
- name: build x64 java
shell: powershell
if: ${{ (matrix.arch == 'x64') }}
run: |
cd onnxruntime-${{ matrix.ver.onnx }}
& '.\Launch-VsDevShell.ps1' -VsInstallationPath '${{ matrix.list.vs_path }}' -SkipAutomaticLocation -HostArch amd64 -Arch amd64
.\${{ env.BUILD_SCRIPT }} -VsArch x64 -VsVer ${{ matrix.list.vs_ver }} -VsCRT ${{ matrix.crt }} -BuildJava
- name: 7zip pack java libs
if: ${{ (matrix.arch == 'x64') }}
run: |
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-x64-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/Release/java/build/libs ${{ env.JAVA_PKG_NAME }}
7z a ${{ env.JAVA_PKG_NAME }}.7z ${{ env.JAVA_PKG_NAME }}
# 上传artifact
- name: upload shared lib
uses: actions/upload-artifact@v4
with:
name: ${{ env.SHARED_PKG_NAME }}
path: ${{ env.SHARED_PKG_NAME }}.7z
- name: upload static lib
uses: actions/upload-artifact@v4
with:
name: ${{ env.STATIC_PKG_NAME }}
path: ${{ env.STATIC_PKG_NAME }}.7z
- name: upload java lib
if: ${{ (matrix.arch == 'x64') }}
uses: actions/upload-artifact@v4
with:
name: ${{ env.JAVA_PKG_NAME }}
path: ${{ env.JAVA_PKG_NAME }}.7z
release:
needs: [ windows ]
runs-on: ubuntu-latest
steps:
# 检出代码
- uses: actions/checkout@v4
# 获取所有的git log和tag
# - name: Unshallow
# run: git fetch --prune --unshallow
# 获取git log 从 previousTag 到 lastTag
# - name: Get git log
# id: git-log
# run: |
# previousTag=$(git describe --abbrev=0 --tags `git rev-list --tags --skip=1 --max-count=1`)
# lastTag=$(git describe --abbrev=0 --tags)
# echo "previousTag:$previousTag ~ lastTag:$lastTag"
# log=$(git log $previousTag..$lastTag --pretty=format:'- %cd %an: %s\n' --date=format:'%Y-%m-%d %H:%M:%S')
# echo "$log"
# echo "log_state="$log"" >> $GITHUB_ENV
# 创建Changelog文件 triggered by git tag push
# - name: Generate Changelog
# if: startsWith(github.ref, 'refs/tags/')
# run: |
# echo -e '${{ env.log_state }}' > release.md
# 下载artifact
- name: download
uses: actions/download-artifact@v4
with:
path: artifacts
# 查看artifact
- name: list artifact
run: |
tree artifacts
# 创建release 上传release
# https://github.com/marketplace/actions/create-release
- name: upload-windows
uses: ncipollo/release-action@v1
with:
prerelease: false
bodyFile: release.md
artifacts: artifacts/*/*.7z
allowUpdates: true
artifactContentType: application/x-7z-compressed
token: ${{ secrets.GITHUB_TOKEN }}