Skip to content

Conversation

@rfsbraz
Copy link
Owner

@rfsbraz rfsbraz commented Jan 25, 2026

Summary

Add build-time version sync to ensure manifest.json always matches package.json.

Problem

Release-please's extra-files config wasn't updating manifest.json during releases. This caused Chrome Web Store uploads to fail with version mismatch.

Solution

  • Add scripts/sync-version.js to copy version from package.json to manifest.json
  • Run sync-version automatically before build and build:zip
  • Remove broken extra-files config from release-please-config.json

Test plan

  • npm run build syncs version and validates
  • Merge to main, then merge release PR chore(main): release 2.1.1 #24
  • Chrome Web Store upload succeeds with correct version

Release-please's extra-files config wasn't updating manifest.json,
causing Chrome Web Store uploads to fail with version mismatch.

Solution:
- Add scripts/sync-version.js to copy version from package.json
- Run sync-version automatically before build and build:zip
- Remove broken extra-files config from release-please-config.json
Copilot AI review requested due to automatic review settings January 25, 2026 21:54
@rfsbraz rfsbraz merged commit 5ded90e into main Jan 25, 2026
8 checks passed
@rfsbraz rfsbraz deleted the fix/add-version-sync-script branch January 25, 2026 21:56
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 build-time version synchronization to ensure manifest.json always matches package.json during builds and releases. The previous approach using release-please's extra-files configuration was not updating the manifest, causing Chrome Web Store upload failures due to version mismatches.

Changes:

  • Added scripts/sync-version.js to copy version from package.json to manifest.json
  • Integrated sync-version into build and build:zip npm scripts using command chaining
  • Removed non-functional extra-files and obsolete release-as configuration from release-please-config.json

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
scripts/sync-version.js New script that synchronizes version from package.json to manifest.json before builds
package.json Adds sync-version script and integrates it into build and build:zip commands
release-please-config.json Removes broken extra-files config and obsolete release-as setting

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

console.log('✓ manifest.json updated');
}

syncVersion();
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The syncVersion function lacks error handling for file I/O operations and JSON parsing. In contrast, build.js (lines 72-83) wraps its main execution in a try-catch block with proper error messages and exit codes. This script should follow the same pattern to handle cases where:

  1. Files don't exist or can't be read
  2. JSON parsing fails due to malformed files
  3. File writing fails due to permissions or disk space

Without error handling, the script will crash with unhelpful stack traces instead of providing clear error messages to developers.

Suggested change
syncVersion();
if (require.main === module) {
try {
syncVersion();
} catch (err) {
console.error('Failed to sync version:', err && err.message ? err.message : err);
if (err && err.stack) {
console.error(err.stack);
}
process.exitCode = 1;
}
}

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +25
const pkg = JSON.parse(fs.readFileSync(PACKAGE_PATH, 'utf8'));
const manifest = JSON.parse(fs.readFileSync(MANIFEST_PATH, 'utf8'));

if (pkg.version === manifest.version) {
console.log(`Version already in sync: ${pkg.version}`);
return;
}

console.log(`Syncing version: ${manifest.version} -> ${pkg.version}`);
manifest.version = pkg.version;
Copy link

Copilot AI Jan 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script doesn't validate that pkg.version exists before attempting to use it. If package.json is missing the version field, this will assign 'undefined' to manifest.version, corrupting the manifest file. Consider adding validation similar to build.js line 37-38 which validates the manifest version field exists.

Copilot uses AI. Check for mistakes.
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