Skip to content

Commit 2b0ea4f

Browse files
committed
fix: repair nuget publish workflow conditions
1 parent 6c81c4e commit 2b0ea4f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

.github/workflows/publish-nuget.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,37 @@ jobs:
3434
- name: Pack
3535
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
3636

37-
- name: Validate publishing configuration
37+
- name: Determine publishing mode
38+
id: publish-mode
3839
shell: bash
40+
env:
41+
NUGET_USER: ${{ vars.NUGET_USER }}
42+
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
3943
run: |
40-
if [[ -z "${{ vars.NUGET_USER }}" && -z "${{ secrets.NUGET_API_KEY }}" ]]; then
44+
if [[ -n "$NUGET_API_KEY" ]]; then
45+
echo "mode=classic" >> "$GITHUB_OUTPUT"
46+
elif [[ -n "$NUGET_USER" ]]; then
47+
echo "mode=trusted" >> "$GITHUB_OUTPUT"
48+
else
4149
echo "Configure either repo variable NUGET_USER for Trusted Publishing or secret NUGET_API_KEY for classic publishing."
4250
exit 1
4351
fi
4452
4553
- name: NuGet login with Trusted Publishing
46-
if: ${{ vars.NUGET_USER != '' && secrets.NUGET_API_KEY == '' }}
54+
if: ${{ steps.publish-mode.outputs.mode == 'trusted' }}
4755
id: nuget-login
4856
uses: NuGet/login@v1
4957
with:
5058
user: ${{ vars.NUGET_USER }}
5159

5260
- name: Push package with Trusted Publishing
53-
if: ${{ vars.NUGET_USER != '' && secrets.NUGET_API_KEY == '' }}
61+
if: ${{ steps.publish-mode.outputs.mode == 'trusted' }}
5462
run: |
5563
dotnet nuget push "artifacts/*.nupkg" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
5664
dotnet nuget push "artifacts/*.snupkg" --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
5765
5866
- name: Push package with classic API key
59-
if: ${{ secrets.NUGET_API_KEY != '' }}
67+
if: ${{ steps.publish-mode.outputs.mode == 'classic' }}
6068
run: |
6169
dotnet nuget push "artifacts/*.nupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate
6270
dotnet nuget push "artifacts/*.snupkg" --api-key "${{ secrets.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate

0 commit comments

Comments
 (0)