Merge pull request #1719 from shimat/change_linux_nuget_name #47
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Ubuntu 22.04 | |
on: | |
pull_request: | |
types: [synchronize, opened] | |
push: | |
branches: | |
- main | |
env: | |
DEBIAN_FRONTEND: noninteractive | |
OPENCV_VERSION: 4.10.0 | |
OPENCV_CACHE_VERSION: 1 | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
path: opencvsharp | |
- name: Install dependencies | |
run: | | |
sudo apt-get update -y | |
sudo apt-get install -y --no-install-recommends \ | |
apt-transport-https \ | |
software-properties-common \ | |
ca-certificates \ | |
g++ \ | |
make \ | |
cmake \ | |
libtbb-dev \ | |
libatlas-base-dev \ | |
libgtk2.0-dev \ | |
libavcodec-dev \ | |
libavformat-dev \ | |
libswscale-dev \ | |
libdc1394-dev \ | |
libxine2-dev \ | |
libv4l-dev \ | |
libtheora-dev \ | |
libvorbis-dev \ | |
libxvidcore-dev \ | |
libopencore-amrnb-dev \ | |
libopencore-amrwb-dev \ | |
x264 \ | |
libtesseract-dev | |
- name: Cache OpenCV | |
id: opencv-cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/opencv_artifacts/ | |
key: opencv-${{ env.OPENCV_VERSION }}-rev${{ env.OPENCV_CACHE_VERSION }} | |
- name: Checkout OpenCV | |
if: steps.opencv-cache.outputs.cache-hit != 'true' | |
uses: actions/checkout@v4 | |
with: | |
repository: opencv/opencv | |
path: opencv | |
ref: ${{ env.OPENCV_VERSION }} | |
- name: Checkout OpenCV Contrib | |
if: steps.opencv-cache.outputs.cache-hit != 'true' | |
uses: actions/checkout@v4 | |
with: | |
repository: opencv/opencv_contrib | |
path: opencv_contrib | |
ref: ${{ env.OPENCV_VERSION }} | |
- name: Build OpenCV | |
if: steps.opencv-cache.outputs.cache-hit != 'true' | |
run: | | |
mkdir opencv/build && cd opencv/build | |
cmake \ | |
-D CMAKE_BUILD_TYPE=Release \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \ | |
-D BUILD_SHARED_LIBS=OFF \ | |
-D ENABLE_CXX11=ON \ | |
-D BUILD_EXAMPLES=OFF \ | |
-D BUILD_DOCS=OFF \ | |
-D BUILD_PERF_TESTS=OFF \ | |
-D BUILD_TESTS=OFF \ | |
-D BUILD_JAVA=OFF \ | |
-D BUILD_opencv_apps=OFF \ | |
-D BUILD_opencv_barcode=OFF \ | |
-D BUILD_opencv_java_bindings_generator=OFF \ | |
-D BUILD_opencv_python_bindings_generator=OFF \ | |
-D BUILD_opencv_python_tests=OFF \ | |
-D BUILD_opencv_ts=OFF \ | |
-D BUILD_opencv_js=OFF \ | |
-D BUILD_opencv_js_bindings_generator=OFF \ | |
-D BUILD_opencv_bioinspired=OFF \ | |
-D BUILD_opencv_ccalib=OFF \ | |
-D BUILD_opencv_datasets=OFF \ | |
-D BUILD_opencv_dnn_objdetect=OFF \ | |
-D BUILD_opencv_dpm=OFF \ | |
-D BUILD_opencv_fuzzy=OFF \ | |
-D BUILD_opencv_gapi=ON \ | |
-D BUILD_opencv_intensity_transform=OFF \ | |
-D BUILD_opencv_mcc=OFF \ | |
-D BUILD_opencv_objc_bindings_generator=OFF \ | |
-D BUILD_opencv_rapid=OFF \ | |
-D BUILD_opencv_reg=OFF \ | |
-D BUILD_opencv_stereo=OFF \ | |
-D BUILD_opencv_structured_light=OFF \ | |
-D BUILD_opencv_surface_matching=OFF \ | |
-D BUILD_opencv_wechat_qrcode=ON \ | |
-D BUILD_opencv_videostab=OFF \ | |
-D WITH_GSTREAMER=OFF \ | |
-D WITH_ADE=OFF \ | |
-D OPENCV_ENABLE_NONFREE=ON \ | |
-D CMAKE_INSTALL_PREFIX=${GITHUB_WORKSPACE}/opencv_artifacts .. | |
make -j2 | |
make install | |
sudo ldconfig | |
cd ${GITHUB_WORKSPACE} | |
ls | |
- name: Build OpenCvSharpExtern | |
run: | | |
mkdir opencvsharp/src/build && cd $_ | |
cmake -D CMAKE_PREFIX_PATH=${GITHUB_WORKSPACE}/opencv_artifacts .. | |
make -j2 | |
ls OpenCvSharpExtern | |
cp OpenCvSharpExtern/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/opencvsharp/nuget/ | |
- name: Check OpenCvSharpExtern | |
run: | | |
cd ${GITHUB_WORKSPACE}/opencvsharp/nuget/ | |
ldd libOpenCvSharpExtern.so | |
nm libOpenCvSharpExtern.so | |
echo -ne "#include <stdio.h> \n int core_Mat_sizeof(); int main(){ int i = core_Mat_sizeof(); printf(\"sizeof(Mat) = %d\", i); return 0; }" > test.c | |
gcc -I./ -L./ test.c -o test -lOpenCvSharpExtern | |
LD_LIBRARY_PATH=. ./test | |
- name: Install .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.0.x' | |
- name: Create NuGet package | |
env: | |
BETA: "" | |
run: | | |
yyyymmdd=`date '+%Y%m%d'` | |
echo $yyyymmdd | |
cd ${GITHUB_WORKSPACE}/opencvsharp | |
sed -E --in-place=.bak \ | |
"s/<version>[0-9]\.[0-9]{1,2}\.[0-9]{1,2}.[0-9]{8}(-beta[0-9]*)?<\/version>/<version>${OPENCV_VERSION}.${yyyymmdd}${BETA}<\/version>/" \ | |
nuget/OpenCvSharp4_.runtime.linux-x64.nuspec | |
cat nuget/OpenCvSharp4_.runtime.linux-x64.nuspec | |
dotnet pack nuget/OpenCvSharp4_.runtime.linux-x64.csproj -o ${GITHUB_WORKSPACE}/artifacts_ubuntu | |
ls ${GITHUB_WORKSPACE}/artifacts_ubuntu | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: artifacts_ubuntu_22 | |
path: artifacts_ubuntu | |
- name: Test | |
run: | | |
cd ${GITHUB_WORKSPACE}/opencvsharp/test/OpenCvSharp.Tests | |
dotnet build -c Release -f net8.0 | |
cp ${GITHUB_WORKSPACE}/opencvsharp/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/opencvsharp/test/OpenCvSharp.Tests/bin/Release/net8.0/ | |
cp ${GITHUB_WORKSPACE}/opencvsharp/nuget/libOpenCvSharpExtern.so ${GITHUB_WORKSPACE}/opencvsharp/test/OpenCvSharp.Tests/ | |
sudo cp ${GITHUB_WORKSPACE}/opencvsharp/nuget/libOpenCvSharpExtern.so /usr/lib/ | |
LD_LIBRARY_PATH=. dotnet test OpenCvSharp.Tests.csproj -c Release -f net8.0 --runtime linux-x64 --logger "trx;LogFileName=test-results.trx" < /dev/null |