-
Notifications
You must be signed in to change notification settings - Fork 0
Add GitHub Actions release workflow with semantic versioning #2
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
base: main
Are you sure you want to change the base?
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 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. Comment |
Co-authored-by: narthur <[email protected]>
Co-authored-by: narthur <[email protected]>
…er error handling Co-authored-by: narthur <[email protected]>
…ndling Co-authored-by: narthur <[email protected]>
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.
Pull request overview
This PR adds automated release management to the repository using GitHub Actions with semantic versioning based on conventional commit messages. The workflow can be triggered manually or automatically when extension files are modified.
Key changes:
- New GitHub Actions workflow that calculates version bumps from commit messages using conventional commit patterns
- Automated packaging, changelog generation, and GitHub release publishing
- Documentation in README explaining both manual and automatic release processes
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
.github/workflows/release.yml |
Complete release automation workflow with semantic versioning, manifest updates, packaging, and GitHub release creation |
README.md |
Added comprehensive documentation section explaining release process, manual triggers, and automatic versioning rules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if git diff --staged --quiet; then | ||
| echo "No changes to commit" | ||
| else | ||
| git commit -m "chore: bump version to ${{ steps.semver.outputs.version }}" | ||
| fi |
Copilot
AI
Dec 11, 2025
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.
The workflow continues even when there are no changes to commit, but this can lead to issues in subsequent steps. If the manifest.json version hasn't actually changed (e.g., re-running the workflow with the same version), the git push in the "Create and push tag" step may fail or behave unexpectedly because there's nothing new to push to the branch. Consider adding a check to exit gracefully or skip subsequent git operations when no changes are detected.
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.
Fixed in commit 4060085. Added has_changes output flag and conditional logic to skip branch push when no changes were committed.
.github/workflows/release.yml
Outdated
| git tag -a "v${{ steps.semver.outputs.version }}" -m "Release v${{ steps.semver.outputs.version }}" | ||
| git push origin "v${{ steps.semver.outputs.version }}" | ||
| git push origin HEAD:${{ github.ref_name }} | ||
Copilot
AI
Dec 11, 2025
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.
This step will fail when the tag already exists. If the workflow is re-run or if a release with the same version already exists, git tag creation will fail with an error. Additionally, pushing the tag before verifying it was created successfully could cause issues. Consider checking if the tag exists before creating it, or use force-tagging with caution, or handle the error appropriately to prevent workflow failure.
| git tag -a "v${{ steps.semver.outputs.version }}" -m "Release v${{ steps.semver.outputs.version }}" | |
| git push origin "v${{ steps.semver.outputs.version }}" | |
| git push origin HEAD:${{ github.ref_name }} | |
| TAG="v${{ steps.semver.outputs.version }}" | |
| # Check if tag already exists | |
| if git rev-parse "$TAG" >/dev/null 2>&1; then | |
| echo "Tag $TAG already exists. Skipping tag creation and push." | |
| else | |
| git tag -a "$TAG" -m "Release $TAG" | |
| git push origin "$TAG" | |
| fi | |
| git push origin HEAD:${{ github.ref_name }} |
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.
Fixed in commit 4060085. Added check using git rev-parse to detect existing tags and skip creation when tag already exists.
.github/workflows/release.yml
Outdated
| run: | | ||
| git tag -a "v${{ steps.semver.outputs.version }}" -m "Release v${{ steps.semver.outputs.version }}" | ||
| git push origin "v${{ steps.semver.outputs.version }}" | ||
| git push origin HEAD:${{ github.ref_name }} |
Copilot
AI
Dec 11, 2025
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.
Pushing to HEAD with the ref name may cause issues if the workflow is triggered from a detached HEAD state or if there were conflicts. The push could fail silently or push to an unexpected location. Consider using a more explicit branch reference or adding error handling to verify the push was successful.
| git push origin HEAD:${{ github.ref_name }} | |
| git push origin ${{ github.ref_name }} || { echo "Failed to push to branch ${{ github.ref_name }}"; exit 1; } |
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.
Fixed in commit 4060085. Added explicit error handling with || { echo "Failed to push..."; exit 1; } and conditional execution based on has_changes flag.
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'content.js' | ||
| - 'manifest.json' | ||
| - 'styles.css' |
Copilot
AI
Dec 11, 2025
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.
This trigger configuration will create an infinite loop. When the workflow runs automatically on push to main, it commits the version bump to manifest.json (line 165) and pushes it back to main (line 172). Since manifest.json is in the paths filter (line 20), this push will trigger the workflow again, creating a continuous cycle of releases. Consider excluding automated commits from triggering the workflow by using commit message patterns or skip conditions, or remove manifest.json from the paths filter.
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.
Fixed in commit 4060085. Removed manifest.json from the paths filter to prevent the infinite loop. The workflow now only triggers on changes to content.js and styles.css.
.github/workflows/release.yml
Outdated
| - name: Get current version from manifest | ||
| id: current_version | ||
| run: | | ||
| CURRENT_VERSION=$(grep -o '"version": "[^"]*"' manifest.json | cut -d'"' -f4) |
Copilot
AI
Dec 11, 2025
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.
Using grep and cut for parsing JSON is fragile and error-prone. If the manifest.json format changes slightly (e.g., different spacing, ordering), this parsing could break. Since jq is already being used later in the workflow (line 109), it would be more reliable and consistent to use jq here as well for extracting the version.
| CURRENT_VERSION=$(grep -o '"version": "[^"]*"' manifest.json | cut -d'"' -f4) | |
| CURRENT_VERSION=$(jq -r '.version' manifest.json) |
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.
Fixed in commit 4060085. Now using jq -r '.version' for consistent and reliable JSON parsing.
| # Create a zip file with the extension | ||
| zip -r dist/gh2cursor-v${{ steps.semver.outputs.version }}.zip \ | ||
| manifest.json \ | ||
| content.js \ | ||
| styles.css \ | ||
| icons/ \ | ||
| LICENSE \ | ||
| README.md \ | ||
| -x "*.git*" "*.DS_Store" |
Copilot
AI
Dec 11, 2025
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.
The list of files to include in the zip is hardcoded in multiple places (here and potentially needs to stay in sync with the actual extension structure). If new files are added to the extension, this step needs manual updates. Consider using a more dynamic approach or documenting which files should be included, or alternatively, use a configuration file to define the list of files to package.
| # Create a zip file with the extension | |
| zip -r dist/gh2cursor-v${{ steps.semver.outputs.version }}.zip \ | |
| manifest.json \ | |
| content.js \ | |
| styles.css \ | |
| icons/ \ | |
| LICENSE \ | |
| README.md \ | |
| -x "*.git*" "*.DS_Store" | |
| # Use package-files.txt to define which files to include in the zip archive. | |
| # Update package-files.txt in the repository root to add/remove files for packaging. | |
| zip -r dist/gh2cursor-v${{ steps.semver.outputs.version }}.zip $(cat package-files.txt) -x "*.git*" "*.DS_Store" |
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.
Fixed in commit 4060085. Added a clear comment: "NOTE: Update this list when adding new files to the extension" to document that the file list needs manual updates.
.github/workflows/release.yml
Outdated
| PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | ||
| if [ -z "$PREV_TAG" ]; then | ||
| COMMITS=$(git log --pretty=%B -10) |
Copilot
AI
Dec 11, 2025
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.
The fallback to last 10 commits when no tags exist is arbitrary and could lead to incorrect version bump detection. If the repository has more than 10 commits before the first release, some relevant commit messages won't be analyzed. Consider using all commits from the repository root for the first release, or document this 10-commit limitation in the README.
| COMMITS=$(git log --pretty=%B -10) | |
| COMMITS=$(git log --pretty=%B) |
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.
Fixed in commit 4060085. Changed to git log --pretty=%B to analyze all commits from repository root for first release.
README.md
Outdated
| - `styles.css` | ||
|
|
||
| The version bump type is determined from commit messages using conventional commit patterns: | ||
| - Breaking changes (`feat!:`, `fix!:`, or `BREAKING CHANGE:` in commit body) → major version |
Copilot
AI
Dec 11, 2025
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.
The documentation states that fix!: triggers a major version bump, but the actual workflow implementation (line 72 in release.yml) only checks for the pattern ^[a-z]+(\([^)]*\))?!: which would match any commit type with an exclamation mark, not specifically fix!:. While fix!: would work, the documentation could be more accurate by saying "any commit type with ! (e.g., feat!, fix!, refactor!)" or list the pattern more generally.
| - Breaking changes (`feat!:`, `fix!:`, or `BREAKING CHANGE:` in commit body) → major version | |
| - Breaking changes (any commit type with `!:` such as `feat!:`, `fix!:`, `refactor!:`, or `BREAKING CHANGE:` in commit body) → major version |
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.
Fixed in commit 4060085. Updated documentation to accurately state "any commit type with !: such as feat!:, fix!:, refactor!:".
|
@copilot apply changes based on the comments in this thread |
…ror handling, and fix documentation Co-authored-by: narthur <[email protected]>
… safety Co-authored-by: narthur <[email protected]>
Automates releases using semantic versioning calculated from conventional commit messages.
Workflow Features
mainwhen extension files change!:(e.g.,feat!:,fix!:,refactor!:) orBREAKING CHANGE:→ majorfeat:orfeat(scope):→ minormanifest.json, creates.zipartifact, generates changelog, publishes GitHub releaseTechnical Implementation
jqfor safe JSON manipulation ofmanifest.json(parsing and updating)^[a-z]+(\([^)]*\))?!:manifest.jsonfrom automatic trigger pathsUsage
Manual release:
Automatic release:
Push to
mainwith changes tocontent.jsorstyles.cssNote:
manifest.jsonis intentionally excluded from automatic triggers to prevent infinite loops, as the workflow commits version bumps to this file.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.