Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
b22efbf
Merge branch 'develop'
Cryptoc1 Apr 5, 2026
6ee04f7
Merge branch 'main' into develop
Cryptoc1 Apr 6, 2026
0bb1ff3
[NEW] updateing workflow to build libdave from source
Cryptoc1 Apr 6, 2026
f318802
General Updates:
Cryptoc1 Apr 6, 2026
a3f5eab
[FIX] incorrect paths in windows `prepare-artifacts` build step
Cryptoc1 Apr 6, 2026
4db4b51
- [FIX] do not use `tree` when preparing artifact
Cryptoc1 Apr 6, 2026
225547d
- [FIX] build stage definition;
Cryptoc1 Apr 6, 2026
a63251a
[FIX] don't unlink openssl@1 during mac builds
Cryptoc1 Apr 6, 2026
fdcee9d
[FIX] incorrect artifact path
Cryptoc1 Apr 6, 2026
2c25c56
- [NEW] adjust env scoping
Cryptoc1 Apr 6, 2026
2b0d944
[FIX] artifact preparation/packaging
Cryptoc1 Apr 6, 2026
41468b6
[FIX] static linking
Cryptoc1 Apr 6, 2026
f3769d3
[NEW] static linking improvements
Cryptoc1 Apr 6, 2026
e536ce0
- [NEW] package `libcrypto`+`libsll`
Cryptoc1 Apr 6, 2026
b368d46
[FIX] windows build
Cryptoc1 Apr 6, 2026
99b1f1f
[TEMP] windows packaging fixes
Cryptoc1 Apr 6, 2026
2a10392
[TEMP] windows packaging fixes
Cryptoc1 Apr 6, 2026
cfd4cad
[TEMP] windows packaging fixes
Cryptoc1 Apr 6, 2026
2a66797
[FIX] windows packaging fixes
Cryptoc1 Apr 6, 2026
ec6f754
[FIX] package `libmlspp`
Cryptoc1 Apr 6, 2026
55ff3a5
[NEW] package all libs for nativeaot/static linking
Cryptoc1 Apr 6, 2026
197b9da
[FIX] adjust aot build items
Cryptoc1 Apr 6, 2026
d5968e5
[NEW] build against openssl
Cryptoc1 Apr 7, 2026
96a25f2
[FIX] do not explicitly specify ssl version (use openssl@3 by default)
Cryptoc1 Apr 7, 2026
75e8bd2
[NEW] package all static libs
Cryptoc1 Apr 7, 2026
fefb078
[TEMP] adjust listing command in artifact preparation
Cryptoc1 Apr 7, 2026
77e1077
[FIX] manually enumerate files to copy
Cryptoc1 Apr 7, 2026
06a5c08
[FIX] copy `.lib` files on windows
Cryptoc1 Apr 7, 2026
697fc88
[FIX] don't use double quotes (ensure wildcard is expanded by the shell)
Cryptoc1 Apr 7, 2026
40d0ab0
[FIX] use pwsh for preparing artifact
Cryptoc1 Apr 7, 2026
27cfab9
- [NEW] optmize packaging
Cryptoc1 Apr 7, 2026
f88560c
[FIX] ensure `PrepareForPublish` is targeted
Cryptoc1 Apr 7, 2026
5e2ddb9
[FIX] don't use `pwsh` for preparing windows artifact
Cryptoc1 Apr 7, 2026
a58f4c6
[FIX] restore of sample project (missing rids)
Cryptoc1 Apr 7, 2026
88c3c50
[FIX] adjust target before/after
Cryptoc1 Apr 7, 2026
ded9356
[FIX] target conditions
Cryptoc1 Apr 7, 2026
e316e70
[FIX] property defaults
Cryptoc1 Apr 7, 2026
680c5e4
[NEW] `LibDaveEnableStaticLinking` default value
Cryptoc1 Apr 7, 2026
03e8dab
[NEW] default property values
Cryptoc1 Apr 7, 2026
b33d9b2
[NEW] use `DependsOn` instead of `After`
Cryptoc1 Apr 7, 2026
a897454
[FIX] property defaults+target deps
Cryptoc1 Apr 7, 2026
6bf0644
- [FIX] targets/content includes not copying
Cryptoc1 Apr 7, 2026
49724b6
- [NEW] update README
Cryptoc1 Apr 7, 2026
db5252e
do not publish pr builds
Cryptoc1 Apr 7, 2026
bfc619d
- [NEW] `LinkStandardCPlusPlusLibrary` on any non-windows platform
Cryptoc1 Apr 7, 2026
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
213 changes: 196 additions & 17 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,179 @@ on:
workflow_dispatch:

