Fix release workflow to trigger on tag push and use tag as version#8
Conversation
- Trigger on 'v*' tag push instead of manual workflow_dispatch - Derive PackageVersion from the tag (strips leading 'v') using GITHUB_REF_NAME - Remove hardcoded 0.2.2 version Usage: push a tag like 'v0.2.3' to trigger a NuGet release at that version. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the GitHub Actions release workflow to publish NuGet packages automatically when a version tag is pushed, using the tag name as the package version.
Changes:
- Switch release triggering from
workflow_dispatchtopushon tags matchingv*. - Derive
RELEASE_VERSIONfromGITHUB_REF_NAME(stripping the leadingv). - Use the derived version for
dotnet packinstead of a hardcoded version.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v4 | ||
| with: | ||
| dotnet-version: 9.0.x | ||
| - name: Get latest tag version | ||
| - name: Get version from tag |
There was a problem hiding this comment.
The steps: list items appear to be indented at the same level as the steps: key (instead of being nested under it). GitHub Actions requires sequence items under steps: to be indented deeper (e.g., steps: then - uses:). As written, this workflow is likely invalid YAML and may not run.
| push: | ||
| tags: | ||
| - 'v*' |
There was a problem hiding this comment.
The tag filter v* also matches a tag named exactly v, which would make RELEASE_VERSION empty after ${GITHUB_REF_NAME#v} and cause dotnet pack to run with an empty PackageVersion. Consider tightening the tag glob (e.g., require at least one character after v) and/or adding a guard that fails the job when RELEASE_VERSION is empty/invalid.
| dotnet-version: 9.0.x | ||
| - name: Get latest tag version | ||
| - name: Get version from tag | ||
| id: vars |
There was a problem hiding this comment.
Step Get version from tag sets id: vars but no step outputs are defined/consumed. Either remove the unused id or switch to step outputs (via $GITHUB_OUTPUT) if you intended to reference the version as steps.vars.outputs....
| id: vars |
| run: | | ||
| echo "Release version: $RELEASE_VERSION" | ||
| dotnet pack -p:PackageVersion=0.2.2 | ||
| dotnet pack -p:PackageVersion=$RELEASE_VERSION |
There was a problem hiding this comment.
The workflow only overrides PackageVersion. The project file currently hardcodes both <Version> and <PackageVersion> (e.g., 0.2.2), so the assembly/package metadata can become inconsistent across releases. Consider also passing -p:Version=$RELEASE_VERSION (or removing the hardcoded values from the project) so all version metadata comes from the tag.
| dotnet pack -p:PackageVersion=$RELEASE_VERSION | |
| dotnet pack -p:Version=$RELEASE_VERSION -p:PackageVersion=$RELEASE_VERSION |
Usage: push a tag like 'v0.2.3' to trigger a NuGet release at that version.