From f58d5176516ab8c98ed07d6251f7e4579dbc3d9d Mon Sep 17 00:00:00 2001 From: OlegMozhey Date: Sat, 8 Mar 2025 18:56:51 +0400 Subject: [PATCH 1/5] add verbose logging of failed publishing to nuget.org --- .github/workflows/Release.yaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Release.yaml b/.github/workflows/Release.yaml index 64f6e73..d257d12 100644 --- a/.github/workflows/Release.yaml +++ b/.github/workflows/Release.yaml @@ -45,4 +45,11 @@ jobs: - name: Publish app into nuget.org env: NUGET_API_KEY: ${{ secrets.QUANTORI_NUGET_API_KEY }} - run: dotnet nuget push ./Behavioral.Automation.${{ env.VER }}.nupkg -s "https://api.nuget.org/v3/index.json" -k "$NUGET_API_KEY" --skip-duplicate + run: | + if dotnet nuget push ./Behavioral.Automation.${{ env.VER }}.nupkg -s "https://api.nuget.org/v3/index.json" -k "$NUGET_API_KEY" --skip-duplicate 2>&1 | tee output.log | grep -q "403"; then + echo "NError: NuGet API key is invalid or expired. Please contact Quantori support to renew the key. For more details, refer to the Quantori BDD Confluence page called 'Renew NuGet API key'." + exit 1 + else + echo "Package successfully published to NuGet.org." + fi + \ No newline at end of file From f838db23d044d17d09a1d448b8db4054dbdc612d Mon Sep 17 00:00:00 2001 From: OlegMozhey Date: Sat, 8 Mar 2025 19:01:41 +0400 Subject: [PATCH 2/5] small adjustment --- .github/workflows/Release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Release.yaml b/.github/workflows/Release.yaml index d257d12..d4784f2 100644 --- a/.github/workflows/Release.yaml +++ b/.github/workflows/Release.yaml @@ -46,7 +46,7 @@ jobs: env: NUGET_API_KEY: ${{ secrets.QUANTORI_NUGET_API_KEY }} run: | - if dotnet nuget push ./Behavioral.Automation.${{ env.VER }}.nupkg -s "https://api.nuget.org/v3/index.json" -k "$NUGET_API_KEY" --skip-duplicate 2>&1 | tee output.log | grep -q "403"; then + if dotnet nuget push ./Behavioral.Automation.${{ env.VER }}.nupkg -s "https://api.nuget.org/v3/index.json" -k "$NUGET_API_KEY" --skip-duplicate 2>&1 | tee /dev/stderr | grep -q "403"; then echo "NError: NuGet API key is invalid or expired. Please contact Quantori support to renew the key. For more details, refer to the Quantori BDD Confluence page called 'Renew NuGet API key'." exit 1 else From 066107ea578a10f35d0bd6d3ce241f4ec0c97d84 Mon Sep 17 00:00:00 2001 From: OlegMozhey Date: Sat, 8 Mar 2025 19:02:54 +0400 Subject: [PATCH 3/5] fix typo --- .github/workflows/Release.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Release.yaml b/.github/workflows/Release.yaml index d4784f2..c021de9 100644 --- a/.github/workflows/Release.yaml +++ b/.github/workflows/Release.yaml @@ -47,7 +47,7 @@ jobs: NUGET_API_KEY: ${{ secrets.QUANTORI_NUGET_API_KEY }} run: | if dotnet nuget push ./Behavioral.Automation.${{ env.VER }}.nupkg -s "https://api.nuget.org/v3/index.json" -k "$NUGET_API_KEY" --skip-duplicate 2>&1 | tee /dev/stderr | grep -q "403"; then - echo "NError: NuGet API key is invalid or expired. Please contact Quantori support to renew the key. For more details, refer to the Quantori BDD Confluence page called 'Renew NuGet API key'." + echo "Error: NuGet API key is invalid or expired. Please contact Quantori support to renew the key. For more details, refer to the Quantori BDD Confluence page called 'Renew NuGet API key'." exit 1 else echo "Package successfully published to NuGet.org." From 85f510fa4d82b99d6cd9f3c2f5b0bdd4e6672fa2 Mon Sep 17 00:00:00 2001 From: OlegMozhey Date: Mon, 10 Mar 2025 14:20:46 +0400 Subject: [PATCH 4/5] Update to handle more cases --- .github/workflows/Release.yaml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/Release.yaml b/.github/workflows/Release.yaml index c021de9..9f398b6 100644 --- a/.github/workflows/Release.yaml +++ b/.github/workflows/Release.yaml @@ -46,9 +46,21 @@ jobs: env: NUGET_API_KEY: ${{ secrets.QUANTORI_NUGET_API_KEY }} run: | - if dotnet nuget push ./Behavioral.Automation.${{ env.VER }}.nupkg -s "https://api.nuget.org/v3/index.json" -k "$NUGET_API_KEY" --skip-duplicate 2>&1 | tee /dev/stderr | grep -q "403"; then + exit_code=0 + output=$(dotnet nuget push ./Behavioral.Automation.${{ env.VER }}.nupkg -s "https://api.nuget.org/v3/index.json" -k "$NUGET_API_KEY" --skip-duplicate 2>&1) || { + echo "An error occurred while running the dotnet nuget push command." + exit_code=1 + } + + echo "$output" + echo "Exit Code: $exit_code" + + if echo "$output" | grep -q "403"; then echo "Error: NuGet API key is invalid or expired. Please contact Quantori support to renew the key. For more details, refer to the Quantori BDD Confluence page called 'Renew NuGet API key'." - exit 1 + exit 1 + elif [ $exit_code -ne 0 ]; then + echo "Error: dotnet nuget push failed. Check the logs for more details." + exit 1 else echo "Package successfully published to NuGet.org." fi From 93d626d8c4c4d14271bde91110f22598f52173c9 Mon Sep 17 00:00:00 2001 From: OlegMozhey Date: Mon, 10 Mar 2025 14:30:20 +0400 Subject: [PATCH 5/5] Final solution --- .github/workflows/Release.yaml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/Release.yaml b/.github/workflows/Release.yaml index 9f398b6..e6e927c 100644 --- a/.github/workflows/Release.yaml +++ b/.github/workflows/Release.yaml @@ -45,12 +45,10 @@ jobs: - name: Publish app into nuget.org env: NUGET_API_KEY: ${{ secrets.QUANTORI_NUGET_API_KEY }} - run: | - exit_code=0 - output=$(dotnet nuget push ./Behavioral.Automation.${{ env.VER }}.nupkg -s "https://api.nuget.org/v3/index.json" -k "$NUGET_API_KEY" --skip-duplicate 2>&1) || { - echo "An error occurred while running the dotnet nuget push command." - exit_code=1 - } + run: | + output=$(dotnet nuget push ./Behavioral.Automation.${{ env.VER }}.nupkg -s "https://api.nuget.org/v3/index.json" -k "$NUGET_API_KEY" --skip-duplicate 2>&1) || exit_code=$? + + if [ -z "$exit_code" ]; then exit_code=0; fi echo "$output" echo "Exit Code: $exit_code" @@ -59,8 +57,8 @@ jobs: echo "Error: NuGet API key is invalid or expired. Please contact Quantori support to renew the key. For more details, refer to the Quantori BDD Confluence page called 'Renew NuGet API key'." exit 1 elif [ $exit_code -ne 0 ]; then - echo "Error: dotnet nuget push failed. Check the logs for more details." - exit 1 + echo "Error: dotnet nuget push failed with exit code $exit_code. Check the logs for more details." + exit $exit_code else echo "Package successfully published to NuGet.org." fi