Add build/publish to NuGet workflow

This commit is contained in:
Pat Hartl 2025-03-06 18:18:54 -06:00
parent aa8f666635
commit 0ecce6e4fb

View file

@ -0,0 +1,49 @@
name: IPXRelayDotNet Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
prep:
runs-on: ubuntu-latest
outputs:
version_tag: ${{ steps.trim_tag_ref.outputs.replaced }}
version_semver: ${{ steps.trim_tag_ref.outputs.replaced }}
steps:
- uses: frabert/replace-string-action@v2
name: Trim Tag Ref
id: trim_tag_ref
with:
string: '${{ github.ref }}'
pattern: 'refs/tags/v'
replace-with: ''
publish:
needs: prep
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '7.0.x'
- name: Restore dependencies
run: dotnet restore IPXRelay/IPXRelayDotNet.csproj
- name: Build project
run: dotnet build --configuration Release IPXRelay/IPXRelayDotNet.csproj -p:Version="${{ needs.prep.outputs.version_tag }}" -p:AssemblyVersion="${{ needs.prep.outputs.version_semver }}"
- name: Pack NuGet package with symbols
run: dotnet pack IPXRelay/IPXRelayDotNet.csproj --no-build --configuration Release -p:PackageVersion=${{ needs.prep.outputs.version_tag }} -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -o ./artifacts
- name: Publish NuGet package
run: |
dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json