-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
172 lines (144 loc) · 5.44 KB
/
Copy pathpublish_nuget.yml
File metadata and controls
172 lines (144 loc) · 5.44 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Publish NuGet
on:
workflow_dispatch:
jobs:
Prepare:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v6
- name: Download windows artifact
uses: dawidd6/action-download-artifact@v14
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: windows.yml
name: packages_windows
branch: ${{ github.ref_name }}
- name: Download ubuntu arm artifact
uses: dawidd6/action-download-artifact@v14
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: linux-arm.yml
name: artifacts_linux_arm
branch: ${{ github.ref_name }}
#- name: Download macos artifact
# uses: dawidd6/action-download-artifact@v14
# with:
# github_token: ${{secrets.GITHUB_TOKEN}}
# workflow: macos10.yml
# name: artifacts_macos_10
# branch: ${{ github.ref_name }}
- name: Download wasm artifact
uses: dawidd6/action-download-artifact@v14
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: wasm.yml
name: artifacts_wasm
branch: ${{ github.ref_name }}
- name: Download manylinux artifact
uses: dawidd6/action-download-artifact@v14
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: manylinux.yml
name: nuget-packages-manylinux
branch: ${{ github.ref_name }}
- run: |
ls -l
- name: Validate windows slim packages exist
run: |
set -euo pipefail
runtime_count=$(find "$PWD" -type f -name "OpenCvSharp4.runtime.win.slim*.nupkg" | wc -l)
windows_slim_count=$(find "$PWD" -type f -name "OpenCvSharp4.Windows.Slim*.nupkg" | wc -l)
if [ "$runtime_count" -eq 0 ] || [ "$windows_slim_count" -eq 0 ]; then
echo "Expected Windows slim NuGet packages were not found in downloaded artifacts."
echo "runtime.win.slim count: $runtime_count"
echo "Windows.Slim count: $windows_slim_count"
echo "Detected .nupkg files:"
find "$PWD" -maxdepth 4 -type f -name "*.nupkg" -print
exit 1
fi
- name: Install .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 8.0.x
- name: Rename
run: |
for f in $(find $PWD -maxdepth 1 -regex ".+\.s?nupkg"); do
dotnet run --project src/tools/OpenCvSharp.NupkgBetaRemover --configuration Release -- "$f"
done
- name: Verify no beta versions remain
run: |
if find . -maxdepth 1 -name "*-beta*" -type f | grep -q .; then
echo "ERROR: beta packages still exist after rename"
find . -maxdepth 1 -name "*-beta*" -type f
exit 1
fi
- name: List packages to publish
run: |
echo "=== Packages ready for publishing ==="
ls -lh *.nupkg *.snupkg 2>/dev/null || true
echo "## NuGet Packages to Publish" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Package | Size |" >> $GITHUB_STEP_SUMMARY
echo "|---------|------|" >> $GITHUB_STEP_SUMMARY
for f in *.nupkg; do
[ -f "$f" ] || continue
size=$(numfmt --to=iec --suffix=B --format="%.2f" "$(stat -c %s "$f")")
echo "| \`${f}\` | ${size} |" >> $GITHUB_STEP_SUMMARY
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Total:** $(find . -maxdepth 1 -name '*.nupkg' | wc -l) nupkg, $(find . -maxdepth 1 -name '*.snupkg' | wc -l) snupkg" >> $GITHUB_STEP_SUMMARY
- name: Upload release packages
uses: actions/upload-artifact@v6
with:
name: release-packages
path: |
*.nupkg
*.snupkg
retention-days: 7
Publish:
needs: Prepare
runs-on: ubuntu-24.04
environment: nuget-production
steps:
- name: Download release packages
uses: actions/download-artifact@v6
with:
name: release-packages
- name: List packages
run: ls -lh *.nupkg *.snupkg 2>/dev/null || true
- name: Push to nuget.org
run: |
set -euo pipefail
pushed=0
failed=0
push_package() {
local file="$1"
local name
name=$(basename "$file")
local output
if output=$(dotnet nuget push "$file" \
-k ${{secrets.NUGET_ORG_API_KEY}} \
-s https://api.nuget.org/v3/index.json 2>&1); then
echo "PUSHED: $name"
echo "| \`$name\` | ✅ Pushed |" >> $GITHUB_STEP_SUMMARY
pushed=$((pushed + 1))
else
echo "FAILED: $name"
echo "$output"
echo "| \`$name\` | ❌ Failed |" >> $GITHUB_STEP_SUMMARY
failed=$((failed + 1))
fi
}
echo "## Push Results" >> $GITHUB_STEP_SUMMARY
echo "| Package | Status |" >> $GITHUB_STEP_SUMMARY
echo "|---------|--------|" >> $GITHUB_STEP_SUMMARY
for f in *.nupkg *.snupkg; do
[ -f "$f" ] || continue
push_package "$f"
done
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Pushed:** $pushed **Failed:** $failed" >> $GITHUB_STEP_SUMMARY
if [ "$failed" -gt 0 ]; then
echo "ERROR: $failed package(s) failed to push."
exit 1
fi