Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .github/workflows/build-csharp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: Build CSharp

on:
workflow_call:
inputs:
tag:
required: false
type: string
use_rust_artifacts:
required: false
type: boolean
default: true

jobs:
build-csharp:
name: Build C# (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: linux
os: ubuntu-latest
rid: linux-x64
ext: ""
prefix: linux
rust_artifact: rust-core-linux
- target: windows
os: windows-latest
rid: win-x64
ext: .exe
prefix: win
rust_artifact: rust-core-windows

steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Download Rust artifact (${{ matrix.target }})
if: inputs.use_rust_artifacts
uses: actions/download-artifact@v8
with:
name: ${{ matrix.rust_artifact }}
path: src/Core/target/release

- name: Compute version
id: version
shell: bash
run: |
TAG="${{ inputs.tag || '' }}"
if [ -z "$TAG" ]; then
echo "version=0.0.0" >> $GITHUB_OUTPUT
else
CLEAN="${TAG#v}"
echo "version=$CLEAN" >> $GITHUB_OUTPUT
fi

- name: Build .Net (${{ matrix.target }})
shell: bash
run: |
VERSION="${{ steps.version.outputs.version }}"
dotnet publish \
src/Cli \
-c Release \
-r ${{ matrix.rid }} \
-p:Version=$VERSION \
-o artifacts/${{ matrix.prefix }}

- name: Create setup-linux.zip
if: github.event_name != 'pull_request' && matrix.target == 'linux'
shell: bash
run: |
cd artifacts/${{ matrix.prefix }}
zip -r payload.zip appsettings.json Anonymizer.Core.so libonnxruntime.so libonnxruntime_providers_shared.so

- name: Create setup-win.zip
if: github.event_name != 'pull_request' && matrix.target == 'windows'
shell: pwsh
run: |
Set-Location "artifacts/${{ matrix.prefix }}"
$items = @(
"appsettings.json"
"Anonymizer.Core.dll",
"onnxruntime.dll",
"onnxruntime_providers_shared.dll")
Compress-Archive -Path $items -DestinationPath payload.zip -CompressionLevel Optimal -Force

- name: Create setup (${{ matrix.target }})
if: github.event_name != 'pull_request'
shell: bash
run: |
cd artifacts/${{ matrix.prefix }}
MAGIC="SETUP-PAYLOAD"
PAYLOAD_SIZE=$(stat -c%s payload.zip)
cp anonymizer${{ matrix.ext }} setup${{ matrix.ext }}
cat payload.zip >> setup${{ matrix.ext }}
printf "%s" "$MAGIC" | iconv -f ASCII -t ASCII >> setup${{ matrix.ext }}
python3 - <<EOF
import struct
size = $PAYLOAD_SIZE
with open("setup${{ matrix.ext }}", "ab") as f:
f.write(struct.pack("<Q", size))
EOF
cp setup${{ matrix.ext }} ../

- name: Upload setup (${{ matrix.target }})
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v7
with:
name: setup-${{ matrix.prefix }}
path: artifacts/setup${{ matrix.ext }}
56 changes: 56 additions & 0 deletions .github/workflows/build-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build Rust

on:
workflow_call:

jobs:
build-rust:
name: Build Rust (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: linux
os: ubuntu-latest
artifact_name: rust-core-linux
artifact_path: src/Core/target/release/Anonymizer.Core.so
- target: windows
os: windows-latest
artifact_name: rust-core-windows
artifact_path: src/Core/target/release/Anonymizer.Core.dll

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install Rust
uses: dtolnay/rust-toolchain@4be7066ada62dd38de10e7b70166bc74ed198c30 # stable on 2026-07-03

- name: Build Rust (linux)
if: matrix.target == 'linux'
shell: bash
working-directory: src/Core
run: |
cargo build --release
cd target/release
if [ -f libAnonymizer_Core.so ]; then
mv libAnonymizer_Core.so Anonymizer.Core.so
elif [ -f Anonymizer_Core.so ]; then
mv Anonymizer_Core.so Anonymizer.Core.so
else
echo "Unable to find Rust Linux shared library output"
exit 1
fi

- name: Build Rust (windows)
if: matrix.target == 'windows'
shell: pwsh
working-directory: src/Core
run: |
./build.ps1

- name: Upload Rust artifact
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact_name }}
path: ${{ matrix.artifact_path }}
119 changes: 6 additions & 113 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,119 +3,12 @@ name: Continuous Integration
on:
pull_request:
branches: [main]
workflow_call:
inputs:
tag:
required: false
type: string
workflow_dispatch:

