Skip to content

macos

macos #42

Workflow file for this run

name: macos
on:
workflow_dispatch:
jobs:
macos:
strategy:
fail-fast: false
matrix:
ver:
- { cv: 4.9.0, ant: 1.10.14 }
list:
- { os_ver: 12, java: 8 }
- { os_ver: 13, java: 8 }
- { os_ver: 14, java: 11 }
arch:
[
x86_64,
arm64,
arm64e,
]
#exclude:
# - list: { os_ver: 12, java: 8 }
runs-on: macos-${{ matrix.list.os_ver }}
env:
BUILD_SCRIPT: build-opencv4-mac.sh
BUILD_OPTIONS: opencv4_cmake_options.txt
PKG_NAME: opencv-${{ matrix.ver.cv }}-macos-${{ matrix.list.os_ver }}-${{ matrix.arch }}
JAVA_PKG_NAME: opencv-${{ matrix.ver.cv }}-macos-${{ matrix.list.os_ver }}-${{ matrix.arch }}-java
steps:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '${{ matrix.list.java }}'
distribution: 'temurin '
- uses: cedx/setup-ant@v2
if: ${{ matrix.list.os_ver != '14' }}
with:
optional-tasks: true
version: ${{ matrix.ver.ant }}
- name: ant version
run: ant -version
# 检出代码
- uses: actions/checkout@v4
# 检出opencv
- name: checkout opencv
uses: actions/checkout@v4
with:
repository: opencv/opencv
path: opencv-${{ matrix.ver.cv }}
ref: ${{ matrix.ver.cv }}
submodules: recursive
# 安装openmp
#- name: install openmp
# run: |
# brew install libomp
# 复制
- name: copy
run: |
cp ${{ env.BUILD_SCRIPT }} opencv-${{ matrix.ver.cv }}
cp ${{ env.BUILD_OPTIONS }} opencv-${{ matrix.ver.cv }}
# 编译
- name: build
run: |
cd opencv-${{ matrix.ver.cv }}
chmod a+x ${{ env.BUILD_SCRIPT }} &&./${{ env.BUILD_SCRIPT }} -n '${{ matrix.arch }}'
# 7z压缩
- name: 7zip
run: |
cp -r opencv-${{ matrix.ver.cv }}/build-Release-${{ matrix.arch }}/install ${{ env.PKG_NAME }}
7z a ${{ env.PKG_NAME }}.7z ${{ env.PKG_NAME }}
rm -r -f ${{ env.PKG_NAME }}
# 编译
- name: build java
run: |
cd opencv-${{ matrix.ver.cv }}
chmod a+x ${{ env.BUILD_SCRIPT }} &&./${{ env.BUILD_SCRIPT }} -n '${{ matrix.arch }}' -j
# 7z压缩
- name: 7zip
run: |
cp -r opencv-${{ matrix.ver.cv }}/build-Release-${{ matrix.arch }}/install/share/java/opencv4 ${{ env.JAVA_PKG_NAME }}
7z a ${{ env.JAVA_PKG_NAME }}.7z ${{ env.JAVA_PKG_NAME }}
rm -r -f ${{ env.JAVA_PKG_NAME }}
# 上传artifact
# - name: upload
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.PKG_NAME }}
# path: ${{ env.PKG_NAME }}.7z
# - name: upload
# 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: 'opencv-*.7z'
allowUpdates: true
artifactContentType: application/x-7z-compressed
token: ${{ secrets.GITHUB_TOKEN }}