Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 11, 2025

Automates releases using semantic versioning calculated from conventional commit messages.

Workflow Features

  • Dual triggers: Manual dispatch with explicit version selection (patch/minor/major) or automatic on push to main when extension files change
  • Conventional commits: Parses commit messages to determine version bump
    • Any commit type with !: (e.g., feat!:, fix!:, refactor!:) or BREAKING CHANGE: → major
    • feat: or feat(scope): → minor
    • Everything else → patch
  • Automated packaging: Updates manifest.json, creates .zip artifact, generates changelog, publishes GitHub release
  • First-release handling: Detects missing tags, analyzes all commits from repository root, and generates appropriate initial release notes
  • Duplicate protection: Detects existing tags and skips release creation when version already exists

Technical Implementation

  • Uses jq for safe JSON manipulation of manifest.json (parsing and updating)
  • Regex patterns support scoped conventional commits: ^[a-z]+(\([^)]*\))?!:
  • Robust git error handling with conditional operations and explicit error checking
  • Prevents infinite loop by excluding manifest.json from automatic trigger paths
  • Quotes variables for command injection safety
  • Node.js 20 for consistent environment

Usage

Manual release:

Actions → Release with Semantic Versioning → Run workflow → Select version bump

Automatic release:
Push to main with changes to content.js or styles.css

Note: manifest.json is intentionally excluded from automatic triggers to prevent infinite loops, as the workflow commits version bumps to this file.

Original prompt

Let's add a github actions release workflow that uses semantic versioning to calculate the new version number


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@coderabbitai
Copy link

coderabbitai bot commented Dec 11, 2025

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit 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 @coderabbitai help to get the list of available commands and usage tips.

Copilot AI changed the title [WIP] Add GitHub Actions release workflow with semantic versioning Add GitHub Actions release workflow with semantic versioning Dec 11, 2025
Copilot AI requested a review from narthur December 11, 2025 15:56
@narthur narthur marked this pull request as ready for review December 11, 2025 16:00
@narthur narthur requested a review from Copilot December 11, 2025 16:00
Copy link

Copilot AI left a 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.

Comment on lines 162 to 166
if git diff --staged --quiet; then
echo "No changes to commit"
else
git commit -m "chore: bump version to ${{ steps.semver.outputs.version }}"
fi
Copy link

Copilot AI Dec 11, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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.

Comment on lines 170 to 173
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 }}
Copy link

Copilot AI Dec 11, 2025

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.

Suggested change
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 }}

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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.

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 }}
Copy link

Copilot AI Dec 11, 2025

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.

Suggested change
git push origin HEAD:${{ github.ref_name }}
git push origin ${{ github.ref_name }} || { echo "Failed to push to branch ${{ github.ref_name }}"; exit 1; }

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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.

Comment on lines 15 to 21
push:
branches:
- main
paths:
- 'content.js'
- 'manifest.json'
- 'styles.css'
Copy link

Copilot AI Dec 11, 2025

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.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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.

- name: Get current version from manifest
id: current_version
run: |
CURRENT_VERSION=$(grep -o '"version": "[^"]*"' manifest.json | cut -d'"' -f4)
Copy link

Copilot AI Dec 11, 2025

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.

Suggested change
CURRENT_VERSION=$(grep -o '"version": "[^"]*"' manifest.json | cut -d'"' -f4)
CURRENT_VERSION=$(jq -r '.version' manifest.json)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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.

Comment on lines 119 to 127
# 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"
Copy link

Copilot AI Dec 11, 2025

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.

Suggested change
# 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"

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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.

PREV_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$PREV_TAG" ]; then
COMMITS=$(git log --pretty=%B -10)
Copy link

Copilot AI Dec 11, 2025

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.

Suggested change
COMMITS=$(git log --pretty=%B -10)
COMMITS=$(git log --pretty=%B)

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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
Copy link

Copilot AI Dec 11, 2025

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.

Suggested change
- 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

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

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!:".

@narthur
Copy link
Contributor

narthur commented Dec 11, 2025

@copilot apply changes based on the comments in this thread

Copilot AI requested a review from narthur December 11, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants