-
Notifications
You must be signed in to change notification settings - Fork 0
Add GitHub Actions workflow for packaging and release automation #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis PR adds a comprehensive GitHub Actions workflow to automate .NET-based packaging and releases, configuring event triggers, environment setup, build/test execution, artifact packaging, and publishing to GitHub Packages and NuGet.org. Flow diagram for the packaging and release automation stepsflowchart TD
Checkout[Checkout Code]
SetupDotnet[Setup .NET Core SDK]
SetTag[Set TAG Variable]
SetVersion[Set VERSION Variable]
Restore[Restore .NET Packages]
Build[Build .NET Solution]
Test[Test .NET Solution]
UploadTestResults[Upload Test Results]
Pack[Pack .NET Solution]
PublishGitHub[Publish to GitHub Packages]
StoreNuget[Store NuGet Package]
PublishNuget[Publish to NuGet.org]
Checkout --> SetupDotnet --> SetTag --> SetVersion --> Restore --> Build --> Test --> UploadTestResults
UploadTestResults --> Pack
Pack --> PublishGitHub
Pack --> StoreNuget
Pack --> PublishNuget
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- Consider moving all packaging and publishing steps into a separate release job with a single
if: github.event_name == 'release'to avoid repeating complex conditional logic on each step. - The mixed use of
&&and||in your step-levelifexpressions can lead to unintended evaluations—either wrap them in parentheses or simplify the logic into clearer separate conditions. - Instead of echo-ing TAG and VERSION into the environment in multiple steps, you could define and pass them as job outputs for cleaner variable management between steps.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider moving all packaging and publishing steps into a separate release job with a single `if: github.event_name == 'release'` to avoid repeating complex conditional logic on each step.
- The mixed use of `&&` and `||` in your step-level `if` expressions can lead to unintended evaluations—either wrap them in parentheses or simplify the logic into clearer separate conditions.
- Instead of echo-ing TAG and VERSION into the environment in multiple steps, you could define and pass them as job outputs for cleaner variable management between steps.
## Individual Comments
### Comment 1
<location> `.github/workflows/package.yml:42` </location>
<code_context>
+
+ - name: Set TAG variable from tag
+ run: echo "TAG=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
+ if: ${{ github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name }}
+
+ - name: Set VERSION variable
</code_context>
<issue_to_address>
The conditional logic for release/tag detection may not behave as intended due to operator precedence.
Parentheses should be added to the conditional to ensure correct evaluation and avoid unintended behavior.
</issue_to_address>
### Comment 2
<location> `.github/workflows/package.yml:57` </location>
<code_context>
+ run: dotnet build --configuration Release --no-restore /p:Version=${VERSION}
+
+ - name: Test .NET Solution
+ run: dotnet test --configuration Release --no-build --filter="Category=UnitTest|Category=IntegrationTest" --logger "trx;LogFilePrefix=test-results"
+
+ - uses: actions/upload-artifact@v4
</code_context>
<issue_to_address>
Test filter uses '|' for categories, which may not work as expected in dotnet test.
The '|' operator may not work as an OR in dotnet test filters. Use a comma or run tests for each category separately to ensure both are included.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds a new GitHub Actions workflow (.github/workflows/package.yml) that builds, tests, derives VERSION from tags, and conditionally packs and publishes a .NET solution to GitHub Packages and NuGet.org on release events; uploads test TRX and nupkg artifacts. Changes
Sequence Diagram(s)sequenceDiagram
actor Dev as Developer/Release
participant GH as GitHub Events
participant WF as Package Workflow
participant Dotnet as .NET SDK
participant GHP as GitHub Packages
participant NuGet as NuGet.org
participant Art as Artifacts
Dev->>GH: PR / push to main / release.published / workflow_dispatch
GH->>WF: Trigger workflow
WF->>WF: Compute TAG and VERSION
WF->>Dotnet: dotnet restore
WF->>Dotnet: dotnet build (Version=VERSION)
WF->>Dotnet: dotnet test (collect TRX)
WF->>Art: Upload test TRX artifact
alt Release published
WF->>Dotnet: dotnet pack -> pack/
WF->>GHP: Publish nupkg (GITHUB_TOKEN)
WF->>NuGet: Publish nupkg (NUGET_ORG_KEY) [conditional]
WF->>Art: Upload nupkg artifact (7d retention)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Assessment against linked issues
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
🔭 Outside diff range comments (1)
.github/workflows/package.yml (1)
83-89: NuGet.org publish: fix source URL, gating, and env usage.
- The source should be the v3 index URL;
--source nugetmay not exist.ifreferencesenv.apikeydefined in the same step; that env is not reliably available to theifexpression. Checksecretsinstead.- Add
--skip-duplicatefor idempotency.Apply this diff:
- name: Publish .NET Solution to NuGet.org continue-on-error: true - env: - apikey: ${{ secrets.NUGET_ORG_KEY }} - run: dotnet nuget push pack/*.nupkg --api-key ${{ secrets.NUGET_ORG_KEY }} --source nuget - if: ${{ env.apikey != '' && github.event_name == 'release' && github.ref_type == 'tag' || github.event.release.tag_name }} + run: dotnet nuget push pack/*.nupkg --api-key ${{ secrets.NUGET_ORG_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate + if: ${{ secrets.NUGET_ORG_KEY != '' && github.event_name == 'release' && github.event.action == 'published' }}
🧹 Nitpick comments (2)
.github/workflows/package.yml (2)
30-36: Nit: name the step “Setup .NET SDK” and consider cache lock-file availability.
- Rename for accuracy (.NET Core SDK is legacy wording).
- If you don’t commit
packages.lock.json, the cache won’t be used. That’s fine, but intentional?Suggested rename:
- - name: Setup .NET Core SDK + - name: Setup .NET SDK
50-58: Optional: include code coverage or test result path broadening.If you want richer insights, add coverage collection or capture default TestResults files in addition to the custom prefix.
Example tweaks:
- Add coverage:
--collect:"XPlat Code Coverage"- Expand artifact path to cover default folder:
- path: "**/test-results*.trx" + path: | + **/test-results*.trx + **/TestResults/*.trx
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/package.yml(1 hunks)
🔇 Additional comments (1)
.github/workflows/package.yml (1)
26-29: Double-check checkout version (v5 may not exist).At the time of writing,
actions/checkout@v4is the stable major. Ifv5isn’t yet available, this will fail early.Apply this diff if needed:
- - uses: actions/checkout@v5 + - uses: actions/checkout@v4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🔭 Outside diff range comments (1)
.github/workflows/package.yml (1)
87-93: NuGet.org push: fix source and conditional check (likely skip due to step-level env in if)
- The step’s if references a step-scoped env var (env.apikey). Step-level env isn’t reliably available at if-evaluation time, so this can prevent the step from ever running. Prefer checking secrets directly in the if.
- Use the official NuGet v3 endpoint as the source; the friendly name "nuget" is not guaranteed to exist on runners.
Apply this diff:
- name: Publish .NET Solution to NuGet.org - continue-on-error: true - env: - apikey: ${{ secrets.NUGET_ORG_KEY }} - run: dotnet nuget push pack/*.nupkg --api-key ${{ secrets.NUGET_ORG_KEY }} --source nuget - if: ${{ env.apikey != '' && github.event_name == 'release' && github.event.action == 'published' }} + continue-on-error: true + run: dotnet nuget push pack/*.nupkg --api-key ${{ secrets.NUGET_ORG_KEY }} --source https://api.nuget.org/v3/index.json + if: ${{ secrets.NUGET_ORG_KEY != '' && github.event_name == 'release' && github.event.action == 'published' }}
🧹 Nitpick comments (2)
.github/workflows/package.yml (2)
63-65: Use always() for artifact upload conditionFunctionally equivalent and clearer than success() || failure().
- if: success() || failure() + if: always()
73-77: Consider failing the run on GitHub Packages publish errorsCurrently continue-on-error: true will mask real publishing failures. If you want releases to be green only when publishing succeeds, remove it or set to false.
- continue-on-error: true + continue-on-error: false
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
.github/workflows/package.yml(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-18T20:39:17.594Z
Learnt from: snovak7
PR: escendit/extensions-workflows#6
File: .github/workflows/package.yml:0-0
Timestamp: 2025-08-18T20:39:17.594Z
Learning: For the escendit/extensions-workflows repository, the user snovak7 indicated that --skip-duplicate flag is not needed for NuGet package publishing when following their established rules, suggesting they have processes in place to prevent duplicate package pushes.
Applied to files:
.github/workflows/package.yml
🔇 Additional comments (5)
.github/workflows/package.yml (5)
44-46: Release gating is correct and robust nowGood fix. The step is now safely scoped to published releases and won’t access undefined contexts on non-release events.
69-71: Packing with explicit PackageVersion is spot onPassing /p:PackageVersion=${VERSION} ensures the .nupkg version aligns with your release tag. Nice.
21-23: Minimal permissions set correctly for package publishingcontents: read and packages: write is the right balance for GitHub Packages pushes. Good hardening.
30-33: actions/checkout@v5 is up-to-dateConfirmed that the latest stable release of actions/checkout is v5.0.0 (Aug 11 2025), so using
actions/checkout@v5is correct and no changes are needed.
61-61: Confirm test filter aligns with your project’s test traits
I ran automated checks but didn’t detect any C# test framework references or attribute usages (e.g.[TestCategory],[Category],[Trait]) in your.csprojor.csfiles. Before merging, please manually verify which test framework(s) you’re using (MSTest, NUnit, xUnit, etc.) and ensure your--filterkeys match the trait names emitted by that adapter (e.g.TestCategoryfor MSTest,Category/Traitfor NUnit/xUnit).If you’re using MSTest attributes, you’d adjust the step to:
run: dotnet test --configuration Release --no-build \ --filter "TestCategory=UnitTest|TestCategory=IntegrationTest" \ --logger "trx;LogFilePrefix=test-results"Otherwise, keep
Category/Traitfor NUnit/xUnit.
Closes #5
Summary by Sourcery
Introduce a GitHub Actions workflow to automate .NET build, test, packaging, and release steps on pull requests, pushes, and release tags
CI:
Summary by CodeRabbit