jobs:
download-uv:
name: Download UV binaries
runs-on: ubuntu-latest
build-rust:
uses: ./.github/workflows/build-rust.yml

outputs:
tools-path: ${{ steps.set-output.outputs.tools-path }}

steps:
- name: Checkout
uses: actions/checkout@v7

- name: Create tools directory
run: mkdir -p src/Cli/tools

- name: Download uv
run: |
chmod +x ./scripts/download_uv.sh
./scripts/download_uv.sh

- name: Upload tools as artifact
uses: actions/upload-artifact@v7
with:
name: uv-tools
path: src/Cli/tools

- id: set-output
run: echo "tools-path=src/Cli/tools" >> $GITHUB_OUTPUT

build:
name: Build
runs-on: ubuntu-latest
needs: [download-uv]

strategy:
matrix:
target: [linux, windows]
include:
- target: linux
rid: linux-x64
ext: "" # no extension
prefix: linux
- target: windows
rid: win-x64
ext: .exe
prefix: win

steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Compute version
id: version
run: |
TAG="${{ inputs.tag }}"
if [ -z "$TAG" ]; then
echo "version=0.0.0" >> $GITHUB_OUTPUT
else
CLEAN="${TAG#v}"
echo "version=$CLEAN" >> $GITHUB_OUTPUT
fi

- name: Download uv tools
uses: actions/download-artifact@v8
with:
name: uv-tools
path: src/Cli/tools

- name: Build (${{ matrix.target }})
run: |
VERSION="${{ steps.version.outputs.version }}"
dotnet publish \
src/Cli \
-c Release \
-r ${{ matrix.rid }} \
-p:Version=$VERSION \
-o artifacts/${{ matrix.prefix }}

- name: Create setup.zip (${{ matrix.target }})
if: github.event_name != 'pull_request'
run: |
cd artifacts/${{ matrix.prefix }}
zip -r payload.zip scripts tools appsettings.json

- name: Create setup (${{ matrix.target }})
if: github.event_name != 'pull_request'
run: |
cd artifacts/${{ matrix.prefix }}
MAGIC="SETUP-PAYLOAD"
PAYLOAD_SIZE=$(stat -c%s payload.zip)
cp anonymizer${{ matrix.ext }} setup${{ matrix.ext }}
cat payload.zip >> setup${{ matrix.ext }}
printf "%s" "$MAGIC" | iconv -f ASCII -t ASCII >> setup${{ matrix.ext }}
python3 - <<EOF
import struct
size = $PAYLOAD_SIZE
with open("setup${{ matrix.ext }}", "ab") as f:
f.write(struct.pack("<Q", size))
EOF
cp setup${{ matrix.ext }} ../


- name: Upload setup (${{ matrix.target }})
if: github.event_name != 'pull_request'
uses: actions/upload-artifact@v7
with:
name: setup-${{ matrix.prefix }}
path: artifacts/setup${{ matrix.ext }}
build-csharp:
needs: [build-rust]
uses: ./.github/workflows/build-csharp.yml
44 changes: 44 additions & 0 deletions .github/workflows/download-models.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Download Models

on:
pull_request:
paths:
- .github/workflows/download-models.yml
workflow_call:
workflow_dispatch:

jobs:
download-models:
name: Download ONNX Models
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Install UV
uses: astral-sh/setup-uv@v8.2.0

- name: Download and build PII model
run: |
mkdir -p artifacts/models/pii
uv run ./scripts/download-model.py --model onnx-community/pii-ner-nemotron-ONNX --out artifacts/models/pii

- name: Download Face model
run: |
mkdir -p artifacts/models/face
curl -L -o artifacts/models/face/model.onnx \
https://github.com/Linzaer/Ultra-Light-Fast-Generic-Face-Detector-1MB/raw/master/models/onnx/version-RFB-320.onnx

- name: Create model archives
run: |
zip -j -r artifacts/face_model.zip artifacts/models/face/*
zip -j -r artifacts/pii_model.zip artifacts/models/pii/*

- name: Upload models artifact
uses: actions/upload-artifact@v7
with:
name: onnx-models
path: |
artifacts/face_model.zip
artifacts/pii_model.zip
Loading
Loading