# `mix phoenix_kit.release_check`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v2.21.1/lib/mix/tasks/phoenix_kit.release_check.ex#L1)

Asserts release-metadata consistency before publishing to Hex.

Catches the class of mistakes that `precommit`/`quality.ci` cannot see —
version/CHANGELOG/migration drift and unsafe git state — and exits non-zero
on any failure so it can gate `mix hex.publish`. It is the semantic core of
the `mix prerelease` alias and runs without a database.

## Usage

    $ mix phoenix_kit.release_check
    $ mix phoenix_kit.release_check --allow-dirty --allow-branch

## Options

  * `--allow-dirty`  — downgrade the "working tree clean" check to a warning
  * `--allow-branch` — downgrade the "on main branch" check to a warning

## Checks Performed

  1. **CHANGELOG Heading** — top `## X.Y.Z` entry matches `mix.exs` `@version`
     (and is a real version, not "Unreleased").
  2. **CHANGELOG Body** — that entry has at least one content line.
  3. **Migration Version Sync** — code/disk/module consistency for the
     versioned migration chain:
       * `Migrations.Postgres.current_version/0` equals the highest
         `vNNN.ex` file on disk.
       * `Migrations.Postgres.initial_version/0` equals the LOWEST
         `vNNN.ex` file on disk (catches an orphaned below-floor file, or
         a floor bump that left the old file behind).
       * every version in `initial_version/0..current_version/0` has both
         a `vNNN.ex` file on disk AND a loadable
         `PhoenixKit.Migrations.Postgres.VNNN` module — catches an
         accidentally deleted delta file.
       * when `PhoenixKit.Migrations.ExpectedSchema` (the tool-generated
         verify-and-repair manifest, squash spec §5.1/§8.3) is loaded, its
         `chain_hash/0` must match a fresh SHA-256 over the same `vNNN.ex`
         file set — catches a migration added without regenerating the
         manifest. While the manifest does not exist yet (pre-squash, P2,
         pending the operator scratch DB), this prints an explicit SKIP
         notice instead of failing — see
         `dev_docs/plans/2026-07-14-squash-migrations-spec.md`.
  4. **Git Tree Clean** — no uncommitted changes (`--allow-dirty` to warn).
  5. **Git Branch** — on `main` (`--allow-branch` to warn).
  6. **Tag Collision** — tag `v<version>` does not already exist (publish-
     before-tag means a pre-existing tag signals a double release).

---

*Consult [api-reference.md](api-reference.md) for complete listing*
