Skip to content

Commit a80e778

Browse files
committed
improves CI
1 parent b656477 commit a80e778

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

.github/workflows/publish-package.yml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,19 @@ jobs:
5252
- name: Restore tests
5353
run: dotnet restore test/Soenneker.Utils.Strings.DiceCoefficient.Tests/Soenneker.Utils.Strings.DiceCoefficient.Tests.csproj --verbosity minimal
5454

55-
- name: Build
55+
- name: Build tests
5656
run: dotnet build test/Soenneker.Utils.Strings.DiceCoefficient.Tests/Soenneker.Utils.Strings.DiceCoefficient.Tests.csproj --configuration Release --no-restore --verbosity minimal
5757

5858
- name: Test
5959
run: dotnet test test/Soenneker.Utils.Strings.DiceCoefficient.Tests/Soenneker.Utils.Strings.DiceCoefficient.Tests.csproj --configuration Release --no-build --no-restore --verbosity normal
6060

61+
62+
- name: Restore library
63+
run: dotnet restore src/Soenneker.Utils.Strings.DiceCoefficient/Soenneker.Utils.Strings.DiceCoefficient.csproj --verbosity minimal
64+
65+
- name: Build library
66+
run: dotnet build src/Soenneker.Utils.Strings.DiceCoefficient/Soenneker.Utils.Strings.DiceCoefficient.csproj --configuration Release --no-restore --verbosity minimal
67+
6168
- name: Pack
6269
shell: bash
6370
run: |
@@ -68,22 +75,37 @@ jobs:
6875
--no-restore \
6976
--output ./artifacts
7077
71-
- name: Publish to NuGet with retry
78+
- name: Publish to NuGet
7279
shell: bash
7380
run: |
74-
for i in 1 2 3; do
81+
set -euo pipefail
82+
83+
for i in 1 2; do
84+
output_file="$(mktemp)"
85+
86+
set +e
7587
dotnet nuget push ./artifacts/*.nupkg \
7688
--source "https://api.nuget.org/v3/index.json" \
7789
--api-key "${{ secrets.NUGET__TOKEN }}" \
78-
--skip-duplicate && break
90+
--skip-duplicate 2>&1 | tee "$output_file"
91+
exit_code=${PIPESTATUS[0]}
92+
set -e
7993
80-
if [ "$i" -lt 3 ]; then
81-
echo "NuGet publish failed, retrying in 10 seconds..."
82-
sleep 10
83-
else
84-
echo "NuGet publish failed after 3 attempts."
94+
if [ $exit_code -eq 0 ]; then
95+
exit 0
96+
fi
97+
98+
if grep -qiE 'Quota Exceeded|retry after:' "$output_file"; then
99+
echo "NuGet throttled this publish. Not retrying inside the same job."
85100
exit 1
86101
fi
102+
103+
if [ "$i" -lt 2 ]; then
104+
echo "Transient failure, retrying once in 15 seconds..."
105+
sleep 15
106+
else
107+
exit $exit_code
108+
fi
87109
done
88110
89111
- name: Publish to GitHub Packages

0 commit comments

Comments
 (0)