Skip to content

#7 fix NuGet push step (#8) #3

#7 fix NuGet push step (#8)

#7 fix NuGet push step (#8) #3

name: Build and Publish FastTrack NuGet Package
on:
push:
branches:
- main
paths:
- 'FastTrack/**'
- '.github/workflows/fasttrack-nuget.yml'
workflow_dispatch:
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Restore dependencies
run: dotnet restore FastTrack/FastTrack.csproj
- name: Build
run: dotnet build FastTrack/FastTrack.csproj --configuration Release --no-restore
- name: Set workspace and nupkg output directory
id: vars
run: |
echo "::set-output name=workspace::${{ github.workspace }}"
echo "::set-output name=nupkgdir::${{ github.workspace }}/nupkgs"
- name: Pack NuGet package
run: dotnet pack FastTrack/FastTrack.csproj --configuration Release --no-build --output "${{ steps.vars.outputs.nupkgdir }}"
- name: List contents of nupkgs directory
run: |
echo "Listing contents of nupkgs directory:"
dir "${{ steps.vars.outputs.nupkgdir }}"
- name: Fail if no .nupkg found
run: |
if (!(Test-Path -Path "${{ steps.vars.outputs.nupkgdir }}/*.nupkg")) { Write-Error "No .nupkg file found in nupkgs directory."; exit 1 }
shell: pwsh
- name: Publish to NuGet.org
uses: actions/upload-artifact@v4
with:
name: fasttrack-nuget
path: ${{ steps.vars.outputs.nupkgdir }}/*.nupkg
- name: Push package to NuGet.org
run: dotnet nuget push "${{ steps.vars.outputs.nupkgdir }}"/*.nupkg --api-key ${{ secrets.NUGET_API_KEY }} --source https://api.nuget.org/v3/index.json
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}