Skip to content

Refine NuGet publish workflow to specify project paths for restore, b… #2

Refine NuGet publish workflow to specify project paths for restore, b…

Refine NuGet publish workflow to specify project paths for restore, b… #2

Workflow file for this run

name: Publish NuGet Package
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+-*'
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Extract version from tag
id: get_version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj
- name: Build
run: dotnet build ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj --configuration Release --no-restore /p:Version=${{ steps.get_version.outputs.VERSION }}
- name: Pack
run: dotnet pack ./src/NullOpsDevs.Bootstrap/NullOpsDevs.Bootstrap.csproj --configuration Release --no-build --output ./artifacts /p:Version=${{ steps.get_version.outputs.VERSION }}
- name: Push to NuGet
run: dotnet nuget push ./artifacts/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: ./artifacts/*.nupkg
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}