Automate semantic versioning + NuGet package publishing in CI #175
Replies: 2 comments 1 reply
-
|
There is an MTConnect.NET-Builder project under the build directory that is a CLI tool I have been using to create an installer for Windows, Docker Image, and Nuget packages. The only thing missing from the repo is the GitHub Token (for publishing a Release) and the Nuget API Token. There should be some kind of token needed for Docker but I usually login through the Docker CLI. These are set in a config file in that project. The version is read from the The installer uses InnoSetup to create an installer for Windows. If you can figure out how to run that in a GitHub Action/Workflow that would be awesome! That was my plan but I never got around to it. I typically run the builder CLI using the following commands:
I ended up creating a CLI in c# because I work better in that language. I was using Gulp but I was limited in what I could do in that. Feel free to edit/expand the existing CLI tool to run in an automated workflow or if you can come up with something better that would be great too! |
Beta Was this translation helpful? Give feedback.
-
|
@PatrickRitchie, while you decide, could you release a dev/rc/pre-release from the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
@PatrickRitchie, I wanted to put an idea on your radar now that the repository has a working CI surface again.
Two pieces of the release process currently look manual, and both are good candidates for automation:
Directory.Build.props(<VersionPrefix>6.9.0</VersionPrefix>, empty<VersionSuffix>). Every release means editing that line and remembering to keep it in step with what actually shipped..github/workflows/— the only workflow isbuild-test-coverage(dotnet.yml), which explicitly carries no package-write privileges. So the per-library NuGet packages are presumably packed and pushed to nuget.org by hand.I don't know what your current release ritual looks like (you may well have a local script that does this cleanly), so treat the below as a question as much as a proposal: would CI-driven versioning + publishing be useful, or do you prefer keeping releases a manual, deliberate act? If the latter, no problem — this is purely an offer.
What automation could look like
Versioning — replace the hand-bumped
VersionPrefixwith a deterministic, git-derived version so the version is always a function of the commit rather than a line someone remembered to edit. Two well-trodden options:v7.0.0→ packages version7.0.0); commits past the tag get a height-based pre-release suffix automatically. Zero config beyond a package reference; no build-time network.version.jsonat the root drives versions and gives you a stable, reproducible build version + git-height. Slightly more ceremony, slightly more control.Either removes the manual
Directory.Build.propsedit and makes "what version is this?" answerable fromgit describe.Publishing — a
release.ymlworkflow triggered on a published GitHub Release (or av*tag push) that:build-test-coveragejob),dotnet packs every shipped library inRelease,dotnet nuget pushes the resulting.nupkg/.snupkgto nuget.org.For the push credential there are two routes — a classic
NUGET_API_KEYrepository secret, or NuGet's trusted publishing (OIDC), which avoids a long-lived key entirely by exchanging the workflow's OIDC token for a short-lived nuget.org credential. I'd lean towards trusted publishing if you're open to it, since there's no secret to rotate or leak.Pros
Cons / things to weigh
environmentapproval keeps a human in the loop while still automating everything up to the push.Offer
If any of this is appealing, I'm happy to prototype it — e.g. a draft PR adding MinVer + a
release.ymlthat packs and pushes on tag, with the push gated behind a manual environment approval so you stay in control of the actual publish. If you'd rather keep releases manual, that's a perfectly good answer too; I just wanted to flag the option while CI is fresh on everyone's mind.Beta Was this translation helpful? Give feedback.
All reactions