---
myst:
  html_meta:
    "description": "The built-in steps of repoplone release, what each one reads and writes, what a dry run does, and the contract of a local_step."
    "property=og:description": "The built-in steps of repoplone release, what each one reads and writes, what a dry run does, and the contract of a local_step."
    "property=og:title": "Release steps"
    "keywords": "Plone, repoplone, release, steps, local_step, dry run, pipeline"
---

(reference-release-steps)=

# Release steps

This page lists the built-in steps of `repoplone release` and the contract of a step of your own.

(reference-release-steps-order)=

## Built-in steps

<!-- source: src/repoplone/release/steps/__init__.py -->

The steps run in this order unless `[repository.release] steps` sets another.

| Id | Title | Runs when |
|---|---|---|
| `changelog` | Display Changelog | always |
| `version` | Next version | always |
| `repository` | Update repository components | always |
| `release_python` | Release Python packages | the repository has an enabled Python package |
| `release_node` | Release Node packages | the repository has an enabled Node package |
| `git` | Commit changes, create tag | always |
| `gh_release` | Create GitHub release | always |
| `bye` | Summary and goodbye | always |

`repoplone settings release-steps` prints the configured order.
A step that fails stops the release with `Release failed: Release step <id> failed.` and exit code 1.

(reference-release-steps-preflight)=

## Checks before the first step

<!-- source: src/repoplone/commands/release.py, src/repoplone/utils/release.py -->

These checks run before the first step, in a dry run too.

| Check | Applies when | On failure |
|---|---|---|
| PyPI authentication: `UV_PUBLISH_TOKEN` is set, or `uv auth token pypi.org` succeeds | a Python package has `publish = true` | error, exit code 1 |
| npm authentication: `npm whoami` succeeds | a Node package has `publish = true` | error, exit code 1 |
| The repository changelog exists and has the line `<!-- towncrier release notes start -->` | repoplone writes the repository changelog itself, not a package at the root | error, exit code 1 |
| No tracked file has uncommitted changes | always | error, exit code 1; a warning in a dry run or with `--start-step` |
| The `origin` remote points to GitHub | always | warning |
| `GITHUB_TOKEN` is set and can read the repository's releases | always | warning |

After a warning, repoplone asks `Do you want to continue the release?`.
Answering no exits with code 0.

The `git` step commits every tracked change.
A restart with `--start-step` follows steps that already changed files.
There, uncommitted changes only give a warning.
Check that the warning lists only files the release wrote.

(reference-release-steps-each)=

## What each step does

