Skip to content

v0.0.6

v0.0.6 #6

Workflow file for this run

name: Publish to NuGet
on:
release:
types: [published]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
build-native:
name: Build native (${{ matrix.rid }})
runs-on: ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
strategy:
fail-fast: false
matrix:
include:
- rid: win-x64
os: windows-latest
target: x86_64-pc-windows-msvc
artifact: tp_lib_net.dll
- rid: linux-x64
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact: libtp_lib_net.so
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build native library
run: cargo build --release -p tp-lib-net --target ${{ matrix.target }}
- name: Stage artifact
shell: bash
run: |
mkdir -p staging
cp target/${{ matrix.target }}/release/${{ matrix.artifact }} staging/
- name: Upload native artifact
uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.rid }}
path: staging/${{ matrix.artifact }}
pack-and-publish:
name: Pack and publish to NuGet
needs: build-native
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
permissions:
contents: read
id-token: write # required for GitHub OIDC token issuance (trusted publishing)
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Download all native artifacts
uses: actions/download-artifact@v4
with:
path: native-artifacts
- name: Arrange runtimes
run: |
mkdir -p tp-net/csharp/runtimes/win-x64/native
mkdir -p tp-net/csharp/runtimes/linux-x64/native
cp native-artifacts/native-win-x64/tp_lib_net.dll tp-net/csharp/runtimes/win-x64/native/
cp native-artifacts/native-linux-x64/libtp_lib_net.so tp-net/csharp/runtimes/linux-x64/native/
- name: Pack
run: |
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
PACKAGE_VERSION="${GITHUB_REF_NAME#v}"
dotnet pack tp-net/csharp/TpLib.csproj -c Release -o nupkg -p:PackageVersion="${PACKAGE_VERSION}"
else
dotnet pack tp-net/csharp/TpLib.csproj -c Release -o nupkg
fi
- name: Upload nupkg
uses: actions/upload-artifact@v4
with:
name: nupkg
path: nupkg/*.nupkg
- name: NuGet login (OIDC trusted publishing)
if: startsWith(github.ref, 'refs/tags/v')
uses: NuGet/login@v1
id: nuget-login
with:
user: ${{ secrets.NUGET_USER }}
- name: Publish to NuGet
if: startsWith(github.ref, 'refs/tags/v')
run: |
dotnet nuget push "nupkg/*.nupkg" \
--api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate