feat(Meta): v0.0.6 #6
Workflow file for this run
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
| name: Publish NuGet on Tag push | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_call: | |
| inputs: | |
| dotnet-version: | |
| description: '.NET SDK version' | |
| required: false | |
| default: '10.x.x' | |
| type: string | |
| project-path: | |
| description: 'Path to the .csproj to pack' | |
| required: false | |
| default: 'WrathCombo.API.csproj' | |
| type: string | |
| package-output: | |
| description: 'Output folder for packed packages' | |
| required: false | |
| default: 'bin/Release/nuget' | |
| type: string | |
| secrets: | |
| NUGET_API_KEY: | |
| description: 'API key for pushing to NuGet' | |
| required: true | |
| permissions: | |
| contents: read | |
| env: | |
| DOTNET_VERSION: ${{ inputs.dotnet-version || '10.x.x' }} | |
| jobs: | |
| pack-and-push: | |
| runs-on: windows-latest | |
| env: | |
| PROJECT_PATH: ${{ inputs.project-path || 'WrathCombo.API.csproj' }} | |
| PACKAGE_OUTPUT: ${{ inputs.package-output || 'bin/Release/nuget' }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| dotnet-quality: preview | |
| - name: Derive package version from tag | |
| shell: pwsh | |
| run: | | |
| $tag = $env:GITHUB_REF.Split('/')[-1] | |
| $version = $tag.TrimStart('v') | |
| if (-not $version) { throw 'Tag name missing version' } | |
| Write-Host "Derived version: $version" | |
| "PACKAGE_VERSION=$version" >> $env:GITHUB_ENV | |
| - name: Restore | |
| run: dotnet restore | |
| - name: Build | |
| run: dotnet build $env:PROJECT_PATH -c Release -p:ContinuousIntegrationBuild=true | |
| - name: Pack | |
| run: dotnet pack $env:PROJECT_PATH -c Release --no-build -p:PackageVersion=$env:PACKAGE_VERSION -p:ContinuousIntegrationBuild=true -o $env:PACKAGE_OUTPUT | |
| - name: Verify and locate packages | |
| shell: pwsh | |
| run: | | |
| Write-Host "PACKAGE_OUTPUT=$env:PACKAGE_OUTPUT" | |
| if (Test-Path "$env:PACKAGE_OUTPUT") { | |
| Write-Host "Listing contents of $env:PACKAGE_OUTPUT"; | |
| Get-ChildItem -Path "$env:PACKAGE_OUTPUT" -Recurse | Format-Table -AutoSize FullName, Length | |
| } else { | |
| Write-Host "Package output directory missing: $env:PACKAGE_OUTPUT" | |
| } | |
| Write-Host "Searching for .nupkg under workspace: $env:GITHUB_WORKSPACE" | |
| $nupkgs = Get-ChildItem -Path $env:GITHUB_WORKSPACE -Recurse -Filter '*.nupkg' | |
| if (-not $nupkgs) { | |
| Write-Host "No .nupkg found anywhere under $env:GITHUB_WORKSPACE"; exit 1 | |
| } | |
| Write-Host "Found .nupkg files:"; | |
| $nupkgs | ForEach-Object { Write-Host $_.FullName } | |
| $pkgDir = $nupkgs[0].Directory.FullName | |
| Write-Host "Using package directory: $pkgDir" | |
| "PKG_DIR=$pkgDir" >> $env:GITHUB_ENV | |
| - name: Push package to NuGet | |
| shell: pwsh | |
| env: | |
| NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} | |
| run: | | |
| Write-Host "Pushing packages from $env:PKG_DIR" | |
| $nupkgs = Get-ChildItem -Path $env:PKG_DIR -Filter '*.nupkg' | |
| if (-not $nupkgs) { | |
| Write-Host "No .nupkg found in $env:PKG_DIR"; exit 1 | |
| } | |
| foreach ($pkg in $nupkgs) { | |
| Write-Host "Pushing $($pkg.FullName)"; | |
| dotnet nuget push $pkg.FullName --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| } | |
| $snupkgs = Get-ChildItem -Path $env:PKG_DIR -Filter '*.snupkg' | |
| foreach ($pkg in $snupkgs) { | |
| Write-Host "Pushing symbols $($pkg.FullName)"; | |
| dotnet nuget push $pkg.FullName --api-key $env:NUGET_API_KEY --source https://api.nuget.org/v3/index.json --skip-duplicate | |
| } | |
| - name: Upload packages as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: nuget-packages | |
| path: ${{ env.PACKAGE_OUTPUT }}/* |