-
-
Notifications
You must be signed in to change notification settings - Fork 40
Provide prebuilt native libraries by NuGet Packages. #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ha-ves
wants to merge
16
commits into
NetCordDev:main
Choose a base branch
from
ha-ves:feature/prebuilt-natives
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9638b17
Pivot to use vcpkg to build natives
ha-ves f5c24eb
* Add NetCord.Natives project and vcpkg support
ha-ves f2f2384
feat: native library support and testing
ha-ves a805dd6
* Refactor NetCord.Natives.csproj for improved build configuration
ha-ves 5c2f7f0
* Refactor native library handling and packaging
ha-ves a5e9a4c
CI finished & fix typos & guarding
ha-ves 6d485fb
solution build fix
ha-ves f9cfc3f
separate solution for natives
ha-ves 5e2ab68
refactor native build/test pipeline
ha-ves 355ffd6
Clean up & atomize CI workflows
ha-ves 041858d
Apply typos and internals fixes
ha-ves 50f0e3e
Resolve PR comments
Copilot db1bc79
Revert to not using nix for building the natives,
ha-ves fac897f
separate nix workflow & fix warn-no-error
ha-ves 990f54d
fix checkout submodules
ha-ves e0b2431
[skip ci] rearrange nix & fix vcpkg
ha-ves File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| name: Build & Publish NetCord.Natives | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| paths: | ||
| - 'NetCord.Natives/**' | ||
| - '.github/workflows/build-natives-nix.yml' | ||
| - '.github/workflows/build-natives-windows.yml' | ||
| - '.github/workflows/build-and-publish-natives.yml' | ||
| tags: | ||
| - "[0-9]+.[0-9]+.[0-9]+" | ||
| - "[0-9]+.[0-9]+.[0-9]+-*" | ||
|
|
||
| jobs: | ||
| build-natives-nix: | ||
| uses: ./.github/workflows/build-natives-nix.yml | ||
|
|
||
| build-natives-windows: | ||
| uses: ./.github/workflows/build-natives-windows.yml | ||
|
|
||
| publish: | ||
| needs: [build-natives-nix, build-natives-windows] | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Download All NuGet Package Artifacts | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| path: artifacts/pkgs | ||
| pattern: NetCord.Natives.*.packages | ||
| merge-multiple: true | ||
|
|
||
| - name: Publish packages | ||
| env: | ||
| KEY: ${{ secrets.NUGET_API_KEY }} | ||
| run: | | ||
| dotnet nuget push artifacts/pkgs/*.nupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate | ||
| dotnet nuget push artifacts/pkgs/*.snupkg -k $KEY -s https://api.nuget.org/v3/index.json --skip-duplicate | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| name: Build NetCord.Natives (Linux/MacOS, Nix) | ||
|
|
||
| on: | ||
| workflow_call: | ||
| workflow_dispatch: | ||
| inputs: | ||
| GenerateBinLog: | ||
| type: boolean | ||
| default: false | ||
| push: | ||
| paths: | ||
| - 'NetCord.Natives/**' | ||
| - 'Tests/NetCord.Natives.Tests/**' | ||
| - '.github/workflows/build-natives-nix.yml' | ||
|
|
||
| jobs: | ||
| build-natives-nix: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - rid: osx-x64 | ||
| runs-on: macos-15-intel | ||
| vcpkg-os-target: osx | ||
| vcpkg-platform-target: x64 | ||
| - rid: osx-arm64 | ||
| runs-on: macos-15 | ||
| vcpkg-os-target: osx | ||
| vcpkg-platform-target: arm64 | ||
| - rid: linux-x64 | ||
| runs-on: ubuntu-latest | ||
| vcpkg-os-target: linux | ||
| vcpkg-platform-target: x64 | ||
| - rid: linux-arm64 | ||
| runs-on: ubuntu-24.04-arm | ||
| vcpkg-os-target: linux | ||
| vcpkg-platform-target: arm64 | ||
|
|
||
| runs-on: ${{ matrix.runs-on }} | ||
| env: | ||
| CI: true | ||
| VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/.vcpkg-cache,readwrite | ||
| VCPKG_DOWNLOADS: ${{ github.workspace }}/.vcpkg-downloads | ||
| VcpkgOSTarget: ${{ matrix.vcpkg-os-target }} | ||
| VcpkgPlatformTarget: ${{ matrix.vcpkg-platform-target }} | ||
| Configuration: Release | ||
| RuntimeIdentifier: ${{ matrix.rid }} | ||
| DotnetVerbose: minimal | ||
| GenerateBinLog: ${{ github.event.inputs.GenerateBinLog || inputs.GenerateBinLog || false }} | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| fetch-depth: 0 | ||
| filter: tree:0 | ||
| submodules: true | ||
|
|
||
| - name: Restore vcpkg cache | ||
| uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | ||
| with: | ||
| path: | | ||
| .vcpkg-cache | ||
| .vcpkg-downloads | ||
| key: vcpkg-${{ runner.os }}-${{ matrix.rid }}-${{ hashFiles('NetCord.Natives/vcpkg.json', 'NetCord.Natives/natives-ports/**') }} | ||
| restore-keys: | | ||
| vcpkg-${{ runner.os }}-${{ matrix.rid }}- | ||
| vcpkg-${{ runner.os }}- | ||
|
|
||
| - name: Install Nix | ||
| uses: cachix/install-nix-action@8aa03977d8d733052d78f4e008a241fd1dbf36b3 # v31.10.6 | ||
|
|
||
| - name: Setup dev shell | ||
| shell: &dev-shell 'nix develop -c bash -eo pipefail {0}' | ||
| run: 'true' | ||
|
|
||
| - name: Setup vcpkg (non-Windows, Nix) | ||
| shell: *dev-shell | ||
| run: | | ||
| mkdir -p "${VCPKG_BINARY_SOURCES#*,}" | ||
| mkdir -p "${VCPKG_DOWNLOADS}" | ||
| vcpkgRoot="${GITHUB_WORKSPACE}/NetCord.Natives/vcpkg" | ||
| echo "Bootstrapping vcpkg from: $vcpkgRoot" | ||
| "$vcpkgRoot/bootstrap-vcpkg.sh" -disableMetrics | ||
| echo "VCPKG_ROOT=$vcpkgRoot" >> "$GITHUB_ENV" | ||
|
|
||
| - name: Restore | ||
| shell: *dev-shell | ||
| run: | | ||
| dotnet restore Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj -v ${{ env.DotnetVerbose }} ${{ env.GenerateBinLog == 'true' && '-bl:restore.binlog' || '' }} | ||
|
|
||
| - name: Build natives projects for ${{ matrix.rid }} | ||
| shell: *dev-shell | ||
| run: > | ||
| dotnet build Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj --no-restore -v ${{ env.DotnetVerbose }} | ||
| ${{ env.GenerateBinLog == 'true' && '-bl:build.binlog' || '' }} | ||
| -p:AppendNativeAotAppProps="RuntimeIdentifier=${{ env.RuntimeIdentifier }}" | ||
| -p:GeneratePackageOnBuild=false -p:CI=false | ||
|
|
||
| - name: Test natives outputs for ${{ matrix.rid }} | ||
| shell: *dev-shell | ||
| run: > | ||
| dotnet test Tests/NetCord.Natives.Tests/NetCord.Natives.Tests.csproj --no-restore --no-build -v ${{ env.DotnetVerbose }} | ||
| ${{ env.GenerateBinLog == 'true' && '-bl:test.binlog' || '' }} | ||
| --logger "console;verbosity=detailed" | ||
| --logger GitHubActions | ||
|
|
||
| - name: Pack NuGet Package for ${{ matrix.rid }} | ||
| if: ${{ always() }} | ||
| shell: *dev-shell | ||
| run: > | ||
| dotnet pack NetCord.Natives/NetCord.Natives.csproj --no-restore --no-build -v ${{ env.DotnetVerbose }} | ||
| ${{ env.GenerateBinLog == 'true' && '-bl:pack.binlog' || '' }} | ||
| -o NetCord.Natives/bin/${{ matrix.rid }} | ||
| -p:CI=false | ||
|
|
||
| - name: Upload Binary Logs | ||
| if: ${{ env.GenerateBinLog == 'true' && always() }} | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: ${{ matrix.rid }}-binlogs | ||
| path: | | ||
| *.binlog | ||
|
|
||
| - name: Upload NuGet Package Artifact | ||
| if: ${{ always() }} | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: NetCord.Natives.${{ matrix.rid }}.packages | ||
| path: | | ||
| NetCord.Natives/bin/${{ matrix.rid }}/*.nupkg | ||
| NetCord.Natives/bin/${{ matrix.rid }}/*.snupkg | ||
|
|
||
| - name: Save vcpkg cache | ||
| if: ${{ always() }} | ||
| uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 | ||
| with: | ||
| path: | | ||
| .vcpkg-cache | ||
| .vcpkg-downloads | ||
| key: vcpkg-${{ runner.os }}-${{ matrix.rid }}-${{ hashFiles('NetCord.Natives/vcpkg.json', 'NetCord.Natives/natives-ports/**') }} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.