diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 73acada..260d227 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,9 +1,80 @@ name: Continuous Integration -on: [ push, pull_request ] +on: + push: + branches: + - master + tags-ignore: + - '*' + pull_request: + branches: + - '*' + tags-ignore: + - '*' + +env: + PROJECT_NAME: Mediapipe.Net.Runtime + PROTO_NAME: Mediapipe.Net.Framework.Protobuf + PACKAGE_OUTDIR: ${{ github.workspace }}/out jobs: - build: - name: Build + build-protobuf: + name: Build (Protobuf) + runs-on: ubuntu-latest + steps: + - name: Cache Bazel directory + uses: actions/cache@v2 + if: ${{ always() }} + env: + cache-name: bazel-cache + with: + path: ~/.cache/bazel + key: Linux-${{ env.cache-name }}-dev + + - name: Cache build directory + uses: actions/cache@v2 + env: + cache-name: build-cache + with: + path: build + key: Linux-${{ env.cache-name }}-dev + + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "6.0.x" + + - name: Setup Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: "3.10" + architecture: "x64" + + - name: Install Numpy + run: pip install numpy + + - name: Build C# Protobuf sources (Linux) + run: python build.py build --protobuf -vv + + - name: Restore packages + run: dotnet restore ${{ env.PROTO_NAME }} + + - name: Build project + run: dotnet build ${{ env.PROTO_NAME }} --no-restore --configuration Release + + - name: Pack project + run: dotnet pack ${{ env.PROTO_NAME }} --no-restore --no-build --configuration Release --output ${{ env.PACKAGE_OUTDIR }} + + - name: Upload Nuget package artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PROTO_NAME }}-nuget + path: ${{ env.PACKAGE_OUTDIR }}/*.nupkg + + build-runtime: + name: Build (Runtime) runs-on: ${{ matrix.os.runner }} strategy: fail-fast: false @@ -11,12 +82,16 @@ jobs: os: - name: Windows runner: windows-latest + cache-path: C:/_bzl - name: Linux_CPU runner: ubuntu-latest + cache-path: ~/.cache/bazel - name: Linux_GPU runner: ubuntu-latest + cache-path: ~/.cache/bazel - name: MacOS runner: macos-latest + cache-path: ~/_bzl steps: - name: Cache Bazel directory uses: actions/cache@v2 @@ -24,7 +99,7 @@ jobs: env: cache-name: bazel-cache with: - path: ~/.cache/bazel + path: ${{ matrix.os.cache-path }} key: ${{ matrix.os.name }}-${{ env.cache-name }}-dev - name: Cache build directory @@ -38,12 +113,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Setup MinGW (Windows) - if: ${{ matrix.os.name == 'Windows' }} - uses: egor-tensin/setup-mingw@v2 - with: - platform: x64 - - name: Setup EGL (Linux, GPU) if: ${{ matrix.os.name == 'Linux_GPU' }} run: sudo apt install libglfw3-dev libgles2-mesa-dev @@ -62,10 +131,6 @@ jobs: - name: Install Numpy run: pip install numpy - - name: Build C# Protobuf sources (Linux, CPU) - if: ${{ matrix.os.name == 'Linux_CPU' }} - run: python build.py build --no-install --protobuf -vv - - name: Build Native Library (*nix, CPU) if: ${{ matrix.os.name != 'Windows' && matrix.os.name != 'Linux_GPU' }} run: python build.py build --no-install --no-protobuf --desktop cpu --opencv cmake -vv @@ -87,3 +152,74 @@ jobs: with: name: Build.${{ matrix.os.name }} path: build/ + + pack-runtime: + name: Pack (Runtime) + needs: build-runtime + runs-on: ubuntu-latest + strategy: + matrix: + comp: + - CPU + - GPU + steps: + - name: Setup .NET 6 + uses: actions/setup-dotnet@v1 + with: + dotnet-version: "6.0.x" + + - name: Setup Python 3.10 + uses: actions/setup-python@v2 + with: + python-version: "3.10" + architecture: "x64" + + - name: Checkout + uses: actions/checkout@v2 + + - name: Download Windows build artifacts + if: ${{ matrix.comp == 'CPU' }} + uses: actions/download-artifact@v2 + with: + name: Build.Windows + path: build/ + + - name: Download Linux (CPU) build artifacts + if: ${{ matrix.comp == 'CPU' }} + uses: actions/download-artifact@v2 + with: + name: Build.Linux_CPU + path: build/ + + - name: Download Linux (GPU) build artifacts + if: ${{ matrix.comp == 'GPU' }} + uses: actions/download-artifact@v2 + with: + name: Build.Linux_GPU + path: build/ + + - name: Download MacOS build artifacts + if: ${{ matrix.comp == 'CPU' }} + uses: actions/download-artifact@v2 + with: + name: Build.MacOS + path: build/ + + - name: Install artifacts + run: python build.py build --no-protobuf -vv + + - name: Restore packages + run: dotnet restore ${{ env.PROJECT_NAME }}.${{ matrix.comp }} + + - name: Build project + run: dotnet build ${{ env.PROJECT_NAME }}.${{ matrix.comp }} --no-restore --configuration Release + + - name: Pack project + run: dotnet pack ${{ env.PROJECT_NAME }}.${{ matrix.comp }} --no-restore --no-build --configuration Release --output ${{ env.PACKAGE_OUTDIR }} + + - name: Upload Nuget package artifact + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PROJECT_NAME }}-nuget + path: ${{ env.PACKAGE_OUTDIR }}/*.nupkg + diff --git a/.github/workflows/deploy-all.yml b/.github/workflows/deploy-all.yml index 878d847..52402fa 100644 --- a/.github/workflows/deploy-all.yml +++ b/.github/workflows/deploy-all.yml @@ -2,7 +2,7 @@ name: Deploy on: release: - types: [ prereleased ] + types: [ prereleased, released ] env: PROJECT_NAME: Mediapipe.Net.Runtime @@ -219,7 +219,7 @@ jobs: deploy: name: Deploy needs: [ build-protobuf, pack-runtime ] - environment: Pre-release + environment: ${{ github.event.release.prerelease && 'Pre-release' || 'Production' }} runs-on: ubuntu-latest steps: - name: Download Protobuf Nuget package artifact @@ -235,10 +235,7 @@ jobs: path: ${{ github.workspace }} - name: Deploy to NuGet - uses: myci-actions/publish-nuget@5 - with: - filename: ${{ github.workspace }}/*.nupkg - api-key: ${{ secrets.NUGET_TOKEN }} + run: dotnet nuget push ${{ github.workspace }}/*.nupkg --api-key ${{ secrets.NUGET_TOKEN }} --source https://api.nuget.org/v3/index.json - name: Generate Release uses: ncipollo/release-action@v1 @@ -248,5 +245,5 @@ jobs: artifacts: ${{ github.workspace }}/*.nupkg name: ${{ format('Mediapipe.Net.Runtime {0}', github.event.release.tag_name) }} tag: ${{ github.event.release.tag_name }} - body: ${{ format('MediaPipe.NET.Runtime {0} has been released.', github.event.release.tag_name) }} + body: ${{ format('MediaPipe.NET.Runtime {0} has been released! Every package below is currently available on [Nuget](https://www.nuget.org).', github.event.release.tag_name) }} generateReleaseNotes: true diff --git a/Readme.md b/Readme.md index 464a1f6..0b717b1 100644 --- a/Readme.md +++ b/Readme.md @@ -2,6 +2,8 @@ > Native library package for MediaPipe.NET. +![Deploy workflow](https://github.com/vignetteapp/MediaPipe.NET.Runtime/actions/workflows/deploy-all.yml/badge.svg) ![CI workflow](https://github.com/vignetteapp/MediaPipe.NET.Runtime/actions/workflows/ci.yml/badge.svg) + This is the first half of the port of [MediaPipeUnityPlugin](https://github.com/homuler/MediaPipeUnityPlugin/), in order to use MediaPipe on the latest .NET environment. The goal is to separate the actual C# bindings from the native library into 2 different workflows to increase productivity and efficiency. We think it will drastically improve maintainability as we'll be able to take better advantage of CI and other things like GitHub releases. We take homuler's Mediapipe C API and building utilities almost completely as-is, use them to build a native Mediapipe library, and ship all libraries for different OSes into one Nuget native runtime package: `Mediapipe.Net.Runtime`.