-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (65 loc) · 2.21 KB
/
publish-package.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: publish-package
on:
push:
branches:
- main
tags:
- v*
env:
"PipelineEnvironment": true
jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setting up build version
run: |
version=$(($GITHUB_RUN_NUMBER))
echo "BUILD_VERSION=2.1.$version" >> ${GITHUB_ENV}
- name: Setup .NET Core 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Install dependencies with retry
run: |
retries=5
base_wait_time=15
exponent=2
for i in $(seq 1 $retries); do
if dotnet restore; then
break
fi
if [ $i -lt $retries ]; then
wait_time=$(awk "BEGIN {print int($base_wait_time * ($exponent ^ ($i - 1)))}")
echo "dotnet restore failed, retrying in $wait_time seconds..."
sleep $wait_time
else
echo "dotnet restore failed after $retries retries."
exit 1
fi
done
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test test/Soenneker.Instantly.Client.Tests/Soenneker.Instantly.Client.Tests.csproj --no-restore --verbosity normal
- name: Pack
run: dotnet pack --no-build --configuration Release --output .
- name: Publish to NuGet with retry
run: |
nupkg_files=$(find . -name "*.nupkg")
retries=5
base_wait_time=20
exponent=3.5
for i in $(seq 1 $retries); do
if dotnet nuget push $nupkg_files --source 'https://api.nuget.org/v3/index.json' --api-key ${{secrets.NUGET_TOKEN}} --skip-duplicate; then
break
fi
if [ $i -lt $retries ]; then
wait_time=$(awk "BEGIN {print int($base_wait_time * ($exponent ^ ($i - 1)))}")
echo "NuGet publish failed, retrying in $wait_time seconds..."
sleep $wait_time
else
echo "NuGet publish failed after $retries retries."
exit 1
fi
done