Skip to content

windows

windows #34

Workflow file for this run

name: windows
on:
workflow_dispatch:
jobs:
windows:
strategy:
fail-fast: false
matrix:
ver:
- { cv: 3.4.18, jdk: 8, 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,
]
exclude:
- list: { win_ver: 2022, vs_name: vs2022, vs_ver: v143 }
runs-on: windows-${{ matrix.list.win_ver }}
name: windows-${{ matrix.list.vs_name }}-${{ matrix.crt }}
env:
BUILD_SCRIPT: build-opencv3-win.ps1
BUILD_OPTIONS: opencv3_cmake_options.txt
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
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '${{ matrix.ver.jdk }}'
distribution: 'adopt'
- uses: cedx/setup-ant@v2
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
# 复制
- name: copy
run: |
cp ${{ env.BUILD_SCRIPT }} opencv-${{ matrix.ver.cv }}
cp ${{ env.BUILD_OPTIONS }} opencv-${{ matrix.ver.cv }}
# 编译
# https://github.com/ilammy/msvc-dev-cmd
#- uses: ilammy/msvc-dev-cmd@v1
- name: build x64
shell: powershell
run: |
cd opencv-${{ matrix.ver.cv }}
.\${{ env.BUILD_SCRIPT }} -VsArch x64 -VsVer ${{ matrix.list.vs_ver }} -VsCRT ${{ matrix.crt }}
- name: build x86
shell: powershell
run: |
cd opencv-${{ matrix.ver.cv }}
.\${{ env.BUILD_SCRIPT }} -VsArch x86 -VsVer ${{ matrix.list.vs_ver }} -VsCRT ${{ matrix.crt }}
- name: build arm64
if: ${{ (matrix.list.vs_name == 'vs2019') || (matrix.list.vs_name == 'vs2022') }}
shell: powershell
run: |
cd opencv-${{ matrix.ver.cv }}
.\${{ env.BUILD_SCRIPT }} -VsArch arm64 -VsVer ${{ matrix.list.vs_ver }} -VsCRT ${{ matrix.crt }}
- name: 7zip libs
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-x86-${{ 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
shell: powershell
run: |
cd opencv-${{ matrix.ver.cv }}
.\${{ env.BUILD_SCRIPT }} -VsArch x64 -VsVer ${{ matrix.list.vs_ver }} -VsCRT ${{ matrix.crt }} -BuildJava
- name: build java x86
shell: powershell
run: |
cd opencv-${{ matrix.ver.cv }}
.\${{ env.BUILD_SCRIPT }} -VsArch x86 -VsVer ${{ matrix.list.vs_ver }} -VsCRT ${{ matrix.crt }} -BuildJava
- name: build java arm64
if: ${{ (matrix.list.vs_name == 'vs2019') || (matrix.list.vs_name == 'vs2022') }}
shell: powershell
run: |
cd opencv-${{ matrix.ver.cv }}
.\${{ env.BUILD_SCRIPT }} -VsArch arm64 -VsVer ${{ matrix.list.vs_ver }} -VsCRT ${{ matrix.crt }} -BuildJava
- 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-x86-${{ 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 lib
uses: actions/upload-artifact@v4
with:
name: ${{ env.PKG_NAME }}
path: ${{ env.PKG_NAME }}.7z
- name: upload java lib
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 }}