Skip to content

fix: repair nuget publish workflow conditions #2

fix: repair nuget publish workflow conditions

fix: repair nuget publish workflow conditions #2

Workflow file for this run

name: Publish NuGet
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
jobs:
publish:
runs-on: windows-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore
run: dotnet restore YCode.Designer.Fluxo/YCode.Designer.Fluxo.csproj
- name: Build
run: dotnet build YCode.Designer.Fluxo/YCode.Designer.Fluxo.csproj --configuration Release --no-restore /p:ContinuousIntegrationBuild=true
- name: Pack
run: dotnet pack YCode.Designer.Fluxo/YCode.Designer.Fluxo.csproj --configuration Release --no-build --output artifacts /p:ContinuousIntegrationBuild=true /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg
- name: Determine publishing mode
id: publish-mode
shell: bash
env:
NUGET_USER: ${{ vars.NUGET_USER }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
if [[ -n "$NUGET_API_KEY" ]]; then
echo "mode=classic" >> "$GITHUB_OUTPUT"
elif [[ -n "$NUGET_USER" ]]; then
echo "mode=trusted" >> "$GITHUB_OUTPUT"
else
echo "Configure either repo variable NUGET_USER for Trusted Publishing or secret NUGET_API_KEY for classic publishing."
exit 1
fi
- name: NuGet login with Trusted Publishing
if: ${{ steps.publish-mode.outputs.mode == 'trusted' }}
id: nuget-login
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}
- name: Push package with Trusted Publishing
if: ${{ steps.publish-mode.outputs.mode == 'trusted' }}
run: |
dotnet nuget push "artifacts/*.nupkg" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
dotnet nuget push "artifacts/*.snupkg" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
- name: Push package with classic API key
if: ${{ steps.publish-mode.outputs.mode == 'classic' }}
run: |
dotnet nuget push "artifacts/*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
dotnet nuget push "artifacts/*.snupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
- name: Upload published artifacts
uses: actions/upload-artifact@v4
with:
name: published-nuget-package
path: |
artifacts/*.nupkg
artifacts/*.snupkg