env:
ARTIFACT_DIR: ${{ github.workspace }}/dist
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/cpp/vcpkg/scripts/buildsystems/vcpkg.cmake
DOTNET_NOLOGO: true
LIBDAVE_VERSION: 1.1.1
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite
VCPKG_CACHE_DIR: ${{ github.workspace }}/vcpkg_cache

jobs:
build:
runs-on: ubuntu-latest
name: build (${{ matrix.rid }})
runs-on: ${{ matrix.runner }}
defaults:
run:
working-directory: ./cpp
shell: bash

strategy:
fail-fast: false
matrix:
include:
- rid: linux-x64
runner: ubuntu-24.04
vcpkg_rid: x64-linux

- rid: linux-arm64
runner: ubuntu-24.04-arm
vcpkg_rid: arm64-linux

- rid: osx-arm64
runner: macos-26
vcpkg_rid: arm64-osx

- rid: osx-x64
runner: macos-26-intel
vcpkg_rid: x64-osx

- rid: win-x64
runner: windows-2025
vcpkg_rid: x64-windows-static

steps:
- name: checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
repository: discord/libdave
ref: v${{ env.LIBDAVE_VERSION }}/cpp
submodules: recursive
fetch-depth: 0

- name: setup dotnet
uses: actions/setup-dotnet@v5
- name: setup vcpkg
run: git -C vcpkg rev-parse HEAD > vcpkg_commit.txt

- name: cache vcpkg
id: cache-vcpkg-restore
uses: actions/cache/restore@v5
with:
cache: true
cache-dependency-path: ./**/packages.lock.json
global-json-file: global.json
path: ${{ env.VCPKG_CACHE_DIR }}
key: vcpkg-${{ matrix.runner }}-openssl-${{ hashFiles('cpp/vcpkg_commit.txt', 'cpp/vcpkg-alts/**') }}
restore-keys: vcpkg-${{ matrix.runner }}-openssl

