Skip to content

Commit fac897f

Browse files
committed
separate nix workflow & fix warn-no-error
1 parent db1bc79 commit fac897f

6 files changed

Lines changed: 174 additions & 77 deletions

File tree

.github/actions/setup-vcpkg/action.yml

Lines changed: 0 additions & 43 deletions
This file was deleted.

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,22 @@ on:
55
push:
66
paths:
77
- 'NetCord.Natives/**'
8-
- '.github/workflows/build-natives.yml'
8+
- '.github/workflows/build-natives-nix.yml'
9+
- '.github/workflows/build-natives-windows.yml'
910
- '.github/workflows/build-and-publish-natives.yml'
1011
tags:
1112
- "[0-9]+.[0-9]+.[0-9]+"
1213
- "[0-9]+.[0-9]+.[0-9]+-*"
1314

1415
jobs:
15-
build-natives:
16-
uses: ./.github/workflows/build-natives.yml
16+
build-natives-nix:
17+
uses: ./.github/workflows/build-natives-nix.yml
18+
19+
build-natives-windows:
20+
uses: ./.github/workflows/build-natives-windows.yml
1721

1822
publish:
19-
needs: [build-natives]
23+
needs: [build-natives-nix, build-natives-windows]
2024
runs-on: ubuntu-latest
2125

2226
steps:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ jobs:
1616

1717
steps:
1818
- name: Download Build Artifacts
19-
uses: actions/download-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
19+
uses: actions/download-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
2020
with:
2121
name: NuGet Packages
2222
path: artifacts/pkgs
2323
merge-multiple: true
2424

