Fix GitHub Actions NuGet publish: glob expansion, version number, PR pre-release versioning, and deterministic builds - #234
Conversation
Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
|
@copilot rename build to build-and-test.yml |
Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Done in c178313. |
|
@copilot the package isn't determenistic anymore and also missing debug symbols (snupkg needed for that). Also sourcelink is broken We need also something like ContinuousIntegrationBuild=true, see https://github.com/clairernovotny/DeterministicBuilds |
Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Done in 51ceed0. Changes to
|
|
@copilot I think |
…ongside nupkg) Co-authored-by: 304NotModified <5808377+304NotModified@users.noreply.github.com>
Yes — |
|



Two bugs prevented NuGet publishing from working after migrating to GitHub Actions:
dotnet nuget push artifacts/*.nupkgfailed on Windows because PowerShell doesn't expand globs for executables, and packages were always versioned1.0.0because no<Version>was set in the csproj (Azure Pipelines injected it via-p:Version=).NLog.MailKit.csproj<Version>with<VersionPrefix>6.0.5</VersionPrefix>— required so--version-suffixin the workflow actually appends (setting<Version>directly silently ignores the suffix flag)<FileVersion>$(VersionPrefix).0</FileVersion>— without this the SDK defaultsFileVersiontoAssemblyVersion(6.0.0.0); now6.0.5.0<PublishRepositoryUrl>true</PublishRepositoryUrl>and<EmbedUntrackedSources>true</EmbedUntrackedSources>— enables SourceLink to map PDBs back to source<IncludeSymbols>true</IncludeSymbols>and<SymbolPackageFormat>snupkg</SymbolPackageFormat>— produces a.snupkgdebug symbols package alongside the.nupkg<ContinuousIntegrationBuild Condition="'$(GITHUB_ACTIONS)' == 'true'">true</ContinuousIntegrationBuild>— setsDeterministic=trueautomatically in CI for reproducible builds (see DeterministicBuilds).github/workflows/build-and-test.yml(renamed frombuild.yml)windows-latestandubuntu-latest.github/workflows/nuget.yml(new)shell: bashon the push step so bash expandsartifacts/*.nupkgmasterproduces no suffix (clean release); any other branch/PR cleans the ref name to alphanumeric+hyphens and passes it as--version-suffix, e.g.NLog.MailKit.6.0.5-pull-42-head.nupkgartifacts/*pkgto capture both.nupkgand.snupkgdotnet nuget push artifacts/*.nupkg—dotnet nuget pushautomatically pushes the matching.snupkgalongside each.nupkgid-token: writepermission scoped only to this workflow where it is needed✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.