Automate release notes and version from GitHub releases#433
Merged
martinnormark merged 2 commits intomainfrom Jun 26, 2025
Merged
Automate release notes and version from GitHub releases#433martinnormark merged 2 commits intomainfrom
martinnormark merged 2 commits intomainfrom
Conversation
- Extract version from release tag, handling 'v' prefix - Use release body as PackageReleaseNotes - Pass values to dotnet pack via MSBuild properties - Remove hardcoded Version and PackageReleaseNotes from csproj Co-Authored-By: Martin <m@martinnormark.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
|
Handling -p:PackageReleaseNotes="${{ github.event.release.body }}"This can break if
✅ Fix: Use a multiline-safe inputWrap the -p:PackageReleaseNotes='${{ github.event.release.body }}'This works because GitHub will substitute the body literally, and single quotes in shell protect the contents from interpretation.
✅ Suggested Safe Version- name: Extract version from tag
if: ${{ github.event_name == 'release' }}
id: version
run: |
TAG_NAME="${{ github.event.release.tag_name }}"
VERSION=${TAG_NAME#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Write release notes to file
if: ${{ github.event_name == 'release' }}
run: echo "${{ github.event.release.body }}" > release-notes.txt
- name: Package
if: ${{ github.event_name == 'release' }}
run: |
RELEASE_NOTES=$(cat release-notes.txt)
dotnet pack -c Release -o . PreMailer.Net/PreMailer.Net/PreMailer.Net.csproj \
-p:Version="${{ steps.version.outputs.version }}" \
-p:PackageReleaseNotes="$RELEASE_NOTES"
- name: Publish
if: ${{ github.event_name == 'release' }}
run: dotnet nuget push *.nupkg -k ${{ secrets.NUGET_APIKEY }} -s https://api.nuget.org/v3/index.json |
- Write release notes to file first to avoid shell escaping issues - Read from file using cat to safely handle quotes and line breaks - Addresses feedback from @martinnormark on PR #433 Co-Authored-By: Martin <m@martinnormark.com>
martinnormark
approved these changes
Jun 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Automate release notes and version from GitHub releases
Summary
This PR eliminates the need to manually maintain version numbers and release notes in the csproj file by automating them through GitHub releases. When a new release is created on GitHub, the workflow will now:
dotnet packvia MSBuild propertiesThe hardcoded
VersionandPackageReleaseNotesproperties have been removed from the csproj file, making the release process much more streamlined.Key Changes:
github.event.release.tag_namecatdotnet packcommand to use MSBuild properties-p:Versionand-p:PackageReleaseNotesReview & Testing Checklist for Human
dotnet buildanddotnet packcommands still work (they should use default version 1.0.0 without the properties)Diagram
graph TD A[GitHub Release Created] --> B[dotnetcore.yml Workflow] B --> C[Extract Version Step] B --> D[Write Release Notes Step] B --> E[Package Step] B --> F[Publish Step] C --> G[github.event.release.tag_name] C --> H[Strip v prefix] C --> I[Output version variable] D --> J[github.event.release.body] D --> K[Write to release-notes.txt] K --> E I --> E E --> L[Read from file with cat] E --> M[dotnet pack with MSBuild props] N[PreMailer.Net.csproj] --> E style B fill:#90EE90 style N fill:#90EE90 style C fill:#87CEEB style D fill:#87CEEB style E fill:#87CEEB style F fill:#white style A fill:#white style G fill:#white style H fill:#white style I fill:#white style J fill:#white style K fill:#white style L fill:#white style M fill:#white subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#whiteNotes
release-notes.txtfirst, then read withcatto safely handle quotes, newlines, and other special characters that could break shell command parsinggithub.event_name == 'release', so they won't affect regular PR builds