[#723] Automate GitHub Release creation process and tagging#724
[#723] Automate GitHub Release creation process and tagging#724phongvhd93 wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughThis PR automates the GitHub Release creation pipeline by introducing a changelog PR template configuration, enhancing the release PR workflow with proper permissions and dynamic assignee handling, and adding a new workflow that creates annotated git tags and publishes GitHub Releases when release PRs merge to main. ChangesGitHub Release Automation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
.cicdtemplate/.github/workflows/tag_release.yml (2)
27-27: 💤 Low valueVersion pattern excludes pre-release and build metadata.
The regex
^release/([0-9]+\.[0-9]+\.[0-9]+)$only matches numeric semantic versions (e.g.,1.2.3) and will reject pre-release versions like1.2.3-alphaor1.2.3-beta.1. If pre-release versions are part of your release strategy, the pattern should be expanded to support them.📝 Expanded pattern for pre-release support (if needed)
- if [[ ! "$head_ref" =~ ^release/([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then + if [[ ! "$head_ref" =~ ^release/([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?)$ ]]; thenThis pattern would accept:
release/1.2.3(standard)release/1.2.3-alpha(pre-release)release/1.2.3-beta.1(pre-release with build)release/1.2.3+build.123(build metadata)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.cicdtemplate/.github/workflows/tag_release.yml at line 27, The if condition that tests head_ref uses the regex ^release/([0-9]+\.[0-9]+\.[0-9]+)$ which only accepts core numeric semver and rejects pre-release or build metadata; update the pattern used in that conditional (the if [[ ! "$head_ref" =~ ... ]]) to a SemVer-aware regex that allows optional pre-release (hyphen followed by alphanumerics, dots and hyphens) and optional build metadata (plus followed by alphanumerics and dots), so branch names like release/1.2.3, release/1.2.3-alpha, release/1.2.3-beta.1 and release/1.2.3+build.123 are accepted.
50-68: ⚡ Quick winConsider atomic release creation to handle partial failures.
If tag creation and push succeed (lines 50-57) but the GitHub Release creation fails (lines 59-68), the tag will exist in the remote repository without a corresponding release. This could require manual cleanup or result in confusion.
Consider either:
- Creating the release first using the merge commit SHA directly (before creating the local tag), or
- Adding error handling to delete the pushed tag if release creation fails.
However, given that
gh release createcan fail for transient reasons (network, API rate limits), option 1 is preferred since the release can be retried or created manually afterward without tag conflicts.🔄 Proposed refactor: create release before pushing tag
- - name: Create and push tag + - name: Create annotated tag locally shell: bash run: | tag="${{ steps.extract_version.outputs.version }}" git config --local user.email "action@github.com" git config --local user.name "GitHub Action" git tag -a "$tag" -m "Release $tag" - git push origin "$tag" - name: Create GitHub Release env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} shell: bash run: | tag="${{ steps.extract_version.outputs.version }}" gh release create "$tag" \ --target "${{ github.event.pull_request.merge_commit_sha }}" \ --title "$tag" \ --generate-notes + + - name: Push tag after successful release + shell: bash + run: | + tag="${{ steps.extract_version.outputs.version }}" + git push origin "$tag"This ensures the GitHub Release exists before the tag is pushed, avoiding orphaned tags.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.cicdtemplate/.github/workflows/tag_release.yml around lines 50 - 68, The workflow currently creates and pushes the tag (step "Create and push tag") before invoking gh release create, which can leave an orphaned remote tag if the release step fails; change the flow to call gh release create (using the merge commit SHA and the same tag name variable tag) before running git tag / git push, or if you prefer rollback keep the existing order but add error handling that deletes the pushed tag (git push origin --delete "$tag" or git push origin :$tag) when gh release create fails; update the steps referencing tag, git push, and gh release create accordingly so the release creation is attempted first or the pushed tag is removed on failure.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In @.cicdtemplate/.github/workflows/tag_release.yml:
- Line 27: The if condition that tests head_ref uses the regex
^release/([0-9]+\.[0-9]+\.[0-9]+)$ which only accepts core numeric semver and
rejects pre-release or build metadata; update the pattern used in that
conditional (the if [[ ! "$head_ref" =~ ... ]]) to a SemVer-aware regex that
allows optional pre-release (hyphen followed by alphanumerics, dots and hyphens)
and optional build metadata (plus followed by alphanumerics and dots), so branch
names like release/1.2.3, release/1.2.3-alpha, release/1.2.3-beta.1 and
release/1.2.3+build.123 are accepted.
- Around line 50-68: The workflow currently creates and pushes the tag (step
"Create and push tag") before invoking gh release create, which can leave an
orphaned remote tag if the release step fails; change the flow to call gh
release create (using the merge commit SHA and the same tag name variable tag)
before running git tag / git push, or if you prefer rollback keep the existing
order but add error handling that deletes the pushed tag (git push origin
--delete "$tag" or git push origin :$tag) when gh release create fails; update
the steps referencing tag, git push, and gh release create accordingly so the
release creation is attempted first or the pushed tag is removed on failure.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 96c06703-382d-4109-a665-a0275da0f306
📒 Files selected for processing (3)
.cicdtemplate/.github/workflows/configs/changelog-config.json.cicdtemplate/.github/workflows/create_release_pull_request.yml.cicdtemplate/.github/workflows/tag_release.yml
What happened 👀
tag_release.ymlworkflow to automatically create new release and tag release version after merging release tomainInsight 📝
Automate create release and tagging a version on GitHub
Proof Of Work 📹
Run:
Note: You can check the release format and tag from my playground repo. Better to try it yourself.
Summary by CodeRabbit
New Features
Chores