Skip to content

fix: skip npm version patch when already matching tag#364

Merged
ajitpratap0 merged 1 commit into
mainfrom
fix/vscode-publish-version-patch
Mar 13, 2026
Merged

fix: skip npm version patch when already matching tag#364
ajitpratap0 merged 1 commit into
mainfrom
fix/vscode-publish-version-patch

Conversation

@ajitpratap0
Copy link
Copy Markdown
Owner

Summary

  • Skip npm version when package.json version already matches the git tag
  • Fixes "Version not changed" error in the publish workflow

🤖 Generated with Claude Code

npm version errors with "Version not changed" when the version in
package.json already matches the tag version.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ajitpratap0 ajitpratap0 merged commit 467da64 into main Mar 13, 2026
@github-actions github-actions Bot added the ci-cd label Mar 13, 2026
@claude
Copy link
Copy Markdown

claude Bot commented Mar 13, 2026

Claude finished @ajitpratap0's task —— View job


Pull Request Review

Reviewing PR #364: fix: skip npm version patch when already matching tag

Todo List

  • Read and analyze the modified workflow file
  • Review code quality and best practices
  • Check for potential bugs or issues
  • Evaluate performance considerations
  • Assess security concerns
  • Review test coverage implications
  • Provide comprehensive feedback

Review Summary ✅

This is a well-implemented fix for a common CI/CD issue. The change prevents npm version from failing when the package.json version already matches the Git tag.

Code Quality & Best Practices ✅

Excellent implementation:

  • Clean conditional logic: The fix uses a proper if-else structure to check version mismatch
  • Clear variable naming: CURRENT and VERSION are descriptive
  • Informative logging: Both branches provide clear output about what's happening
  • Atomic operation: Uses --no-git-tag-version to prevent Git conflicts

Code location: .github/workflows/vscode-publish.yml:90-95

CURRENT=$(node -p "require('./package.json').version")
if [ "$CURRENT" != "$VERSION" ]; then
  npm version "$VERSION" --no-git-tag-version
else
  echo "Version already $VERSION, skipping patch"
fi

Security Assessment ✅

No security concerns identified:

  • Uses safe Node.js built-in require() to read package.json
  • No external input validation issues
  • Maintains existing version validation regex pattern
  • Preserves the --no-git-tag-version flag preventing unintended Git operations

Performance Considerations ✅

Minimal performance impact:

  • Adds only one lightweight Node.js evaluation (node -p)
  • Conditional execution actually improves performance when versions match (skips npm version)
  • No additional network calls or file I/O

Bug Prevention ✅

Addresses root cause effectively:

  • Original problem: npm version throws "Version not changed" error when package.json already matches tag
  • Solution: Check current version before attempting to patch
  • Error handling: Maintains existing semver validation
  • Idempotency: Workflow now runs successfully regardless of package.json state

GitHub Actions Best Practices ✅

Follows workflow best practices:

  • Maintains existing error handling patterns
  • Uses proper shell scripting with error checking
  • Clear step naming and documentation
  • Preserves existing timeout and matrix strategy

Potential Improvements (Minor)

  1. Consider adding version comparison logging:

    echo "Current version: $CURRENT, Target version: $VERSION"
  2. Optional: Add version mismatch detection for debugging:

    if [ "$CURRENT" != "$VERSION" ]; then
      echo "Version mismatch detected: $CURRENT -> $VERSION"
      npm version "$VERSION" --no-git-tag-version

Test Coverage Assessment

Manual testing scenarios covered:

  • ✅ Version mismatch (original npm version path)
  • ✅ Version match (new skip path)
  • ✅ Invalid semver (existing validation)

Recommendation: Consider adding a test workflow that validates this logic with mock package.json files.


Overall Assessment: APPROVED

This is a high-quality fix that:

  • Solves the immediate problem effectively
  • Follows GitHub Actions best practices
  • Maintains backward compatibility
  • Adds no security risks
  • Improves workflow reliability

The implementation is clean, well-documented, and addresses the root cause without introducing complexity.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant