Skip to content

ci: add github actions and nuget publish pipeline #1

ci: add github actions and nuget publish pipeline

ci: add github actions and nuget publish pipeline #1

Workflow file for this run

name: Publish NuGet

Check failure on line 1 in .github/workflows/publish-nuget.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/publish-nuget.yml

Invalid workflow file

(Line: 46, Col: 13): Unrecognized named-value: 'secrets'. Located at position 26 within expression: vars.NUGET_USER != '' && secrets.NUGET_API_KEY == '', (Line: 53, Col: 13): Unrecognized named-value: 'secrets'. Located at position 26 within expression: vars.NUGET_USER != '' && secrets.NUGET_API_KEY == '', (Line: 59, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.NUGET_API_KEY != ''
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: Validate publishing configuration
shell: bash
run: |
if [[ -z "${{ vars.NUGET_USER }}" && -z "${{ secrets.NUGET_API_KEY }}" ]]; then
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: ${{ vars.NUGET_USER != '' && secrets.NUGET_API_KEY == '' }}
id: nuget-login
uses: NuGet/login@v1
with:
user: ${{ vars.NUGET_USER }}
- name: Push package with Trusted Publishing
if: ${{ vars.NUGET_USER != '' && secrets.NUGET_API_KEY == '' }}
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: ${{ secrets.NUGET_API_KEY != '' }}
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