-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (57 loc) · 1.72 KB
/
release-publish.yml
File metadata and controls
68 lines (57 loc) · 1.72 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
name: Publish Release
on:
release:
types: [published]
permissions:
contents: read
packages: write
jobs:
publish-nuget:
name: Publish to NuGet.org
runs-on: ubuntu-latest
steps:
- name: Download release assets
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release download "${{ github.event.release.tag_name }}" \
--pattern "*.nupkg" \
--dir ./artifacts \
--repo "${{ github.repository }}"
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
11.0.x
- name: Verify packages
run: |
echo "Packages to be published:"
ls -la ./artifacts/*.nupkg
# Verify package count
PACKAGE_COUNT=$(ls ./artifacts/*.nupkg | wc -l)
if [ "$PACKAGE_COUNT" -eq 0 ]; then
echo "Error: No packages found!"
exit 1
fi
echo "Found $PACKAGE_COUNT package(s) to publish"
- name: Publish to NuGet.org
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: |
for package in ./artifacts/*.nupkg; do
echo "Publishing $package to NuGet.org..."
dotnet nuget push "$package" \
--api-key "$NUGET_API_KEY" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
done
echo "All packages published successfully!"
- name: Upload published packages as artifacts
uses: actions/upload-artifact@v6
with:
name: published-nuget-packages
path: ./artifacts/*.nupkg
retention-days: 90