- name: restore sample
run: dotnet restore sample/libdave.sample.csproj --locked-mode
- name: setup tools (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y nasm

- name: build sample
run: dotnet build sample/libdave.sample.csproj --no-restore
- name: setup tools (macOS)
if: runner.os == 'macOS'
run: brew install go nasm

pack:
if: startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/develop')
- name: bootstrap vcpkg (linux/macOS)
if: runner.os != 'Windows'
run: ./vcpkg/bootstrap-vcpkg.sh -disableMetrics

- name: bootstrap vcpkg (windows)
if: runner.os == 'Windows'
shell: cmd
run: .\vcpkg\bootstrap-vcpkg.bat -disableMetrics

- name: setup build
run: echo "BUILD_DIR=${{ runner.temp }}/build" >> $GITHUB_ENV

- name: configure (shared)
run: |
make "${{ env.BUILD_DIR }}-shared" \
BUILD_DIR="${{ env.BUILD_DIR }}-shared" \
BUILD_TYPE=Release \
BUILD_SHARED_LIBS=ON \
TESTING=OFF \
INSTALL_VCPKG_LICENSES=ON \
MSVC_RUNTIME_LIBRARY=MultiThreaded

- name: configure (static)
run: |
make "${{ env.BUILD_DIR }}-static" \
BUILD_DIR="${{ env.BUILD_DIR }}-static" \
BUILD_TYPE=Release \
BUILD_SHARED_LIBS=OFF \
TESTING=OFF \
INSTALL_VCPKG_LICENSES=ON \
MSVC_RUNTIME_LIBRARY=MultiThreaded

- name: build (shared)
run: |
make all \
BUILD_DIR="${{ env.BUILD_DIR }}-shared" \
BUILD_TYPE=Release

- name: build (static)
run: |
make all \
BUILD_DIR="${{ env.BUILD_DIR }}-static" \
BUILD_TYPE=Release

- name: prepare artifact (linux)
if: runner.os == 'Linux'
run: |
mkdir -p "${{ env.ARTIFACT_DIR }}/bin" "${{ env.ARTIFACT_DIR }}/lib"
cp "${{ env.BUILD_DIR }}-shared/libdave.so" "${{ env.ARTIFACT_DIR }}/bin/libdave.so"
cp "${{ env.BUILD_DIR }}-static/libdave.a" "${{ env.ARTIFACT_DIR }}/lib/libdave.a"

VCPKG_INSTALLED="${{ env.BUILD_DIR }}-static/vcpkg_installed/${{ matrix.vcpkg_rid }}"
cp ${VCPKG_INSTALLED}/lib/libbytes.a ${{ env.ARTIFACT_DIR }}/lib/libbytes.a
cp ${VCPKG_INSTALLED}/lib/libhpke.a ${{ env.ARTIFACT_DIR }}/lib/libhpke.a
cp ${VCPKG_INSTALLED}/lib/libmlspp.a ${{ env.ARTIFACT_DIR }}/lib/libmlspp.a
cp ${VCPKG_INSTALLED}/lib/libtls_syntax.a ${{ env.ARTIFACT_DIR }}/lib/libtls_syntax.a

- name: prepare artifact (macOS)
if: runner.os == 'macOS'
run: |
mkdir -p "${{ env.ARTIFACT_DIR }}/bin" "${{ env.ARTIFACT_DIR }}/lib"
cp "${{ env.BUILD_DIR }}-shared/libdave.dylib" "${{ env.ARTIFACT_DIR }}/bin/libdave.dylib"
cp "${{ env.BUILD_DIR }}-static/libdave.a" "${{ env.ARTIFACT_DIR }}/lib/libdave.a"

VCPKG_INSTALLED="${{ env.BUILD_DIR }}-static/vcpkg_installed/${{ matrix.vcpkg_rid }}"
cp ${VCPKG_INSTALLED}/lib/libbytes.a ${{ env.ARTIFACT_DIR }}/lib/libbytes.a
cp ${VCPKG_INSTALLED}/lib/libhpke.a ${{ env.ARTIFACT_DIR }}/lib/libhpke.a
cp ${VCPKG_INSTALLED}/lib/libmlspp.a ${{ env.ARTIFACT_DIR }}/lib/libmlspp.a
cp ${VCPKG_INSTALLED}/lib/libtls_syntax.a ${{ env.ARTIFACT_DIR }}/lib/libtls_syntax.a

- name: prepare artifact (windows)
if: runner.os == 'Windows'
run: |
mkdir -p "${{ env.ARTIFACT_DIR }}/bin" "${{ env.ARTIFACT_DIR }}/lib"
cp "${{ env.BUILD_DIR }}-shared/Release/libdave.dll" "${{ env.ARTIFACT_DIR }}/bin/libdave.dll"
cp "${{ env.BUILD_DIR }}-static/Release/libdave.lib" "${{ env.ARTIFACT_DIR }}/lib/libdave.lib"

VCPKG_INSTALLED="${{ env.BUILD_DIR }}-static/vcpkg_installed/${{ matrix.vcpkg_rid }}"
cp "${VCPKG_INSTALLED}/lib/bytes.lib" "${{ env.ARTIFACT_DIR }}/lib/libbytes.lib"
cp "${VCPKG_INSTALLED}/lib/hpke.lib" "${{ env.ARTIFACT_DIR }}/lib/libhpke.lib"
cp "${VCPKG_INSTALLED}/lib/mlspp.lib" "${{ env.ARTIFACT_DIR }}/lib/libmlspp.lib"
cp "${VCPKG_INSTALLED}/lib/tls_syntax.lib" "${{ env.ARTIFACT_DIR }}/lib/libtls_syntax.lib"

- name: upload artifact
uses: actions/upload-artifact@v7
with:
name: libdave-${{ matrix.rid }}
path: ${{ env.ARTIFACT_DIR }}

- name: Post cache vcpkg
if: steps.cache-vcpkg-restore.outputs.cache-hit != 'true'
uses: actions/cache/save@v5
with:
key: ${{ steps.cache-vcpkg-restore.outputs.cache-primary-key }}
path: ${{ env.VCPKG_CACHE_DIR }}

pack:
needs: [build]
runs-on: ubuntu-latest

permissions:
checks: write
contents: read

steps:
- name: checkout
uses: actions/checkout@v6
Expand All @@ -54,23 +198,58 @@ jobs:
cache-dependency-path: ./**/packages.lock.json
global-json-file: global.json

- name: download artifacts
uses: actions/download-artifact@v8
with:
pattern: libdave-*
merge-multiple: false
path: artifact

- name: restore
run: dotnet restore --locked-mode
shell: pwsh
run: |
dotnet restore --locked-mode

$artifact = Join-Path ${{ github.workspace }} "artifact"
$output = Join-Path ${{ github.workspace }} "src"

foreach ($runtime in @("linux-arm64", "linux-x64", "osx-arm64", "osx-x64", "win-x64")) {
foreach ($file in Get-ChildItem -Path ([System.IO.Path]::Combine($artifact, "libdave-$runtime", "lib")) -Recurse -File) {
New-Item -ItemType Directory -Path ([System.IO.Path]::Combine($output, "static", $runtime, "native")) -Force | Out-Null

$destination = [System.IO.Path]::Combine($output, "static", $runtime, "native", $file.Name)
Move-Item -Path $file.FullName -Destination $destination -Force

Write-Host "[!] Moved ${file.FullName} to '$destination'"
}

foreach ($file in Get-ChildItem -Path ([System.IO.Path]::Combine($artifact, "libdave-$runtime", "bin")) -Recurse -File) {
New-Item -ItemType Directory -Path ([System.IO.Path]::Combine($output, "shared", $runtime, "native")) -Force | Out-Null

$destination = [System.IO.Path]::Combine($output, "shared", $runtime, "native", $file.Name)
Move-Item -Path $file.FullName -Destination $destination -Force

Write-Host "[!] Moved ${file.FullName} to '$destination'"
}
}

- name: pack
run: dotnet build src/libdave.csproj -c Release && dotnet pack src/libdave.csproj -c Release -o dist --no-build
run: dotnet build src/libdave.csproj -c Release -p:LibDaveVersion="${{ env.LIBDAVE_VERSION }}" && dotnet pack src/libdave.csproj -c Release -o dist --no-build -p:LibDaveVersion="${{ env.LIBDAVE_VERSION }}"

- name: upload artifact
uses: actions/upload-artifact@v7
with:
name: libdave
name: libdave-nuget
path: dist

publish:
if: startsWith(github.ref, 'refs/heads/main') || startsWith(github.ref, 'refs/heads/develop')

needs: [pack]
runs-on: ubuntu-latest

permissions:
contents: read
id-token: write

steps:
Expand All @@ -93,7 +272,7 @@ jobs:
- name: download artifact
uses: actions/download-artifact@v8
with:
name: libdave
name: libdave-nuget

- name: push
run: dotnet nuget push "*.nupkg" --api-key ${{steps.login.outputs.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate
4 changes: 3 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization>
<Features>strict</Features>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<GenerateSBOM Condition=" '$(Configuration)' == 'Release' ">true</GenerateSBOM>
<ImplicitUsings>true</ImplicitUsings>
<IncludeSymbols>true</IncludeSymbols>
<LangVersion>latest</LangVersion>
Expand All @@ -30,7 +31,7 @@

<!-- libdave version -->
<PropertyGroup>
<LibDaveVersion>1.1.1</LibDaveVersion>
<LibDaveVersion Condition=" '$(LibDaveVersion)' == '' ">1.1.1</LibDaveVersion>
</PropertyGroup>

<!-- Git Versioning + Metadata -->
Expand All @@ -54,6 +55,7 @@

<ItemGroup>
<PackageReference Include="MinVer" Version="7.0.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.Sbom.Targets" Version="4.1.5" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.201" PrivateAssets="all" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ Native library assets for [libdave](https://github.com/discord/libdave).

| Property | Default | Description |
| -------------------------------- | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| `$(LibDaveEnableRuntimeLinking)` | `true` | Toggle whether shared libraries are copied to the output directory. |
| `$(LibDaveEnableStaticLinking)` | `$(PublishAot) == 'true' AND $(RuntimeIdentifier) != ''` | Toggle whether `DirectPInvoke`+`NativeLibrary` items are included in the project (for Static Linking) |
| `$(LibDaveRuntimeLinking)` | `true` | Toggle whether shared libraries are copied to the output directory. |
| `$(LibDaveStaticLinking)` | `$(PublishAot) == 'true' AND $(RuntimeIdentifier) != ''` | Toggle whether `DirectPInvoke`+`NativeLibrary` items are included in the project (for Static Linking) |
2 changes: 2 additions & 0 deletions sample/libdave.sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<PublishAot>true</PublishAot>
<RuntimeIdentifiers>linux-x64;win-x64</RuntimeIdentifiers>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>

Expand Down
50 changes: 50 additions & 0 deletions sample/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
"resolved": "10.0.201",
"contentHash": "MTE+F0fj0N8dtfkEGIcX3/rEycMbOf54DXq/n6n8cE6ZfDIPEElY8lc4X5BpZ+c7DBoQDGLG0iBY/W0YZ3nhtw=="
},
"Microsoft.DotNet.ILCompiler": {
"type": "Direct",
"requested": "[10.0.5, )",
"resolved": "10.0.5",
"contentHash": "yadTZIkStCVsG8nGwvfroSfBApPsgjQbodQyaIfp53dgayE0qhZpywixiCB6lx57JYQ+KVg1m1AFLrj54pxpZg=="
},
"Microsoft.NET.ILLink.Tasks": {
"type": "Direct",
"requested": "[10.0.5, )",
"resolved": "10.0.5",
"contentHash": "A+5ZuQ0f449tM+MQrhf6R9ZX7lYpjk/ODEwLYKrnF6111rtARx8fVsm4YznUnQiKnnXfaXNBqgxmil6RW3L3SA=="
},
"Microsoft.Sbom.Targets": {
"type": "Direct",
"requested": "[4.1.5, )",
"resolved": "4.1.5",
"contentHash": "i5z+cNu/cOcdO0AgFB8aXk8w6In2H+haaDfSgd9ImvQIK+rSHavHZIogVoAZLL8jLwYx4bAcs5b7EyuMMG4mQQ=="
},
"Microsoft.SourceLink.GitHub": {
"type": "Direct",
"requested": "[10.0.201, )",
Expand Down Expand Up @@ -46,6 +64,38 @@
"libdave": {
"type": "Project"
}
},
"net10.0/linux-x64": {
"Microsoft.DotNet.ILCompiler": {
"type": "Direct",
"requested": "[10.0.5, )",
"resolved": "10.0.5",
"contentHash": "yadTZIkStCVsG8nGwvfroSfBApPsgjQbodQyaIfp53dgayE0qhZpywixiCB6lx57JYQ+KVg1m1AFLrj54pxpZg==",
"dependencies": {
"runtime.linux-x64.Microsoft.DotNet.ILCompiler": "10.0.5"
}
},
"runtime.linux-x64.Microsoft.DotNet.ILCompiler": {
"type": "Transitive",
"resolved": "10.0.5",
"contentHash": "QYAggijHfk8FpLrPVhaESEOCYGWzEjA9JLapzg6XMFK5TGmwQ2HIqEprFv28MwvB5GdPGaZVLXE5icnkgLUfSA=="
}
},
"net10.0/win-x64": {
"Microsoft.DotNet.ILCompiler": {
"type": "Direct",
"requested": "[10.0.5, )",
"resolved": "10.0.5",
"contentHash": "yadTZIkStCVsG8nGwvfroSfBApPsgjQbodQyaIfp53dgayE0qhZpywixiCB6lx57JYQ+KVg1m1AFLrj54pxpZg==",
"dependencies": {
"runtime.win-x64.Microsoft.DotNet.ILCompiler": "10.0.5"
}
},
"runtime.win-x64.Microsoft.DotNet.ILCompiler": {
"type": "Transitive",
"resolved": "10.0.5",
"contentHash": "vblLkpVhSDYOmrEW0jypX7YVtLg7idU1QzUyx45ZdZ2sFUSSf3mYFCr0FW3+KZgXWpN1ve9ZPrxNywvHISF4bA=="
}
}
}
}
6 changes: 4 additions & 2 deletions src/build/libdave.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

<PropertyGroup>
<LibDaveDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..'))</LibDaveDirectory>
<LibDaveEnableRuntimeLinking Condition=" '$(LibDaveEnableRuntimeLinking)' == '' ">true</LibDaveEnableRuntimeLinking>
<LibDaveEnableStaticLinking Condition=" '$(LibDaveEnableStaticLinking)' == '' AND '$(PublishAot)' == 'true' AND '$(RuntimeIdentifier)' == 'win-x64' ">true</LibDaveEnableStaticLinking>

<LibDaveItemsVisible Condition=" '$(LibDaveItemsVisible)' == '' ">false</LibDaveItemsVisible>
<LibDaveRuntimeLinking Condition=" '$(LibDaveRuntimeLinking)' == '' ">true</LibDaveRuntimeLinking>
<LibDaveStaticLinking Condition=" '$(LibDaveStaticLinking)' == '' ">auto</LibDaveStaticLinking>
<LibDaveStaticLinking Condition=" '$(LibDaveStaticLinking)' == 'auto' AND '$(PublishAot)' == 'true' AND '$(RuntimeIdentifier)' != '' ">true</LibDaveStaticLinking>
</PropertyGroup>

</Project>
Loading