Skip to content

0.3.0

0.3.0 #42

Workflow file for this run

name: Build Native Libraries
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
release:
types: [ created ]
permissions:
contents: write
actions: read
jobs:
build-linux:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
include-prerelease: true
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y cmake build-essential libssl-dev
- name: Build liboqs for Linux
run: |
chmod +x build-dotnet-liboqs-linux.sh
./build-dotnet-liboqs-linux.sh Release ./src/native/runtimes/linux-x64/native
- name: Test .NET project with native library
run: |
dotnet restore
dotnet build --no-restore
dotnet test --no-build --verbosity normal
- name: Upload Linux artifacts
uses: actions/upload-artifact@v4
with:
name: liboqs-linux-x64
path: |
src/native/runtimes/linux-x64/native/liboqs.so
retention-days: 7
build-linux-arm64:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up ARM64 cross-compilation with musl
run: |
# Install build tools and the aarch64-linux-gnu cross-compiler
sudo apt update
sudo apt install -y cmake build-essential gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
# Create CMake toolchain file
cat > arm64-toolchain.cmake << 'EOF'
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
EOF
- name: Build liboqs for Linux ARM64
run: |
chmod +x build-dotnet-liboqs-linux.sh
# Modify the build script to use our toolchain file
export CMAKE_TOOLCHAIN_FILE="$(pwd)/arm64-toolchain.cmake"
./build-dotnet-liboqs-linux.sh Release ./src/native/runtimes/linux-arm64/native
# Note: Cannot run tests for ARM64 libraries on x64 runner
- name: Verify ARM64 library was created
run: |
if [ -f "src/native/runtimes/linux-arm64/native/liboqs.so" ]; then
echo "ARM64 library successfully created"
file src/native/runtimes/linux-arm64/native/liboqs.so
else
echo "ERROR: ARM64 library not found"
exit 1
fi
- name: Upload Linux ARM64 artifacts
uses: actions/upload-artifact@v4
with:
name: liboqs-linux-arm64
path: |
src/native/runtimes/linux-arm64/native/liboqs.so
retention-days: 7
build-windows-x64:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
include-prerelease: true
- name: Set up Visual Studio environment
uses: microsoft/setup-msbuild@v2
- name: Build liboqs for Windows x64
run: |
powershell -ExecutionPolicy Bypass -File build-dotnet-liboqs.ps1 -Platform x64 -OutputDir ".\src\native\runtimes\win-x64\native"
- name: Test .NET project with native library
run: |
dotnet restore
dotnet build --no-restore
dotnet test --no-build --verbosity normal
- name: Upload Windows x64 artifacts
uses: actions/upload-artifact@v4
with:
name: liboqs-windows-x64
path: |
src/native/runtimes/win-x64/native/oqs.dll
retention-days: 7
build-windows-arm64:
runs-on: windows-11-arm
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
include-prerelease: true
- name: Set up Visual Studio environment
uses: microsoft/setup-msbuild@v2
- name: Build liboqs for Windows ARM64
run: |
powershell -ExecutionPolicy Bypass -File build-dotnet-liboqs.ps1 -Platform ARM64 -OutputDir ".\src\native\runtimes\win-arm64\native"
- name: Test .NET project with native library
run: |
dotnet restore
dotnet build --no-restore
dotnet test --no-build --verbosity normal
- name: Upload Windows ARM64 artifacts
uses: actions/upload-artifact@v4
with:
name: liboqs-windows-arm64
path: |
src/native/runtimes/win-arm64/native/oqs.dll
retention-days: 7
build-macos:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
include-prerelease: true
- name: Build liboqs for macOS
run: |
chmod +x build-dotnet-liboqs-macos.sh
./build-dotnet-liboqs-macos.sh Release ./src/native/runtimes/osx/native
- name: Test .NET project with native library
run: |
dotnet restore
dotnet build --no-restore
dotnet test --no-build --verbosity normal
- name: Upload macOS artifacts
uses: actions/upload-artifact@v4
with:
name: liboqs-macos
path: |
src/native/runtimes/osx/native/liboqs.dylib
retention-days: 7
create-nuget-packages:
if: github.ref == 'refs/heads/main' && github.event_name != 'release'
needs: [build-linux, build-linux-arm64, build-windows-x64, build-windows-arm64, build-macos]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
include-prerelease: true
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Copy native libraries to correct locations
run: |
# Create the native runtime directories
mkdir -p src/native/runtimes/linux-x64/native
mkdir -p src/native/runtimes/linux-arm64/native
mkdir -p src/native/runtimes/win-x64/native
mkdir -p src/native/runtimes/win-arm64/native
mkdir -p src/native/runtimes/osx/native
# Copy artifacts to the correct locations
if [ -d "artifacts/liboqs-linux-x64" ]; then
cp -r artifacts/liboqs-linux-x64/* src/native/runtimes/linux-x64/native/
fi
if [ -d "artifacts/liboqs-linux-arm64" ]; then
cp -r artifacts/liboqs-linux-arm64/* src/native/runtimes/linux-arm64/native/
fi
if [ -d "artifacts/liboqs-windows-x64" ]; then
cp -r artifacts/liboqs-windows-x64/* src/native/runtimes/win-x64/native/
fi
if [ -d "artifacts/liboqs-windows-arm64" ]; then
cp -r artifacts/liboqs-windows-arm64/* src/native/runtimes/win-arm64/native/
fi
if [ -d "artifacts/liboqs-macos" ]; then
cp -r artifacts/liboqs-macos/* src/native/runtimes/osx/native/
fi
# List what we have for debugging
echo "Native libraries copied:"
find src/native/runtimes -type f -name "liboqs.so" -o -name "oqs.dll" -o -name "liboqs.dylib"
- name: Restore dependencies
run: dotnet restore
- name: Build solution in Release mode
run: dotnet build --configuration Release --no-restore
- name: Pack LibOQS.NET.Native
run: dotnet pack src/LibOQS.NET.Native/LibOQS.NET.Native.csproj --configuration Release --no-build --output ./packages
- name: Pack LibOQS.NET
run: dotnet pack src/LibOQS.NET/LibOQS.NET.csproj --configuration Release --no-build --output ./packages
- name: List created packages
run: |
echo "Created NuGet packages:"
ls -la ./packages/
- name: Upload LibOQS.NET.Native package
uses: actions/upload-artifact@v4
with:
name: LibOQS.NET.Native-package
path: ./packages/LibOQS.NET.Native*.nupkg
retention-days: 30
- name: Upload LibOQS.NET package
uses: actions/upload-artifact@v4
with:
name: LibOQS.NET-package
path: ./packages/LibOQS.NET.0*.nupkg
retention-days: 30
release:
if: github.event_name == 'release'
needs: [build-linux, build-linux-arm64, build-windows-x64, build-windows-arm64, build-macos]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
include-prerelease: true
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Copy native libraries to correct locations
run: |
# Create the native runtime directories
mkdir -p src/native/runtimes/linux-x64/native
mkdir -p src/native/runtimes/linux-arm64/native
mkdir -p src/native/runtimes/win-x64/native
mkdir -p src/native/runtimes/win-arm64/native
mkdir -p src/native/runtimes/osx/native
# Copy artifacts to the correct locations
if [ -d "artifacts/liboqs-linux-x64" ]; then
cp -r artifacts/liboqs-linux-x64/* src/native/runtimes/linux-x64/native/
fi
if [ -d "artifacts/liboqs-linux-arm64" ]; then
cp -r artifacts/liboqs-linux-arm64/* src/native/runtimes/linux-arm64/native/
fi
if [ -d "artifacts/liboqs-windows-x64" ]; then
cp -r artifacts/liboqs-windows-x64/* src/native/runtimes/win-x64/native/
fi
if [ -d "artifacts/liboqs-windows-arm64" ]; then
cp -r artifacts/liboqs-windows-arm64/* src/native/runtimes/win-arm64/native/
fi
if [ -d "artifacts/liboqs-macos" ]; then
cp -r artifacts/liboqs-macos/* src/native/runtimes/osx/native/
fi
# List what we have for debugging
echo "Native libraries copied:"
find src/native/runtimes -type f -name "liboqs.so" -o -name "oqs.dll" -o -name "liboqs.dylib"
- name: Restore dependencies
run: dotnet restore
- name: Build solution in Release mode
run: dotnet build --configuration Release --no-restore
- name: Pack LibOQS.NET.Native
run: dotnet pack src/LibOQS.NET.Native/LibOQS.NET.Native.csproj --configuration Release --no-build --output ./packages
- name: Pack LibOQS.NET
run: dotnet pack src/LibOQS.NET/LibOQS.NET.csproj --configuration Release --no-build --output ./packages
- name: Push to NuGet
run: dotnet nuget push ./packages/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Upload LibOQS.NET.Native package to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./packages/LibOQS.NET.Native.${{ github.event.release.tag_name }}.nupkg
asset_name: LibOQS.NET.Native.${{ github.event.release.tag_name }}.nupkg
asset_content_type: application/zip
- name: Upload LibOQS.NET package to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./packages/LibOQS.NET.${{ github.event.release.tag_name }}.nupkg
asset_name: LibOQS.NET.${{ github.event.release.tag_name }}.nupkg
asset_content_type: application/zip