2525
- name: Download Documentation Artifacts
26-
uses: actions/download-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
26+
uses: actions/download-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
2727
with:
2828
name: Documentation Artifacts
2929
path: artifacts/docs
@@ -44,7 +44,7 @@ jobs:
4444
dotnet nuget push artifacts/pkgs/*.snupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate
4545
4646
- name: Deploy Documentation
47-
uses: appleboy/scp-action@ff85246acaad7bdce478db94a363cd2bf7c90345
47+
uses: appleboy/scp-action@ff85246acaad7bdce478db94a363cd2bf7c90345 # v1.0.0
4848
with:
4949
username: ${{ secrets.SSH_USERNAME }}
5050
host: ${{ secrets.SSH_HOST }}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
name: Build NetCord.Natives (Linux/MacOS, Nix)
2+
3+
on:
4+
workflow_call:
5+
workflow_dispatch:
6+
inputs:
7+
GenerateBinLog:
8+
type: boolean
9+
default: false
10+
push:
11+
paths:
12+
- 'NetCord.Natives/**'
13+
- 'Tests/NetCord.Natives.Tests/**'
14+
- '.github/workflows/build-natives-nix.yml'
15+
16+
jobs:
17+
build-natives-nix:
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- rid: osx-x64
23+
runs-on: macos-15-intel
24+
vcpkg-os-target: osx
25+
vcpkg-platform-target: x64
26+
- rid: osx-arm64
27+
runs-on: macos-15
28+
vcpkg-os-target: osx
29+
vcpkg-platform-target: arm64
30+
- rid: linux-x64
31+
runs-on: ubuntu-latest
32+
vcpkg-os-target: linux
33+
vcpkg-platform-target: x64
34+
- rid: linux-arm64
35+
runs-on: ubuntu-24.04-arm
36+
vcpkg-os-target: linux
37+
vcpkg-platform-target: arm64
38+
39+
runs-on: ${{ matrix.runs-on }}
40+
env:
41+
CI: true
42+
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/.vcpkg-cache,readwrite
43+
VCPKG_DOWNLOADS: ${{ github.workspace }}/.vcpkg-downloads
44+
VcpkgOSTarget: ${{ matrix.vcpkg-os-target }}
45+
VcpkgPlatformTarget: ${{ matrix.vcpkg-platform-target }}
46+
Configuration: Release
47+
RuntimeIdentifier: ${{ matrix.rid }}
48+
DotnetVerbose: minimal
49+
GenerateBinLog: ${{ github.event.inputs.GenerateBinLog || inputs.GenerateBinLog || false }}
50+
51+
steps:
52+
- name: Checkout
53+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
54+
with:
55+
fetch-depth: 0
56+
filter: tree:0
57+
58+
- name: Restore vcpkg cache
59+
uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
60+
with:
61+
path: |
62+
.vcpkg-cache
63+
.vcpkg-downloads
64+
key: vcpkg-${{ runner.os }}-${{ matrix.rid }}-${{ hashFiles('NetCord.Natives/vcpkg.json', 'NetCord.Natives/natives-ports/**') }}
65+
restore-keys: |
66+
vcpkg-${{ runner.os }}-${{ matrix.rid }}-
67+
vcpkg-${{ runner.os }}-
68+
69+
- name: Install Nix
70+
uses: cachix/install-nix-action@8aa03977d8d733052d78f4e008a241fd1dbf36b3 # v31.10.6
71+
72+
- name: Setup vcpkg (non-Windows, Nix)
73+
shell: bash
74+
run: |
75+
cat > bootstrap-vcpkg.sh <<'EOF'
76+
#!/usr/bin/env bash
77+
set -euo pipefail
78+
mkdir -p "${VCPKG_BINARY_SOURCES#*,}"
79+
mkdir -p "${VCPKG_DOWNLOADS}"
80+
vcpkgRoot="${GITHUB_WORKSPACE}/NetCord.Natives/vcpkg"
81+
echo "Bootstrapping vcpkg from: $vcpkgRoot"
82+
"$vcpkgRoot/bootstrap-vcpkg.sh" -disableMetrics
83+
echo "VCPKG_ROOT=$vcpkgRoot" >> "$GITHUB_ENV"
84+
EOF
85+
86+
chmod +x bootstrap-vcpkg.sh
87+
nix-shell --run ./bootstrap-vcpkg.sh
88+
rm -f bootstrap-vcpkg.sh
89+
90+
- name: Setup dev shell
91+
shell: &dev-shell 'nix develop -c bash -eo pipefail {0}'
92+
run: 'true'
93+
94+
- name: Restore
95+
shell: *dev-shell
96+
run: |
97+
dotnet restore Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj -v ${{ env.DotnetVerbose }} ${{ env.GenerateBinLog == 'true' && '-bl:restore.binlog' || '' }}
98+
99+
- name: Build natives projects for ${{ matrix.rid }}
100+
shell: *dev-shell
101+
run: >
102+
dotnet build Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj --no-restore -v ${{ env.DotnetVerbose }}
103+
${{ env.GenerateBinLog == 'true' && '-bl:build.binlog' || '' }}
104+
-p:AppendNativeAotAppProps="RuntimeIdentifier=${{ env.RuntimeIdentifier }}"
105+
-p:GeneratePackageOnBuild=false -p:CI=false
106+
107+
- name: Test natives outputs for ${{ matrix.rid }}
108+
shell: *dev-shell
109+
run: >
110+
dotnet test Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj --no-restore --no-build -v ${{ env.DotnetVerbose }}
111+
${{ env.GenerateBinLog == 'true' && '-bl:test.binlog' || '' }}
112+
--logger "console;verbosity=detailed"
113+
--logger GitHubActions
114+
115+
- name: Pack NuGet Package for ${{ matrix.rid }}
116+
if: ${{ always() }}
117+
shell: *dev-shell
118+
run: >
119+
dotnet pack NetCord.Natives/NetCord.Natives.csproj --no-restore --no-build -v ${{ env.DotnetVerbose }}
120+
${{ env.GenerateBinLog == 'true' && '-bl:pack.binlog' || '' }}
121+
-o NetCord.Natives/bin/${{ matrix.rid }}
122+
-p:CI=false
123+
124+
- name: Upload Binary Logs
125+
if: ${{ env.GenerateBinLog == 'true' && always() }}
126+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
127+
with:
128+
name: ${{ matrix.rid }}-binlogs
129+
path: |
130+
*.binlog
131+
132+
- name: Upload NuGet Package Artifact
133+
if: ${{ always() }}
134+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
135+
with:
136+
name: NetCord.Natives.${{ matrix.rid }}.packages
137+
path: |
138+
NetCord.Natives/bin/${{ matrix.rid }}/*.nupkg
139+
NetCord.Natives/bin/${{ matrix.rid }}/*.snupkg
140+
141+
- name: Save vcpkg cache
142+
if: ${{ always() }}
143+
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
144+
with:
145+
path: |
146+
.vcpkg-cache
147+
.vcpkg-downloads
148+
key: vcpkg-${{ runner.os }}-${{ matrix.rid }}-${{ hashFiles('NetCord.Natives/vcpkg.json', 'NetCord.Natives/natives-ports/**') }}

.github/workflows/build-natives.yml renamed to .github/workflows/build-natives-windows.yml

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build NetCord.Natives
1+
name: Build NetCord.Natives (Windows)
22

33
on:
44
workflow_call:
@@ -11,10 +11,10 @@ on:
1111
paths:
1212
- 'NetCord.Natives/**'
1313
- 'Tests/NetCord.Natives.Tests/**'
14-
- '.github/workflows/build-natives.yml'
14+
- '.github/workflows/build-natives-windows.yml'
1515

1616
jobs:
17-
build-natives:
17+
build-natives-windows:
1818
strategy:
1919
fail-fast: false
2020
matrix:
@@ -27,22 +27,6 @@ jobs:
2727
runs-on: windows-11-arm
2828
vcpkg-os-target: windows
2929
vcpkg-platform-target: arm64
30-
- rid: osx-x64
31-
runs-on: macos-15-intel
32-
vcpkg-os-target: osx
33-
vcpkg-platform-target: x64
34-
- rid: osx-arm64
35-
runs-on: macos-15
36-
vcpkg-os-target: osx
37-
vcpkg-platform-target: arm64
38-
- rid: linux-x64
39-
runs-on: ubuntu-latest
40-
vcpkg-os-target: linux
41-
vcpkg-platform-target: x64
42-
- rid: linux-arm64
43-
runs-on: ubuntu-24.04-arm
44-
vcpkg-os-target: linux
45-
vcpkg-platform-target: arm64
4630

4731
runs-on: ${{ matrix.runs-on }}
4832
env:
@@ -74,26 +58,29 @@ jobs:
7458
vcpkg-${{ runner.os }}-${{ matrix.rid }}-
7559
vcpkg-${{ runner.os }}-
7660
77-
- name: Setup vcpkg
78-
uses: ./.github/actions/setup-vcpkg
61+
- name: Setup vcpkg (Windows)
62+
shell: pwsh
63+
run: |
64+
New-Item -ItemType Directory -Path $env:VCPKG_BINARY_SOURCES.Split(',')[1] -Force | Out-Null
65+
New-Item -ItemType Directory -Path $env:VCPKG_DOWNLOADS -Force | Out-Null
66+
$vcpkgRoot = Join-Path $env:GITHUB_WORKSPACE "NetCord.Natives/vcpkg"
67+
Write-Host "Bootstrapping vcpkg from: $vcpkgRoot"
68+
& "$vcpkgRoot/bootstrap-vcpkg.bat" -disableMetrics
69+
"VCPKG_ROOT=$vcpkgRoot" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
7970
8071
- name: Setup .NET Core SDK
8172
uses: actions/setup-dotnet@c2fa09f4bde5ebb9d1777cf28262a3eb3db3ced7 # v5.2.0
8273
with:
8374
global-json-file: global.json
8475

85-
# - name: Install Nix
86-
# if: runner.os != 'Windows'
87-
# uses: cachix/install-nix-action@8aa03977d8d733052d78f4e008a241fd1dbf36b3 # v31.10.6
88-
8976
- name: Restore
9077
shell: pwsh
9178
run: |
9279
dotnet restore Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj -v ${{ env.DotnetVerbose }} ${{ env.GenerateBinLog == 'true' && '-bl:restore.binlog' || '' }}
9380
9481
- name: Build natives projects for ${{ matrix.rid }}
9582
shell: pwsh
96-
run: > # Building tests will build dependencies including the native libraries
83+
run: >
9784
dotnet build Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj --no-restore -v ${{ env.DotnetVerbose }}
9885
${{ env.GenerateBinLog == 'true' && '-bl:build.binlog' || '' }}
9986
-p:AppendNativeAotAppProps="RuntimeIdentifier=${{ env.RuntimeIdentifier }}"
@@ -118,7 +105,7 @@ jobs:
118105
119106
- name: Upload Binary Logs
120107
if: ${{ env.GenerateBinLog == 'true' && always() }}
121-
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
108+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
122109
with:
123110
name: ${{ matrix.rid }}-binlogs
124111
path: |

NetCord.Natives/natives-ports/mlspp/portfile.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ vcpkg_cmake_configure(
1919
-DTESTING=OFF
2020
-DBUILD_TESTING=OFF
2121
-DMLS_CXX_NAMESPACE="mlspp"
22+
-DCMAKE_CXX_FLAGS="-Wno-error"
2223
MAYBE_UNUSED_VARIABLES
2324
BUILD_TESTING
2425
)

0 commit comments

Comments
 (0)