[PR #1095] [MERGED] Add GitHub Actions workflow for automated NuGet releases with multi-platform builds #1522

Open
opened 2026-01-29 22:20:57 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/adamhathcock/sharpcompress/pull/1095
Author: @Copilot
Created: 1/1/2026
Status: Merged
Merged: 1/3/2026
Merged by: @adamhathcock

Base: masterHead: copilot/add-github-action-nuget-release


📝 Commits (10+)

  • 24d651d Initial plan
  • 9001e28 Add GitHub Actions workflow for NuGet releases
  • 2feabed Remove redundant NUGET_API_KEY environment variable
  • 2f874ac Add comment clarifying sort -V usage
  • 9238cf1 Move bash logic to C# build targets
  • bcf7137 Fix code review issues: use cross-platform git execution
  • caa82a6 Remove duplicate entry in documentation
  • 7f71f76 Remove SHA from prerelease version, use only commit count
  • d5913e8 Fix TESTING.md to use valid version tag format
  • 9d6cd93 Use next minor version with beta suffix for prereleases

📊 Changes

5 files changed (+497 additions, -0 deletions)

View changed files

.github/workflows/NUGET_RELEASE.md (+155 -0)
.github/workflows/TESTING.md (+120 -0)
.github/workflows/nuget-release.yml (+57 -0)
📝 .gitignore (+1 -0)
📝 build/Program.cs (+164 -0)

📄 Description

Implements automated NuGet publishing for the master and release branches 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):

  • Tagged commits → stable release (version from tag)
  • Untagged commits → prerelease with next minor version and format {NEXT_MINOR_VERSION}-beta.{COMMIT_COUNT}

Pipeline:

  • Triggers on both master and release branch pushes
  • Triggers on version tag pushes (format: MAJOR.MINOR.PATCH)
  • Builds and tests on Windows and Ubuntu in parallel (matrix strategy)
  • Updates version in SharpCompress.csproj using C# build target
  • Pushes to NuGet.org using NUGET_API_KEY secret (Windows only)
  • Uses --skip-duplicate for idempotency

Implementation

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 Actions
  • update-version - Updates VersionPrefix, AssemblyVersion, and FileVersion in project file
  • push-to-nuget - Publishes packages to NuGet.org

The 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

# Stable release - Method 1: Push tag directly
git tag 0.43.0
git push origin 0.43.0
# → Workflow triggers, builds on Windows and Ubuntu, publishes SharpCompress 0.43.0 (Windows only)

# Stable release - Method 2: Push to branch then tag
git checkout master  # or release
git push origin master
git tag 0.43.0
git push origin 0.43.0
# → Workflow triggers on both branch push and tag push

# Prerelease (if last tag is 0.42.x)
git checkout master  # or release
git push origin master  # or release
# → Builds on Windows and Ubuntu, publishes SharpCompress 0.43.0-beta.456 (Windows only)

Setup Required

Add NUGET_API_KEY secret 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 procedures
  • build/Program.cs - Added 3 new build targets with version detection and publishing logic
  • .gitignore - Added artifacts/ directory
Original prompt

This section details on the original issue you should resolve

<issue_title>GitHub action for nuget releases</issue_title>
<issue_description>Create a GitHub action that builds like things currently do but also pushes a build to nuget.

