Skip to content

v1.0.0

v1.0.0 #6

Workflow file for this run

name: Build binaries
on:
workflow_dispatch:
inputs:
privacy_filter_ref:
description: Upstream localai-org/privacy-filter.cpp ref
required: true
default: master
release:
types:
- created
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name != 'release' }}
jobs:
build:
name: ${{ matrix.artifact }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact: privacy-filter-linux-x64
cmake_generator: Unix Makefiles
cmake_architecture: ''
cmake_platform: ''
os_name: linux
arch_name: x64
- os: macos-15-intel
artifact: privacy-filter-darwin-x64
cmake_generator: Unix Makefiles
cmake_architecture: x86_64
cmake_platform: ''
os_name: darwin
arch_name: x64
- os: macos-15
artifact: privacy-filter-darwin-arm64
cmake_generator: Unix Makefiles
cmake_architecture: arm64
cmake_platform: ''
os_name: darwin
arch_name: arm64
- os: windows-2022
artifact: privacy-filter-windows-x64
cmake_generator: Visual Studio 17 2022
cmake_architecture: ''
cmake_platform: x64
os_name: windows
arch_name: x64
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.3
- name: Install Linux packaging tools
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y patchelf
- name: Resolve upstream ref
id: upstream
shell: bash
run: |
ref="${{ github.event.inputs.privacy_filter_ref }}"
if [ -z "$ref" ]; then
ref="master"
fi
echo "ref=$ref" >> "$GITHUB_OUTPUT"
- name: Checkout privacy-filter.cpp
shell: bash
run: |
git clone --recursive https://github.com/localai-org/privacy-filter.cpp .build/privacy-filter.cpp
git -C .build/privacy-filter.cpp checkout "${{ steps.upstream.outputs.ref }}"
git -C .build/privacy-filter.cpp submodule update --init --recursive
- name: Patch Windows MSVC flags
if: runner.os == 'Windows'
shell: bash
run: |
python - <<'PY'
from pathlib import Path
path = Path(".build/privacy-filter.cpp/CMakeLists.txt")
text = path.read_text()
text = text.replace(
"target_compile_options(pf PRIVATE -Wall -Wextra)",
"if (NOT MSVC)\n target_compile_options(pf PRIVATE -Wall -Wextra)\nendif()",
)
text = text.replace(
" target_compile_options(pf-cli PRIVATE -Wall -Wextra)",
" if (NOT MSVC)\n target_compile_options(pf-cli PRIVATE -Wall -Wextra)\n endif()",
)
path.write_text(text)
path = Path(".build/privacy-filter.cpp/src/model.cpp")
text = path.read_text()
text = text.replace("#include <cmath>\n", "#include <algorithm>\n#include <cmath>\n")
text = text.replace("M_PI", "3.14159265358979323846264338327950288")
path.write_text(text)
PY
- name: Configure
shell: bash
run: |
cmake_args=(
-S .build/privacy-filter.cpp
-B .build/privacy-filter.cpp/build
-G "${{ matrix.cmake_generator }}"
-DCMAKE_BUILD_TYPE=Release
-DPF_BUILD_TESTS=OFF
-DPF_BUILD_TOOLS=ON
-DGGML_NATIVE=OFF
)
if [ -n "${{ matrix.cmake_architecture }}" ]; then
cmake_args+=("-DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_architecture }}")
fi
if [ -n "${{ matrix.cmake_platform }}" ]; then
cmake_args+=("-A" "${{ matrix.cmake_platform }}")
fi
cmake "${cmake_args[@]}"
- name: Build
shell: bash
run: cmake --build .build/privacy-filter.cpp/build --config Release --target pf-cli -j
- name: Package
shell: bash
run: |
package="${{ matrix.artifact }}"
mkdir -p "dist/$package/bin" "dist/$package/lib"
if [ "${{ runner.os }}" = "Windows" ]; then
cp .build/privacy-filter.cpp/build/Release/pf-cli.exe "dist/$package/bin/privacy-filter.exe"
cp .build/privacy-filter.cpp/build/bin/Release/*.dll "dist/$package/bin/"
else
cp .build/privacy-filter.cpp/build/pf-cli "dist/$package/bin/privacy-filter"
chmod +x "dist/$package/bin/privacy-filter"
fi
if [ "${{ runner.os }}" = "macOS" ]; then
find .build/privacy-filter.cpp/build/ggml/src -name 'libggml*.dylib' -maxdepth 3 -exec cp -P {} "dist/$package/lib" \;
for rpath in \
"$PWD/.build/privacy-filter.cpp/build/ggml/src" \
"$PWD/.build/privacy-filter.cpp/build/ggml/src/ggml-blas" \
"$PWD/.build/privacy-filter.cpp/build/ggml/src/ggml-metal"; do
install_name_tool -delete_rpath "$rpath" "dist/$package/bin/privacy-filter" 2>/dev/null || true
done
install_name_tool -add_rpath "@loader_path/../lib" "dist/$package/bin/privacy-filter"
fi
if [ "${{ runner.os }}" = "Linux" ]; then
find .build/privacy-filter.cpp/build/ggml/src -maxdepth 3 -name 'libggml*.so*' -exec cp -P {} "dist/$package/lib" \;
patchelf --set-rpath '$ORIGIN/../lib' "dist/$package/bin/privacy-filter"
fi
cp .build/privacy-filter.cpp/LICENSE "dist/$package/LICENSE"
cp .build/privacy-filter.cpp/README.md "dist/$package/README.md"
upstream_sha="$(git -C .build/privacy-filter.cpp rev-parse HEAD)"
cat > "dist/$package/build-info.json" <<JSON
{
"name": "$package",
"upstreamRepository": "https://github.com/localai-org/privacy-filter.cpp",
"upstreamRef": "${{ steps.upstream.outputs.ref }}",
"upstreamCommit": "$upstream_sha",
"os": "${{ matrix.os_name }}",
"arch": "${{ matrix.arch_name }}",
"cpuOnly": true
}
JSON
cd dist
if [ "${{ runner.os }}" = "Windows" ]; then
7z a "$package.zip" "$package" > /dev/null
else
tar -czf "$package.tar.gz" "$package"
fi
- name: Upload archive
uses: actions/upload-artifact@v7.0.1
with:
name: ${{ matrix.artifact }}
path: |
dist/${{ matrix.artifact }}.tar.gz
dist/${{ matrix.artifact }}.zip
if-no-files-found: ignore
test:
name: Test ${{ matrix.artifact }}
needs: build
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
artifact: privacy-filter-linux-x64
archive: privacy-filter-linux-x64.tar.gz
- os: macos-15-intel
artifact: privacy-filter-darwin-x64
archive: privacy-filter-darwin-x64.tar.gz
- os: macos-15
artifact: privacy-filter-darwin-arm64
archive: privacy-filter-darwin-arm64.tar.gz
- os: windows-2022
artifact: privacy-filter-windows-x64
archive: privacy-filter-windows-x64.zip
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.3
- name: Download archive
uses: actions/download-artifact@v8.0.1
with:
name: ${{ matrix.artifact }}
path: dist
- name: Test archive
shell: bash
run: scripts/test-archive.sh "dist/${{ matrix.archive }}"
manifest:
name: Manifest
needs: test
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v6.0.3
- name: Download archives
uses: actions/download-artifact@v8.0.1
with:
path: dist
merge-multiple: true
- name: Generate manifest and checksums
run: python3 scripts/make-manifest.py dist
- name: Upload manifest artifacts
uses: actions/upload-artifact@v7.0.1
with:
name: manifest
path: |
dist/manifest.json
dist/checksums.txt
- name: Upload release assets
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release upload "${{ github.event.release.tag_name }}" \
dist/privacy-filter-*.tar.gz \
dist/privacy-filter-*.zip \
dist/manifest.json \
dist/checksums.txt \
--clobber