Operations
Version Synchronization System
The version synchronization system ensures that all live version references remain consistent with dotfiles_version in defaults/.chezmoidata.toml. That manifest is the only hand-edited source; package.json, CLI metadata, discovery cards, and current documentation are generated release surfaces.
Overview
Problem Statement
Large repositories often have version numbers scattered across multiple files:
- README badges
- Documentation headers
- Feature version stamps
- Configuration files
Manually keeping these synchronized is error-prone and time-consuming.
Solution Architecture
This system provides automated version synchronization through:
- CI/CD Workflow (
.github/workflows/sync-versions.yml) - Verification onmainand PRs, automated synchronization onfeat/v*branches - Local Script (
scripts/version-sync.sh) - Manual synchronization and verification - Verification System - Ensures all references remain consistent
Components
1. GitHub Actions Workflow
Location: .github/workflows/sync-versions.yml
Triggers:
- Push to
mainor afeat/v*branch that touches any markdown file,package.json,defaults/.chezmoidata.toml,install.sh,scripts/version-sync.sh,scripts/verify-release-versions,scripts/release-preflightor this document - Pull requests to
maintouching the same paths - Manual dispatch with optional target version
Jobs:
| Event | Job | What it does |
|---|---|---|
| Pull request | verify | ./scripts/version-sync.sh --verify; fails on any mismatch. |
Push to main (or dispatch on main) | verify-protected | The same check. It never commits to main. |
Push to feat/v* (or dispatch on any other ref) | sync | Reads the target version (the dispatch input, else dotfiles_version from defaults/.chezmoidata.toml), runs ./scripts/version-sync.sh, and if anything changed has tools/ci/commit-via-api.sh commit it to that branch as chore: sync version references to vX.Y.Z, DCO-signed-off by github-actions[bot]. The commit is made through the GraphQL createCommitOnBranch mutation, so GitHub signs it and shows it as verified, which the required-signatures rule on main needs when the release PR merges. |
The workflow posts no PR comments and uploads no artifacts; the script's summary and any mismatches are in the job log.
2. Local Synchronization Script
Location: scripts/version-sync.sh
Usage:
# Sync to the canonical dotfiles_version
# Sync to specific version
# Preview changes without applying
# Verify current consistency
Options:
--dry-run- Preview changes without applying--verify- Check version consistency only--backup/--no-backup- Control backup creation--force- Force sync even if no changes detected
3. Version Patterns
The system recognizes and updates these patterns:
README.md
Documentation Files
Integration Points
Git Hooks Integration
For local development, add to .git/hooks/pre-commit:
#!/bin/bash
# Check version consistency before commits
|| {
}
Canonical Manifest Integration
Change the version explicitly through the synchronizer; it updates the canonical manifest and regenerates package.json in the same operation:
Workflow Examples
Scenario 1: Version Bump
# Developer updates the canonical manifest and all generated surfaces
# On a feat/v* branch, GitHub Actions then:
# 1. Re-runs the sync against the canonical version
# 2. Commits any remaining changes to the branch (a GitHub-signed commit)
#
# On main (and on the PR), it only verifies and fails on a mismatch.
Scenario 2: PR Review
# PR with version-surface changes
# GitHub Actions automatically:
# 1. Runs ./scripts/version-sync.sh --verify
# 2. Fails the check and logs each mismatch
Scenario 3: Manual Sync
# Local development
File Detection Logic
Automatic Discovery
The system automatically discovers files containing version references:
Known Files
These files are always included even if they don't currently contain versions (the non-markdown and hidden-directory surfaces the rg --type md scan cannot reach):
README.mddocs/reference/FEATURES.mddocs/COPYRIGHTscripts/git-hooks/pre-commit-audit.shdefaults/.chezmoitemplates/README.md,functions/README.mdandaliases/README.md
package.json is not scanned; the script sets its version field directly.
The discovery cards (.well-known/agent-card.json, .well-known/mcp/server-card.json, defaults/dot_config/dotfiles/agent-card.json) get their top-level version, and each plugin manifest (plugins/*/dot-plugin.toml) its version = line, never an alias's until. The Go binaries (dot-ui, dot-mcp) keep no version in their source: the build injects dotfiles_version with -ldflags "-X main.version=...", so --version and the MCP handshake report the framework version without a sync.
Exclusions
The authoritative list is the EXCLUDE_FILES array at the top of scripts/version-sync.sh, each entry with a comment saying why. It covers history (CHANGELOG.md, docs/archive/*, docs/articles/*, ROADMAP.md), every file under docs/operations/ (this document included), third-party and per-release version tables (for example docs/reference/FONTS.md, docs/security/COMPLIANCE.md, docs/security/VERIFY_RELEASE.md, pkg/VERIFY.md) and files deployed into $HOME that quote other projects' versions (defaults/Code/*). Only markdown files are scanned, so binaries and non-markdown fixtures never match.
Error Handling
Common Issues
Version Mismatch
❌ Found inconsistent release in docs/reference/FEATURES.md: vX.Y.Z (expected: vA.B.C)
Solution: Run ./scripts/version-sync.sh to fix
Optional Dependencies
Neither tool is required: without rg the script finds markdown files with find and grep, and without jq it rewrites the package.json version with sed. CI installs both.
Permission Issues
❌ Permission denied writing to README.md
Solution: Check file permissions and Git status
Recovery Procedures
Rollback Changes
# Restore from backup
# Or restore from Git
Force Resync
Monitoring & Maintenance
Health Checks
# Daily verification (add to cron)
||
Run Summary
Each sync ends with a summary in the log: target version, files updated, whether a backup was made, and the verification result.
Backup Strategy
- Local backups in
.version-sync-backup/(replaced on every run) - Git history for rollback
Security Considerations
Token Permissions
permissions:
contents: read # top level, and for both verify jobs
# sync job only:
# contents: write # createCommitOnBranch for the version-bump diff
Validation
- Version format validation (
x.y.zpattern) - File path validation (no directory traversal)
- Change verification before commit
Audit Trail
- All changes logged in Git history
- GitHub Actions run history
- Backup preservation
Performance Optimization
Caching Strategy
- Git operations use shallow fetch when possible
- Pattern compilation cached
- File discovery optimized with
ripgrep
Parallel Processing
- File processing is sequential but optimized
- Git operations batched
- Verification runs concurrently with updates
Resource Usage
- Typical run time: 30-60 seconds
- Memory usage: <100MB
- Network usage: Minimal (only Git operations)
Future Enhancements
Planned Features
- Smart Version Detection - Semantic version awareness
- Template Support - Custom version patterns
- Multi-Format Support - YAML, JSON, TOML files
- Rollback Automation - One-command rollback
- Integration Testing - End-to-end workflow tests
Extension Points
- Custom pattern definitions
- File-specific update rules
- Pre/post-sync hooks
- External validation services
Troubleshooting
Debug Mode
The script has no debug flag of its own; trace it with bash:
Common Solutions
| Issue | Solution |
|---|---|
| Script not executable | chmod +x scripts/version-sync.sh |
| Slow file discovery | apt install ripgrep (Ubuntu); jq is optional too |
| Permission denied | Check Git status and file permissions |
| Workflow not triggering | Check the push touches one of the trigger paths above |
| Changes not committed | Commits are made only on feat/v* pushes and non-main dispatches, never on main or PRs |
Log Analysis
# View GitHub Actions logs
Contributing
Testing Changes
# Test local changes
# Test workflow changes (requires GitHub CLI)
Adding New Patterns
- Update pattern regex in script
- Add test cases
- Update documentation
- Submit PR with examples
Last Updated: 2026-02-15 Version: v0.2.503 Maintainer: Principal Automation Engineer Status: Production Ready ✅