Skip to content

Commit ecd814d

Browse files
authored
Merge pull request #1825 from shimat/fix_ubuntu_packages_beta
Fix NupkgBetaRemover for Ubuntu packages and add approval gate to publish workflow
2 parents 0363b4a + d1cb8d8 commit ecd814d

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

.github/workflows/publish_nuget.yml

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55

66
jobs:
7-
Publish:
7+
Prepare:
88
runs-on: ubuntu-24.04
99

1010
steps:
@@ -104,6 +104,54 @@ jobs:
104104
dotnet run --project tool/OpenCvSharp.NupkgBetaRemover --configuration Release -- "$f"
105105
done
106106
107+
- name: Verify no beta versions remain
108+
run: |
109+
if find . -maxdepth 1 -name "*-beta*" -type f | grep -q .; then
110+
echo "ERROR: beta packages still exist after rename"
111+
find . -maxdepth 1 -name "*-beta*" -type f
112+
exit 1
113+
fi
114+
115+
- name: List packages to publish
116+
run: |
117+
echo "=== Packages ready for publishing ==="
118+
ls -lh *.nupkg *.snupkg 2>/dev/null || true
119+
120+
echo "## NuGet Packages to Publish" >> $GITHUB_STEP_SUMMARY
121+
echo "" >> $GITHUB_STEP_SUMMARY
122+
echo "| Package | Size |" >> $GITHUB_STEP_SUMMARY
123+
echo "|---------|------|" >> $GITHUB_STEP_SUMMARY
124+
for f in *.nupkg; do
125+
[ -f "$f" ] || continue
126+
size=$(du -h "$f" | cut -f1)
127+
echo "| \`${f}\` | ${size} |" >> $GITHUB_STEP_SUMMARY
128+
done
129+
echo "" >> $GITHUB_STEP_SUMMARY
130+
echo "**Total:** $(find . -maxdepth 1 -name '*.nupkg' | wc -l) nupkg, $(find . -maxdepth 1 -name '*.snupkg' | wc -l) snupkg" >> $GITHUB_STEP_SUMMARY
131+
132+
- name: Upload release packages
133+
uses: actions/upload-artifact@v6
134+
with:
135+
name: release-packages
136+
path: |
137+
*.nupkg
138+
*.snupkg
139+
retention-days: 7
140+
141+
Publish:
142+
needs: Prepare
143+
runs-on: ubuntu-24.04
144+
environment: nuget-production
145+
146+
steps:
147+
- name: Download release packages
148+
uses: actions/download-artifact@v6
149+
with:
150+
name: release-packages
151+
152+
- name: List packages
153+
run: ls -lh *.nupkg *.snupkg 2>/dev/null || true
154+
107155
- name: Push to nuget.org
108156
run: |
109157
dotnet nuget push "*.nupkg" -k ${{secrets.NUGET_ORG_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate

tool/OpenCvSharp.NupkgBetaRemover/Program.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,9 @@
3434
nuspecContent = nuspecContentStreamReader.ReadToEnd();
3535
}
3636

37-
if (nupkgFile.Contains("ubuntu"))
37+
nuspecContent = Regex.Replace(nuspecContent, @"-beta-?\d*</version>", "</version>");
38+
if (!nupkgFile.Contains("ubuntu"))
3839
{
39-
nuspecContent = Regex.Replace(nuspecContent, @"-\d+</version>", $".{date:yyyyMMdd}</version>");
40-
}
41-
else
42-
{
43-
nuspecContent = Regex.Replace(nuspecContent, @"-beta-?\d*</version>", "</version>");
4440
nuspecContent = Regex.Replace(nuspecContent, @"(?<=<dependency.*version="")(?<version>\d{1,2}\.\d{1,2}\.\d{1,2}\.\d{8})(?<betaVersion>-beta-?\d*)",
4541
match => match.Groups["version"].Value);
4642
}

0 commit comments

Comments
 (0)