Skip to content

Commit 67716e5

Browse files
committed
* Add NetCord.Natives project and vcpkg support
* Add native ports for libdave and mlspp * Update build workflows for native packaging * Add local targets and CI helpers for natives * Update README
1 parent 36c3303 commit 67716e5

10 files changed

Lines changed: 338 additions & 141 deletions

File tree

.github/workflows/build-and-publish.yml

Lines changed: 23 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -7,93 +7,52 @@ on:
77
- "[0-9]+.[0-9]+.[0-9]+-*"
88

99
jobs:
10-
build-and-publish:
10+
build:
11+
uses: ./.github/workflows/build.yml
12+
13+
publish:
14+
needs: build
1115
runs-on: ubuntu-latest
1216

1317
steps:
14-
- name: Checkout
15-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
18+
- name: Download Build Artifacts
19+
uses: actions/download-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
20+
with:
21+
name: Build Artifacts
22+
path: artifacts/build
23+
24+
- name: Download Documentation Artifacts
25+
uses: actions/download-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
1626
with:
17-
fetch-depth: 0
18-
filter: tree:0
27+
name: Documentation Artifacts
28+
path: artifacts/docs
1929

2030
- name: Install Nix
21-
uses: cachix/install-nix-action@ab739621df7a23f52766f9ccc97f38da6b7af14f # v31.10.5
31+
uses: cachix/install-nix-action@ab739621df7a23f52766f9ccc97f38da6b7af14f
2232

2333
- name: Setup dev environment
2434
shell: &dev-shell 'nix develop -c bash -eo pipefail {0}'
2535
run: 'true'
2636

