Skip to content

macos

macos #79

Workflow file for this run

name: macos
on:
workflow_dispatch:
jobs:
macos:
strategy:
fail-fast: false
matrix:
ver:
- { onnx: v1.18.0, python: 3.8.10, jdk: 11, gradle: 8.6 }
list:
- { os_ver: 12, java: 8 }
- { os_ver: 13, java: 8 }
- { os_ver: 14, java: 11 }
arch:
[
x86_64,
arm64,
arm64e,
]
runs-on: macos-${{ matrix.list.os_ver }}
env:
BUILD_SCRIPT: build-onnxruntime-mac.sh
SHARED_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-macos-${{ matrix.list.os_ver }}-${{ matrix.arch }}-shared
STATIC_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-macos-${{ matrix.list.os_ver }}-${{ matrix.arch }}-static
JAVA_PKG_NAME: onnxruntime-${{ matrix.ver.onnx }}-macos-${{ matrix.list.os_ver }}-${{ matrix.arch }}-java
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 build script
run: |
cp ${{ env.BUILD_SCRIPT }} onnxruntime-${{ matrix.ver.onnx }}
# 编译
- name: build lib
run: |
cd onnxruntime-${{ matrix.ver.onnx }}
chmod a+x ${{ env.BUILD_SCRIPT }}
./${{ env.BUILD_SCRIPT }} -n ${{ matrix.arch }}
# install文件夹改名macos,并使用7z压缩
- name: 7z shared lib
run: |
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Darwin-${{ matrix.arch }}/Release/install ${{ env.SHARED_PKG_NAME }}
7z a ${{ env.SHARED_PKG_NAME }}.7z ${{ env.SHARED_PKG_NAME }}
rm -r -f ${{ env.SHARED_PKG_NAME }}
- name: 7z static lib
run: |
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Darwin-${{ matrix.arch }}/Release/install-static ${{ env.STATIC_PKG_NAME }}
7z a ${{ env.STATIC_PKG_NAME }}.7z ${{ env.STATIC_PKG_NAME }}
rm -r -f ${{ env.STATIC_PKG_NAME }}
- name: build java
run: |
cd onnxruntime-${{ matrix.ver.onnx }}
chmod a+x ${{ env.BUILD_SCRIPT }}
./${{ env.BUILD_SCRIPT }} -n ${{ matrix.arch }} -j
- name: 7z java lib
run: |
if [ -d "onnxruntime-${{ matrix.ver.onnx }}/build-Darwin-${{ matrix.arch }}/Release/java/build/libs" ]; then
cp -r onnxruntime-${{ matrix.ver.onnx }}/build-Darwin-${{ matrix.arch }}/Release/java/build/libs ${{ env.JAVA_PKG_NAME }}
7z a ${{ env.JAVA_PKG_NAME }}.7z ${{ env.JAVA_PKG_NAME }}
rm -r -f ${{ env.JAVA_PKG_NAME }}
fi
# 上传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: Check file existence
# id: check_java_7z
# uses: andstor/file-existence-action@v3
# with:
# files: "${{ env.JAVA_PKG_NAME }}.7z"
# - name: upload java lib
# if: steps.check_java_7z.outputs.files_exists == 'true'
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.JAVA_PKG_NAME }}
# path: ${{ env.JAVA_PKG_NAME }}.7z
# 获取所有的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
# 创建release 上传release
# https://github.com/marketplace/actions/create-release
- name: Create release and upload-archive
uses: ncipollo/release-action@v1
with:
prerelease: false
bodyFile: release.md
artifacts: 'onnxruntime-*.7z'
allowUpdates: true
artifactContentType: application/x-7z-compressed
token: ${{ secrets.GITHUB_TOKEN }}