-
-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (102 loc) · 3.74 KB
/
Copy pathpublish-package.yml
File metadata and controls
126 lines (102 loc) · 3.74 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: publish-package
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- main
paths-ignore:
- 'test/**'
workflow_dispatch:
permissions:
contents: write
packages: write
env:
PipelineEnvironment: true
NUGET_XMLDOC_MODE: skip
jobs:
publish-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- name: Setting up build version
shell: bash
run: |
echo "BUILD_VERSION=4.0.${GITHUB_RUN_NUMBER}" >> "$GITHUB_ENV"
- name: Get release notes from latest commit
shell: bash
run: |
notes="$(git log -1 --pretty=%B | sed '/^Co-authored-by:/d')"
{
echo "PACKAGE_RELEASE_NOTES<<EOF"
printf '%s\n' "$notes"
echo "EOF"
} >> "$GITHUB_ENV"
- name: Setup .NET
uses: actions/setup-dotnet@v6
with:
dotnet-version: 10.0.x
- name: Restore tests
run: dotnet restore test/Soenneker.Utils.RateLimiting.Executor.Tests/Soenneker.Utils.RateLimiting.Executor.Tests.csproj --verbosity minimal
- name: Build tests
run: dotnet build test/Soenneker.Utils.RateLimiting.Executor.Tests/Soenneker.Utils.RateLimiting.Executor.Tests.csproj --configuration Release --no-restore --verbosity minimal
- name: Test
run: dotnet test --project test/Soenneker.Utils.RateLimiting.Executor.Tests/Soenneker.Utils.RateLimiting.Executor.Tests.csproj --configuration Release --no-build --no-restore --verbosity normal
- name: Restore library
run: dotnet restore src/Soenneker.Utils.RateLimiting.Executor/Soenneker.Utils.RateLimiting.Executor.csproj --verbosity minimal
- name: Build library
run: dotnet build src/Soenneker.Utils.RateLimiting.Executor/Soenneker.Utils.RateLimiting.Executor.csproj --configuration Release --no-restore --verbosity minimal
- name: Pack
shell: bash
run: |
mkdir -p artifacts
dotnet pack src/Soenneker.Utils.RateLimiting.Executor/Soenneker.Utils.RateLimiting.Executor.csproj \
--configuration Release \
--no-build \
--no-restore \
--output ./artifacts
- name: Publish to NuGet
shell: bash
run: |
set -euo pipefail
for i in 1 2; do
output_file="$(mktemp)"
set +e
dotnet nuget push ./artifacts/*.nupkg \
--source "https://api.nuget.org/v3/index.json" \
--api-key "${{ secrets.NUGET__TOKEN }}" \
--skip-duplicate 2>&1 | tee "$output_file"
exit_code=${PIPESTATUS[0]}
set -e
if [ $exit_code -eq 0 ]; then
exit 0
fi
if grep -qiE 'Quota Exceeded|retry after:' "$output_file"; then
echo "NuGet throttled this publish. Not retrying inside the same job."
exit 1
fi
if [ "$i" -lt 2 ]; then
echo "Transient failure, retrying once in 15 seconds..."
sleep 15
else
exit $exit_code
fi
done
- name: Publish to GitHub Packages
shell: bash
run: |
dotnet nuget push ./artifacts/*.nupkg \
--source "https://nuget.pkg.github.com/soenneker/index.json" \
--api-key "${{ secrets.GH__TOKEN }}" \
--skip-duplicate
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GH__TOKEN }}
shell: bash
run: |
gh release create "v$BUILD_VERSION" \
--title "v$BUILD_VERSION" \
--notes "${{ env.PACKAGE_RELEASE_NOTES }}"