Skip to content

windows

windows #30

Workflow file for this run

name: windows
on:
workflow_dispatch:
jobs:
windows:
strategy:
fail-fast: false
matrix:
ver:
- { cv: 4.9.0, ant: 1.10.14 }
list:
- { win_ver: 2019, vs_name: vs2015, vs_ver: v140 }
- { win_ver: 2019, vs_name: vs2017, vs_ver: v141 }
- { win_ver: 2019, vs_name: vs2019, vs_ver: v142 }
- { win_ver: 2022, vs_name: vs2022, vs_ver: v143 }
crt:
[
md,
mt,
]
runs-on: windows-${{ matrix.list.win_ver }}
name: windows-${{ matrix.list.vs_name }}-${{ matrix.crt }}
env:
PKG_NAME: opencv-${{ matrix.ver.cv }}-windows-${{ matrix.list.vs_name }}-${{ matrix.crt }}
JAVA_PKG_NAME: opencv-${{ matrix.ver.cv }}-windows-${{ matrix.list.vs_name }}-java-${{ matrix.crt }}
steps:
# Setup JDK 8
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'adopt'
- uses: cedx/setup-ant@v2
with:
optional-tasks: true
version: ${{ matrix.ver.ant }}
- name: ant version
run: ant -version
# 检出代码
- uses: actions/checkout@v3
# 检出opencv
- name: checkout opencv
uses: actions/checkout@v3
with:
repository: opencv/opencv
path: opencv-${{ matrix.ver.cv }}
ref: ${{ matrix.ver.cv }}
submodules: recursive
# 复制
- name: copy
run: |
cp build-opencv4-win.bat opencv-${{ matrix.ver.cv }}
cp build-opencv4-win-java.bat opencv-${{ matrix.ver.cv }}
cp opencv4_cmake_options.txt opencv-${{ matrix.ver.cv }}
# 编译
# https://github.com/ilammy/msvc-dev-cmd
#- uses: ilammy/msvc-dev-cmd@v1
- name: build x64
run: |
cd opencv-${{ matrix.ver.cv }}
./build-opencv4-win.bat x64 ${{ matrix.list.vs_ver }} ${{ matrix.crt }}
- name: build Win32
run: |
cd opencv-${{ matrix.ver.cv }}
./build-opencv4-win.bat Win32 ${{ matrix.list.vs_ver }} ${{ matrix.crt }}
- name: build ARM64
if: ${{ (matrix.list.vs_name == 'vs2019') || (matrix.list.vs_name == 'vs2022') }}
run: |
cd opencv-${{ matrix.ver.cv }}
./build-opencv4-win.bat ARM64 ${{ matrix.list.vs_ver }} ${{ matrix.crt }}
# 7z压缩
- name: 7zip lib
run: |
cp -r opencv-${{ matrix.ver.cv }}/build-x64-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/install windows-x64
cp -r opencv-${{ matrix.ver.cv }}/build-Win32-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/install windows-x86
if ( ("${{ matrix.list.vs_name }}" -eq "VS2019") -or ("${{ matrix.list.vs_name }}" -eq "VS2022") )
{
echo "vs2019 or vs2022 7z x64 x86 arm64"
cp -r opencv-${{ matrix.ver.cv }}/build-ARM64-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/install windows-arm64
7z a ${{ env.PKG_NAME }}.7z windows-x64 windows-x86 windows-arm64
rm windows-arm64 -r -fo
}
else
{
echo "vs2015 or vs2017 7z x64 x86"
7z a ${{ env.PKG_NAME }}.7z windows-x64 windows-x86
}
rm windows-x64 -r -fo
rm windows-x86 -r -fo
- name: build java x64
run: |
cd opencv-${{ matrix.ver.cv }}
./build-opencv4-win-java.bat x64 ${{ matrix.list.vs_ver }} ${{ matrix.crt }}
- name: build java Win32
run: |
cd opencv-${{ matrix.ver.cv }}
./build-opencv4-win-java.bat Win32 ${{ matrix.list.vs_ver }} ${{ matrix.crt }}
- name: build java ARM64
if: ${{ (matrix.list.vs_name == 'vs2019') || (matrix.list.vs_name == 'vs2022') }}
run: |
cd opencv-${{ matrix.ver.cv }}
./build-opencv4-win-java.bat ARM64 ${{ matrix.list.vs_ver }} ${{ matrix.crt }}
# 7z压缩
- name: 7zip java
run: |
cp -r opencv-${{ matrix.ver.cv }}/build-x64-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/install/java windows-x64
cp -r opencv-${{ matrix.ver.cv }}/build-Win32-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/install/java windows-x86
if ( ("${{ matrix.list.vs_name }}" -eq "VS2019") -or ("${{ matrix.list.vs_name }}" -eq "VS2022") )
{
echo "vs2019 or vs2022 7z x64 x86 arm64"
cp -r opencv-${{ matrix.ver.cv }}/build-ARM64-${{ matrix.list.vs_ver }}-${{ matrix.crt }}/install/java windows-arm64
7z a ${{ env.JAVA_PKG_NAME }}.7z windows-x64 windows-x86 windows-arm64
rm windows-arm64 -r -fo
}
else
{
echo "vs2015 or vs2017 7z x64 x86"
7z a ${{ env.JAVA_PKG_NAME }}.7z windows-x64 windows-x86
}
rm windows-x64 -r -fo
rm windows-x86 -r -fo
# 上传artifact
- name: upload
uses: actions/upload-artifact@v3
with:
name: ${{ env.PKG_NAME }}
path: ${{ env.PKG_NAME }}.7z
- name: upload
uses: actions/upload-artifact@v3
with:
name: ${{ env.JAVA_PKG_NAME }}
path: ${{ env.JAVA_PKG_NAME }}.7z
release:
needs: [ windows ]
runs-on: ubuntu-latest
steps:
# 检出代码
- uses: actions/checkout@v3
# 获取所有的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@v3
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 }}