This is on the release branch. If the release isn't tagged then it's a prerelease version based on the last tag</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/adamhathcock/sharpcompress/pull/1095 **Author:** [@Copilot](https://github.com/apps/copilot-swe-agent) **Created:** 1/1/2026 **Status:** ✅ Merged **Merged:** 1/3/2026 **Merged by:** [@adamhathcock](https://github.com/adamhathcock) **Base:** `master` ← **Head:** `copilot/add-github-action-nuget-release` --- ### 📝 Commits (10+) - [`24d651d`](https://github.com/adamhathcock/sharpcompress/commit/24d651d7aef329681e666eeb110cfae997fc24a5) Initial plan - [`9001e28`](https://github.com/adamhathcock/sharpcompress/commit/9001e28b363c2e2a7db117cda3de11fafae1f741) Add GitHub Actions workflow for NuGet releases - [`2feabed`](https://github.com/adamhathcock/sharpcompress/commit/2feabed29782f89e26418770205135d2b3acf78c) Remove redundant NUGET_API_KEY environment variable - [`2f874ac`](https://github.com/adamhathcock/sharpcompress/commit/2f874ace51aafea39dd78bf24e2bbe7cd1bba35e) Add comment clarifying sort -V usage - [`9238cf1`](https://github.com/adamhathcock/sharpcompress/commit/9238cf112872a7529d17b04359375ed6289edde6) Move bash logic to C# build targets - [`bcf7137`](https://github.com/adamhathcock/sharpcompress/commit/bcf71370738d5489621a92143b5e225712bd59cb) Fix code review issues: use cross-platform git execution - [`caa82a6`](https://github.com/adamhathcock/sharpcompress/commit/caa82a614631a3b619fb74973bcb39caaefd0804) Remove duplicate entry in documentation - [`7f71f76`](https://github.com/adamhathcock/sharpcompress/commit/7f71f76f6e36d5bdb0c978692a17ce9217a71025) Remove SHA from prerelease version, use only commit count - [`d5913e8`](https://github.com/adamhathcock/sharpcompress/commit/d5913e8371eef6f4ff3212ffba64310db02d9514) Fix TESTING.md to use valid version tag format - [`9d6cd93`](https://github.com/adamhathcock/sharpcompress/commit/9d6cd930eabfc2c1ae2db65db963bf8e54bbe5f5) Use next minor version with beta suffix for prereleases ### 📊 Changes **5 files changed** (+497 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `.github/workflows/NUGET_RELEASE.md` (+155 -0) ➕ `.github/workflows/TESTING.md` (+120 -0) ➕ `.github/workflows/nuget-release.yml` (+57 -0) 📝 `.gitignore` (+1 -0) 📝 `build/Program.cs` (+164 -0) </details> ### 📄 Description Implements automated NuGet publishing for the `master` and `release` branches 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):** - Tagged commits → stable release (version from tag) - Untagged commits → prerelease with next minor version and format `{NEXT_MINOR_VERSION}-beta.{COMMIT_COUNT}` **Pipeline:** - Triggers on both `master` and `release` branch pushes - Triggers on version tag pushes (format: `MAJOR.MINOR.PATCH`) - Builds and tests on Windows and Ubuntu in parallel (matrix strategy) - Updates version in `SharpCompress.csproj` using C# build target - Pushes to NuGet.org using `NUGET_API_KEY` secret (Windows only) - Uses `--skip-duplicate` for idempotency ## Implementation 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 Actions - `update-version` - Updates VersionPrefix, AssemblyVersion, and FileVersion in project file - `push-to-nuget` - Publishes packages to NuGet.org The 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 ```bash # Stable release - Method 1: Push tag directly git tag 0.43.0 git push origin 0.43.0 # → Workflow triggers, builds on Windows and Ubuntu, publishes SharpCompress 0.43.0 (Windows only) # Stable release - Method 2: Push to branch then tag git checkout master # or release git push origin master git tag 0.43.0 git push origin 0.43.0 # → Workflow triggers on both branch push and tag push # Prerelease (if last tag is 0.42.x) git checkout master # or release git push origin master # or release # → Builds on Windows and Ubuntu, publishes SharpCompress 0.43.0-beta.456 (Windows only) ``` ## Setup Required Add `NUGET_API_KEY` secret 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 procedures - `build/Program.cs` - Added 3 new build targets with version detection and publishing logic - `.gitignore` - Added `artifacts/` directory <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>GitHub action for nuget releases</issue_title> > <issue_description>Create a GitHub action that builds like things currently do but also pushes a build to nuget. > > This is on the release branch. If the release isn't tagged then it's a prerelease version based on the last tag</issue_description> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes adamhathcock/sharpcompress#1094 <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 22:20:57 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#1522