Skip to content

feat: config schema versioning and automatic migration framework #195

@mwaldheim

Description

@mwaldheim

Summary

Introduce a schemaVersion field to .semrel.yaml and a semrel migrate command that automatically upgrades the config file to the current schema version when breaking changes are made.

Motivation

As semrel matures, the .semrel.yaml schema will change: fields get renamed, new required keys are added, plugin args format changes. Without a migration path, every schema change is a silent breaking change that only manifests as a confusing runtime error.

Proposed design

1. Schema version in config

schemaVersion: 1   # added automatically by semrel config init / semrel migrate
tagPrefix: "v"
branches:
  - name: main
plugins:
  - uses: analyzer-conventional

When schemaVersion is absent, semrel assumes v1 (current) and adds it on the next semrel migrate run.

2. semrel migrate command

$ semrel migrate

Detected .semrel.yaml at schema version 1
Current schema version: 2

Changes:
  [renamed]  plugins[*].path  →  plugins[*].binary
  [added]    plugins[*].phase (default: "release")

? Apply migration? [Y/n/diff]
> Y

✔  .semrel.yaml migrated to schema version 2
   Backup written to .semrel.yaml.bak

3. Auto-migration check on startup

When semrel detects that schemaVersion in the config is lower than the running binary expects, it:

  1. Prints a warning with the migration command
  2. In CI (no TTY), exits non-zero if the gap is more than one major schema version

4. Migration registry

Each schema change is captured as a named migration in internal/config/migrations/:

v1_to_v2.go   — rename path→binary, add phase default
v2_to_v3.go   — ...

Acceptance criteria

  • schemaVersion field added to config struct and schema
  • semrel migrate command implemented with dry-run (--dry-run) and backup (--backup, default true)
  • Migration functions are composable (v1→v2→v3 chains automatically)
  • Startup warning when config schema is outdated
  • Tests: migration from each previous version to current
  • Tracking issue for every plugin: [see linked issues]

Related

This issue tracks the core migration framework. Each plugin maintains its own SEMREL_PLUGIN_* env-var schema version and migration notes — see the individual plugin issues linked below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions