Add GitHub Actions workflow for automated NuGet releases with multi-platform builds#1095
Conversation
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
|
@copilot move any bash code to c# in the build project then call the step from the action |
- Added determine-version, update-version, push-to-nuget, and create-release build targets - All version detection and publishing logic now in build/Program.cs - Workflow calls C# build targets instead of bash scripts - Updated documentation to reflect C# implementation Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Done! I've moved all the bash logic to C# in the build project. The following build targets were added to
The workflow now simply calls these C# targets instead of running bash scripts. All version detection, file manipulation, and publishing logic is now in C#. Commit: 9238cf1 |
- Replaced bash-specific Process execution with SimpleExec's ReadAsync - Fixed git command execution to work on Windows and Linux - Added comment about API key handling in push-to-nuget target - Removed unused System.Diagnostics import Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements automated NuGet package publishing for the SharpCompress project with intelligent version detection and prerelease support. The workflow triggers on pushes to the release branch, automatically determining whether to publish stable or prerelease packages based on git tags.
Key changes include:
- Version detection logic: C# implementation that distinguishes between tagged releases (stable) and untagged commits (prerelease with format
{LAST_TAG}-preview.{COMMIT_COUNT}+{SHA}) - Build targets: Four new C# build targets (
determine-version,update-version,push-to-nuget,create-release) that handle all version detection, file updates, and publishing - GitHub Actions workflow: Orchestrates the build, test, and publish pipeline using the new C# targets with proper secret management
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/nuget-release.yml |
New workflow that automates NuGet publishing on the release branch with version detection, build/test, and conditional GitHub release creation |
build/Program.cs |
Adds 4 new build targets for version detection, project file updates, NuGet publishing, and GitHub release creation with git-based version logic |
.github/workflows/NUGET_RELEASE.md |
Comprehensive documentation explaining workflow behavior, setup requirements, usage examples, and troubleshooting guidance |
.github/workflows/TESTING.md |
Testing procedures and verification steps for both prerelease and stable release scenarios |
.gitignore |
Adds artifacts/ directory to ignore list for build output |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@copilot change the untagged versioning to only use commit count and not the short sha |
- Changed prerelease version format from {LAST_TAG}-preview.{COMMIT_COUNT}+{SHA} to {LAST_TAG}-preview.{COMMIT_COUNT}
- Updated documentation in NUGET_RELEASE.md and TESTING.md to reflect the change
- Removed git rev-parse call for short SHA since it's no longer needed
Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
Done! Changed the prerelease version format from Updated:
Example prerelease version now: Commit: 7f71f76 |
- Changed example from 0.42.2-test to 0.42.2 to match regex pattern - Added note that tags must be pure semantic versions (MAJOR.MINOR.PATCH) - Addresses bot review feedback about documentation inconsistency Co-authored-by: adamhathcock <527620+adamhathcock@users.noreply.github.com>
|
@copilot instead of using last tag, use next tag which is a minor release. Change preview to beta |
Implements automated NuGet publishing for the
masterandreleasebranches with automatic version detection and prerelease support. The workflow runs on both Windows and Ubuntu for comprehensive testing, with NuGet publishing only on Windows. All version detection, file updates, and publishing logic is implemented in C# in the build project. GitHub releases are created manually.Workflow Behavior
Version Detection (C# implementation):
{NEXT_MINOR_VERSION}-beta.{COMMIT_COUNT}Pipeline:
masterandreleasebranch pushesMAJOR.MINOR.PATCH)SharpCompress.csprojusing C# build targetNUGET_API_KEYsecret (Windows only)--skip-duplicatefor idempotencyImplementation
All logic is implemented in C# as build targets in
build/Program.cs:determine-version- Detects version from git tags, increments minor version for prereleases, and outputs to GitHub Actionsupdate-version- Updates VersionPrefix, AssemblyVersion, and FileVersion in project filepush-to-nuget- Publishes packages to NuGet.orgThe workflow calls these C# targets instead of using bash scripts. Cross-platform compatible (Windows/Linux). Matrix builds ensure cross-platform compatibility while keeping NuGet publishing exclusive to Windows to prevent duplicate publishes.
Example Usage
Setup Required
Add
NUGET_API_KEYsecret to repository settings with NuGet.org API key.Files Added/Modified
.github/workflows/nuget-release.yml- Multi-platform workflow with matrix strategy calling C# build targets, triggers on branch and tag pushes.github/workflows/NUGET_RELEASE.md- Setup and usage documentation with build targets info.github/workflows/TESTING.md- Testing proceduresbuild/Program.cs- Added 3 new build targets with version detection and publishing logic.gitignore- Addedartifacts/directoryOriginal prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.