diff --git a/.github/workflows/publish_nuget.yml b/.github/workflows/publish_nuget.yml index 53c9325f70..7170c52b5e 100644 --- a/.github/workflows/publish_nuget.yml +++ b/.github/workflows/publish_nuget.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: jobs: - Publish: + Prepare: runs-on: ubuntu-24.04 steps: @@ -104,6 +104,54 @@ jobs: dotnet run --project tool/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=$(du -h "$f" | cut -f1) + 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: | dotnet nuget push "*.nupkg" -k ${{secrets.NUGET_ORG_API_KEY}} -s https://api.nuget.org/v3/index.json --skip-duplicate diff --git a/tool/OpenCvSharp.NupkgBetaRemover/Program.cs b/tool/OpenCvSharp.NupkgBetaRemover/Program.cs index f35306e064..1e4e982bdd 100644 --- a/tool/OpenCvSharp.NupkgBetaRemover/Program.cs +++ b/tool/OpenCvSharp.NupkgBetaRemover/Program.cs @@ -34,13 +34,9 @@ nuspecContent = nuspecContentStreamReader.ReadToEnd(); } - if (nupkgFile.Contains("ubuntu")) + nuspecContent = Regex.Replace(nuspecContent, @"-beta-?\d*", ""); + if (!nupkgFile.Contains("ubuntu")) { - nuspecContent = Regex.Replace(nuspecContent, @"-\d+", $".{date:yyyyMMdd}"); - } - else - { - nuspecContent = Regex.Replace(nuspecContent, @"-beta-?\d*", ""); nuspecContent = Regex.Replace(nuspecContent, @"(?<=\d{1,2}\.\d{1,2}\.\d{1,2}\.\d{8})(?-beta-?\d*)", match => match.Groups["version"].Value); }