27-
- name: Restore dependencies
28-
shell: *dev-shell
29-
run: dotnet restore
30-
31-
- name: Build
32-
shell: *dev-shell
33-
run: dotnet build -c Release --no-restore --warnaserror
34-
35-
- name: Test
36-
shell: *dev-shell
37-
run: dotnet test -c Release --no-build --verbosity normal
38-
39-
- name: Pack Packages
40-
shell: *dev-shell
41-
run: |
42-
dotnet pack NetCord -c Release --no-build
43-
dotnet pack NetCord.Services -c Release --no-build
44-
dotnet pack Hosting/NetCord.Hosting -c Release --no-build
45-
dotnet pack Hosting/NetCord.Hosting.Services -c Release --no-build
46-
dotnet pack Hosting/NetCord.Hosting.AspNetCore -c Release --no-build
47-
48-
- name: Setup docs environment
49-
shell: &docs-shell 'nix develop .#docs -c bash -eo pipefail {0}'
50-
run: 'true'
51-
52-
- name: Build Documentation
53-
shell: *docs-shell
54-
working-directory: Documentation
55-
run: |
56-
npm install
57-
npm run lint
58-
npm run test
59-
npm run build
60-
6137
- name: Publish Packages
6238
shell: *dev-shell
6339
env:
6440
KEY: ${{ secrets.NUGET_API_KEY }}
6541
run: |
66-
dotnet nuget push NetCord/bin/Release/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
67-
dotnet nuget push NetCord.Services/bin/Release/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
68-
dotnet nuget push Hosting/NetCord.Hosting/bin/Release/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
69-
dotnet nuget push Hosting/NetCord.Hosting.Services/bin/Release/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
70-
dotnet nuget push Hosting/NetCord.Hosting.AspNetCore/bin/Release/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
42+
dotnet nuget push artifacts/build/NetCord/bin/Release/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
43+
dotnet nuget push artifacts/build/NetCord.Services/bin/Release/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
44+
dotnet nuget push artifacts/build/Hosting/NetCord.Hosting/bin/Release/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
45+
dotnet nuget push artifacts/build/Hosting/NetCord.Hosting.Services/bin/Release/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
46+
dotnet nuget push artifacts/build/Hosting/NetCord.Hosting.AspNetCore/bin/Release/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
7147
7248
- name: Deploy Documentation
73-
uses: appleboy/scp-action@ff85246acaad7bdce478db94a363cd2bf7c90345 # v1.0.0
49+
uses: appleboy/scp-action@ff85246acaad7bdce478db94a363cd2bf7c90345
7450
with:
7551
username: ${{ secrets.SSH_USERNAME }}
7652
host: ${{ secrets.SSH_HOST }}
7753
port: ${{ secrets.SSH_PORT }}
7854
key: ${{ secrets.SSH_KEY }}
7955
rm: true
80-
source: Documentation/_site
56+
source: artifacts/docs
8157
strip_components: 2
8258
target: ~/NetCord/html
83-
84-
- name: Upload Build Artifacts
85-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
86-
with:
87-
name: Build Artifacts
88-
path: |
89-
NetCord/bin/Release
90-
NetCord.Services/bin/Release
91-
Hosting/NetCord.Hosting/bin/Release
92-
Hosting/NetCord.Hosting.Services/bin/Release
93-
Hosting/NetCord.Hosting.AspNetCore/bin/Release
94-
95-
- name: Upload Documentation Artifacts
96-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
97-
with:
98-
name: Documentation Artifacts
99-
path: Documentation/_site
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Build NetCord.Natives
2+
3+
on:
4+
workflow_dispatch: {}
5+
push:
6+
paths:
7+
- 'NetCord.Natives/**'
8+
9+
jobs:
10+
build-natives:
11+
runs-on: ${{ matrix.runs-on }}
12+
env:
13+
CI: true
14+
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/.vcpkg-cache,readwrite
15+
VCPKG_DOWNLOADS: ${{ github.workspace }}/.vcpkg-downloads
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- rid: win-x64
21+
runs-on: windows-latest
22+
vcpkg-os-target: windows
23+
vcpkg-platform-target: x64
24+
- rid: win-arm64
25+
runs-on: windows-latest
26+
vcpkg-os-target: windows
27+
vcpkg-platform-target: arm64
28+
- rid: osx-x64
29+
runs-on: macos-latest
30+
vcpkg-os-target: osx
31+
vcpkg-platform-target: x64
32+
- rid: osx-arm64
33+
runs-on: macos-latest
34+
vcpkg-os-target: osx
35+
vcpkg-platform-target: arm64
36+
- rid: linux-x64
37+
runs-on: ubuntu-latest
38+
vcpkg-os-target: linux
39+
vcpkg-platform-target: x64
40+
- rid: linux-arm64
41+
runs-on: ubuntu-latest
42+
vcpkg-os-target: linux
43+
vcpkg-platform-target: arm64
44+
45+
steps:
46+
- name: Checkout
47+
uses: actions/checkout@v4
48+
49+
- name: Cache vcpkg installs
50+
uses: actions/cache@v4
51+
with:
52+
path: |
53+
.vcpkg-cache
54+
.vcpkg-downloads
55+
key: vcpkg-${{ runner.os }}-${{ matrix.rid }}-${{ hashFiles('NetCord.Natives/vcpkg.json') }}
56+
restore-keys: |
57+
vcpkg-${{ runner.os }}-${{ matrix.rid }}-
58+
vcpkg-${{ runner.os }}-
59+
60+
- name: Setup .NET
61+
uses: actions/setup-dotnet@v4
62+
with:
63+
dotnet-version: 8.0.x
64+
65+
- name: Resolve vcpkg from runner image
66+
shell: pwsh
67+
run: |
68+
$vcpkgRoot = $env:VCPKG_INSTALLATION_ROOT
69+
if (-not $vcpkgRoot) {
70+
$vcpkgCommand = Get-Command vcpkg -ErrorAction Stop
71+
$vcpkgRoot = Split-Path -Parent $vcpkgCommand.Source
72+
}
73+
74+
if (-not (Test-Path $vcpkgRoot)) {
75+
throw "vcpkg installation root not found."
76+
}
77+
78+
"VCPKG_ROOT=$vcpkgRoot" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
79+
"VcpkgMsbuildPath=$vcpkgRoot/scripts/buildsystems/msbuild/vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
80+
81+
- name: Restore
82+
shell: pwsh
83+
run: |
84+
dotnet restore NetCord.Natives/NetCord.Natives.csproj -p:VcpkgMsbuildPath=$env:VcpkgMsbuildPath -p:VcpkgOSTarget=${{ matrix.vcpkg-os-target }} -p:VcpkgPlatformTarget=${{ matrix.vcpkg-platform-target }}
85+
86+
- name: Build native outputs for ${{ matrix.rid }}
87+
shell: pwsh
88+
run: |
89+
dotnet build NetCord.Natives/NetCord.Natives.csproj -c Release --no-restore -p:GeneratePackageOnBuild=false -p:VcpkgMsbuildPath=$env:VcpkgMsbuildPath -p:VcpkgOSTarget=${{ matrix.vcpkg-os-target }} -p:VcpkgPlatformTarget=${{ matrix.vcpkg-platform-target }}
90+
91+
- name: List artifacts
92+
shell: pwsh
93+
run: |
94+
Get-ChildItem -Recurse NetCord.Natives/bin | Select-Object FullName
95+
96+
- name: Upload artifact
97+
uses: actions/upload-artifact@v4
98+
with:
99+
name: ${{ matrix.rid }}
100+
path: NetCord.Natives/bin
101+
102+
pack-natives:
103+
needs: build-natives
104+
runs-on: ubuntu-latest
105+
env:
106+
CI: true
107+
NativeArtifactsRoot: ${{ github.workspace }}/artifacts
108+
109+
steps:
110+
- name: Checkout
111+
uses: actions/checkout@v4
112+
113+
- name: Download native artifacts
114+
uses: actions/download-artifact@v4
115+
with:
116+
path: artifacts
117+
merge-multiple: false
118+
119+
- name: Setup .NET
120+
uses: actions/setup-dotnet@v4
121+
with:
122+
dotnet-version: 8.0.x
123+
124+
- name: Resolve native license root
125+
shell: pwsh
126+
run: |
127+
$licenseRoot = Get-ChildItem artifacts -Directory | Sort-Object Name | Select-Object -First 1
128+
if (-not $licenseRoot) {
129+
throw "No native artifact directories were downloaded."
130+
}
131+
132+
"NativeLicenseRoot=$($licenseRoot.FullName)" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
133+
134+
- name: Pack combined nupkg
135+
shell: pwsh
136+
run: |
137+
dotnet pack NetCord.Natives/NetCord.Natives.csproj -c Release --no-build --no-restore -p:VcpkgMsbuildPath=$env:VcpkgMsbuildPath -p:NativeArtifactsRoot=$env:NativeArtifactsRoot -p:NativeLicenseRoot=$env:NativeLicenseRoot -o artifacts/package
138+
139+
- name: Upload nupkg
140+
uses: actions/upload-artifact@v4
141+
with:
142+
name: NetCord.Natives.Package
143+
path: artifacts/package/*.nupkg

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Build
22

33
on:
4+
workflow_call:
45
pull_request:
56
branches:
67
- stable

0 commit comments

Comments
 (0)