README.md

# Publisho

Version management for Elixir projects. Bump versions, update changelogs, commit, and tag — all in one command.

## Usage

```sh
mix publisho patch          # 1.2.3 -> 1.2.4
mix publisho minor          # 1.2.3 -> 1.3.0
mix publisho major          # 1.2.3 -> 2.0.0
mix publisho rc             # 1.2.3 -> 1.2.4-rc.1
mix publisho beta           # 1.2.3 -> 1.2.4-beta.1
mix publisho alpha          # 1.2.3 -> 1.2.4-alpha.1
mix publisho stable         # 1.2.3-rc.1 -> 1.2.3
```

### Options

- `--dry-run` — show what would happen without making changes
- `--as-major` — bump major when entering pre-release (alpha/beta/rc only)
- `--as-minor` — bump minor when entering pre-release (alpha/beta/rc only)
- `--allow-dirty` — skip the git clean check

### How it works

1. Checks that the git working tree is clean (unless `--allow-dirty`)
2. Reads the current version from the `version` field in `mix.exs`
3. Bumps the version according to the given level
4. Reads release notes from `RELEASE.md` (required for stable releases, optional for pre-releases)
5. Updates `CHANGELOG.md` — if an entry for the same base version already exists (e.g. a previous RC), it is replaced in-place; otherwise a new entry is inserted after the placeholder
6. Writes the bumped version back to `mix.exs`
7. Writes the updated `CHANGELOG.md`
8. Clears `RELEASE.md` for stable releases (major/minor/patch/stable)
9. Stages `mix.exs`, `CHANGELOG.md`, and `RELEASE.md` with `git add`
10. Creates a commit with the message `"Version <version>"`
11. Creates an annotated git tag using the version string, with the release notes as the tag annotation (falls back to the version string if empty)

With `--dry-run`, steps 1-5 execute (pure computation) and the remaining steps are printed but not performed.

### Setup

Your project needs two files:

- **`RELEASE.md`** — write your release notes here before running the task. For stable releases this file is required and must not be empty. For pre-releases it is optional; if absent or empty, the version string is used as the tag annotation.

- **`CHANGELOG.md`** — must contain the placeholder comment `<!-- %% CHANGELOG_ENTRIES %% -->`. Entries are inserted after this line.

```markdown
# Changelog

<!-- %% CHANGELOG_ENTRIES %% -->
```

## Installation

Add `publisho` to your list of dependencies in `mix.exs`:

```elixir
def deps do
  [
    {:publisho, "~> 0.1.0", only: :dev, runtime: false}
  ]
end
```

Documentation is available at [HexDocs](https://hexdocs.pm/publisho).