<!-- source: src/repoplone/release/steps/*.py, src/repoplone/utils/release.py, src/repoplone/utils/_git.py, src/repoplone/utils/_github.py -->

`changelog`
: Builds the draft of the repository changelog entry from the news fragments, and prints it.
  Asks `Continue?`.
  Writes nothing.

`version`
: Computes the next version from the `desired_version` argument.
  Without the argument, a semver repository shows a menu of versions, and a calver repository computes the next one.
  Fails when the version is not valid, is not higher than the current one, or already exists as a git tag.
  Writes nothing.

`repository`
: Writes the changelog entry to the repository changelog, after the line `<!-- towncrier release notes start -->`.
  Deletes the repository's news fragments when `[repository.towncrier]` exists.
  Writes the new version to the `version` file.
  In each `compose` file, replaces the old version with the new one in image tags.
  It only changes `image:` lines that contain `container_images_prefix`, or every `image:` line when the prefix is empty.
  A tag can be the plain version, such as `app-backend:1.0.0`, or a variable default, such as `app-backend:${VERSION:-1.0.0}`.

`release_python`
: For each enabled Python package, in file order:
  compiles its `.po` files,
  sets its version with hatch,
  builds its changelog with towncrier and deletes its news fragments,
  and copies that changelog to each component whose `changelog_package` names the package.
  With `publish = true`, it then empties `dist/`, runs `uv build`, and runs `uv publish`.
  It skips a package whose version is already on PyPI.

`release_node`
: For each enabled Node package, converts the version to semantic versioning syntax, such as `1.0.0-alpha.1`.
  With `publish = false`, it writes the version to `package.json`, builds the changelog with towncrier, and copies it to components as above.
  With `publish = true`, it runs `npx release-it --ci --no-git --no-github.release` in the package folder.
  It skips a package whose version is already on npm.

`git`
: Runs `git commit -am "Release <version>"`.
  Creates the annotated tag `<version>`, without a `v` prefix.
  Pushes the branch, then the tag, to `origin`.

`gh_release`
: Creates a GitHub release for the tag, with the repository changelog entry as its body.
  Without a token, or when `origin` is not on GitHub, it prints a message and goes on.
  The token comes from `GITHUB_TOKEN`, or from `gh auth token` after a confirmation in an interactive terminal.

`bye`
: Prints `Completed the release of version <new> from version <old>`.

(reference-release-steps-dry-run)=

## Dry run

<!-- source: src/repoplone/utils/release.py, release_backend and release_frontend -->

`repoplone release --dry-run` runs every step with these differences.

| Step | In a dry run |
|---|---|
| `changelog` | Same as a release. |
| `version` | Same as a release. |
| `repository` | Prints `Would update` for each file and writes nothing. |
| `release_python` | Runs `uv build` for each package with `publish = true`. Compiles no `.po` files, sets no version, writes no changelog, publishes nothing. |
| `release_node` | Runs `release-it --dry-run` for every Node package. |
| `git` | Skipped. |
| `gh_release` | Skipped. |
| `bye` | Same as a release. |

A dry run leaves a `dist/` folder in each Python package with `publish = true`.

(reference-release-steps-restart)=

## Restarting a release

<!-- source: src/repoplone/release/pipeline.py, src/repoplone/release/steps/version.py -->

`--start-step <id>` skips the steps before `<id>`.
The release prints them as `(skipped)`.
`--start-step` also accepts the specification 1 ids `release_backend` and `release_frontend`.

When the start step comes after `version`, give the version as the `desired_version` argument.
A version equal to the content of the `version` file is used as it is.
This is the case once `repository` has run.
Any other version must be higher than the content of the `version` file, and must not exist as a tag.

The package steps skip each package already published at that version.
A restart therefore does not upload a package twice.

(reference-release-steps-local)=

## `local_step`

<!-- source: src/repoplone/release/steps/local_step.py -->

A registry entry with `function = "local_step"` calls a function of your own.

```toml
[repository.release.registry.notify]
function = "local_step"
title = "Notify the team"
args = { entrypoint = "scripts.release:notify", channel = "releases" }
```

`args.entrypoint`
: Required.
  The form is `module.path:callable`.
  repoplone puts the root of the repository first on `sys.path` before it imports the module.

Other keys of `args`
: Passed to the callable as keyword arguments.

The callable has this signature.

```python
def notify(step_id, title, settings, state, **kwargs) -> bool:
    if state.dry_run:
        return True
    channel = kwargs["channel"]
    print(f"Released {state.next_version}, telling {channel}")
    return True
```

| Argument | Value |
|---|---|
| `step_id` | The registry key, such as `notify`. |
| `title` | The step title. |
| `settings` | The repository settings. `settings.backend` and `settings.frontend` give the primary Python and Node packages. |
| `state` | The release state. See the next table. |

| `state` attribute | Value |
|---|---|
| `dry_run` | `True` in a dry run. A step of your own should then change nothing. |
| `original_version` | The version before the release. |
| `next_version` | The new version, once `version` has run. |
| `version_format` | `"semver"` or `"calver"`. |

A return value that is false fails the release.
`repoplone settings sanity-check` imports every entrypoint and reports the ones that fail.

```{seealso}
- {doc}`/explanation/release-pipeline`, for why the release is a list of steps.
- {doc}`/how-to/customize-the-release`, to add, drop, or reorder steps.
- {ref}`cli-release`, for the options of the command.
```
