From c8eb5c2f0232f3c637914775776f847a16b0390d Mon Sep 17 00:00:00 2001 From: Hadrian Tang Date: Mon, 2 Feb 2026 10:23:00 +0800 Subject: [PATCH] Fix Nightly and Release workflows (#246) --- .github/workflows/Nightly.yml | 18 +++++++++++------- .github/workflows/Release.yml | 13 +++++++------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/Nightly.yml b/.github/workflows/Nightly.yml index 5056a561..2c94802c 100644 --- a/.github/workflows/Nightly.yml +++ b/.github/workflows/Nightly.yml @@ -25,11 +25,11 @@ jobs: ${{ steps.release_drafter.outputs.body }} run: | - # .NET Core MSBuild cannot parse , and ; correctly so we replace them with substitutions: https://github.com/dotnet/msbuild/issues/471#issuecomment-366268743 - # PowerShell string replacement + # .NET Core MSBuild cannot parse , and ; correctly so we replace them with MSBuild XML escapes: https://github.com/dotnet/msbuild/issues/471#issuecomment-366268743 $env:RELEASE_NOTES = $env:RELEASE_NOTES -replace ',','%2C' -replace ';','%3B' dotnet workload restore + dotnet build -c Release # CSharpMath.VectSharp isn't tested so we need to build everything here for NuGet packages instead of relying on auto-build by dotnet test. dotnet test --solution CSharpMath.sln -c Release -p:PackageReleaseNotes="$env:RELEASE_NOTES" -p:PackageVersion=${{ steps.release_drafter.outputs.tag_name || format('{0}-pr', github.event.number) }}-ci-${{ github.sha }} #### Awaiting coverlet.MTP at https://github.com/coverlet-coverage/coverlet/pull/1788 # # --collect:"XPlat Code Coverage" means collect test coverage with https://github.com/coverlet-coverage/coverlet @@ -72,12 +72,16 @@ jobs: if: always() with: name: NuGet packages - path: .nupkgs/ + path: .nupkgs/* + include-hidden-files: true # This GitHub Action interprets any file or folder starting with . as hidden and omitted by default. - name: Push CI artifacts to GitHub Packages registry if: github.ref == 'refs/heads/master' run: | + # On Windows, / will not be interpreted as the folder separator in this command and \ must be used here, unlike in Unix environments. # "dotnet nuget push" with "dotnet nuget add source" to GitHub Packages is unstable for project names with a dot: https://github.com/NuGet/Home/issues/9775#issuecomment-714509211 - # So we must specify api-key directly in "dotnet nuget push" instead of following the GitHub Packages documentation - # --no-symbols true to not let GitHub Releases interpret .snupkg as .nupkg - dotnet nuget push '.nupkgs\*.nupkg' --source 'https://nuget.pkg.github.com/verybadcat/index.json' --api-key ${{ github.token }} --skip-duplicate --no-symbols true - shell: pwsh \ No newline at end of file + # so we must specify -k (key) directly in "dotnet nuget push" instead of following the GitHub Packages documentation. + # By using *.* as the file path, this command will fail when .nupkgs folder contains any file that isn't a .nupkg or .snupkg file. + # --skip-duplicate enables re-running this workflow even if some packages from the same commit are already uploaded. + # --no-symbols omits uploading .snupkg files which is not supported by GitHub Packages: https://github.com/orgs/community/discussions/38678 + dotnet nuget push '.nupkgs\*.*' -s 'https://nuget.pkg.github.com/verybadcat/index.json' -k ${{ github.token }} --skip-duplicate --no-symbols + shell: pwsh diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index d65f9c25..cb13da3a 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -21,13 +21,11 @@ jobs: ${{ github.event.release.body }} run: | - # .NET Core MSBuild cannot parse , and ; correctly so we replace them with substitutions: https://github.com/dotnet/msbuild/issues/471#issuecomment-366268743 - # PowerShell string replacement + # .NET Core MSBuild cannot parse , and ; correctly so we replace them with MSBuild XML escapes: https://github.com/dotnet/msbuild/issues/471#issuecomment-366268743 $env:RELEASE_NOTES = $env:RELEASE_NOTES -replace ',','%2C' -replace ';','%3B' dotnet workload restore - # -r for restore - dotnet msbuild -r -p:Configuration=Release -p:PackageVersion="${{ github.event.release.tag_name }}" -p:PackageReleaseNotes="$env:RELEASE_NOTES" CSharpMath.sln + dotnet build -c Release -p:PackageVersion="${{ github.event.release.tag_name }}" -p:PackageReleaseNotes="$env:RELEASE_NOTES" CSharpMath.sln shell: pwsh - name: Upload to GitHub Releases uses: svenstaro/upload-release-action@v2 @@ -39,6 +37,9 @@ jobs: overwrite: true - name: Upload to NuGet run: | - # Use --skip-duplicate since we want re-runs of this workflow to succeed in case of network issues - dotnet nuget push '.nupkgs\*.nupkg' -k ${{ secrets.NUGET_API_KEY }} -s https://api.nuget.org/v3/index.json --skip-duplicate + # On Windows, / will not be interpreted as the folder separator in this command and \ must be used here, unlike in Unix environments. + # "dotnet nuget push" with "dotnet nuget add source" to GitHub Packages is unstable for project names with a dot: https://github.com/NuGet/Home/issues/9775#issuecomment-714509211 + # so we must specify -k (key) directly in "dotnet nuget push" instead of following the GitHub Packages documentation. + # --skip-duplicate enables re-running this workflow even if some packages from the same commit are already uploaded. + dotnet nuget push '.nupkgs\*.nupkg' -s 'https://api.nuget.org/v3/index.json' -k ${{ secrets.NUGET_API_KEY }} --skip-duplicate shell: pwsh