
# Publish a release and patch the previous one

You build a release (a GitHub form, no command) and, the day a real operator cannot move up a version, you fix an earlier line without losing anything. `main` stays the only development branch, one PR per topic, no `develop`. This guide is for whoever publishes the image; to deploy a version, see [Upgrade to a new version](mettre-a-jour.md), and for what a number promises, [version numbers](versioning.md).

## 1. The source of truth: a git tag

A deployment's version is the **git tag** `vX.Y.Z` placed on `main`, created and pushed by GitHub's release form (§ 2). Annotated or lightweight makes no difference: `git describe --tags --exact-match`, the only reading that counts, treats them identically. Everything else **derives** from the tag:

| Where | How |
| --- | --- |
| Frontend (`APP_VERSION`, footer of both shells, *Debug* page) | `generate-version.js`: the exact tag (`v1.2.0`), otherwise the short SHA. The link leads to the GitHub release for a tag, to the commit for a SHA (`core/version-link.ts`) |
| *What's new* screen (`/nouveautes`) | `generate-news.js`: the git history read at build time, split by tag `vX.Y.Z` or `vX.Y.Z-rc.N` (a pre-release shows as such); what follows the last tag is under "Upcoming" |
| Backend (`quarkus.application.version`) | The `Dockerfile` passes `-Drevision=1.2.0` derived from the same `git describe`, the `v` removed; outside a release, the short SHA; in a local build, `999-SNAPSHOT` |
| Sentry, **frontend only** | `release: APP_VERSION`: browser errors group by version. Backend events do not carry a `release` yet |
| Docker image | `docker-ghcr.yml` publishes `ghcr.io/…:1.2.0` and `ghcr.io/…:1.2` on the tag push |
| GitHub release | One per tag, body written by `release.yml` (§ 2) |

The `pom.xml` carries **no hard-coded number** (`${revision}`), and a release workflow fails before building if the tag is not visible to the build.

## 2. Make a release

A release is **one form**: *Releases* → *Draft a new release* on GitHub. Choose the `vX.Y.Z` number ([what each number promises](versioning.md)), target `main`, publish. The body may stay empty. For a **pre-release**, name the tag `vX.Y.Z-rc.N` (`N` from 1, no leading zero) and tick *Set as a pre-release* (`release.yml` does it for you if you forget): the image is published only as `X.Y.Z-rc.N` (no `X.Y`, no `:latest`) and the notes cover the range since the last stable tag. Any other suffix (`-beta`, `-alpha`) is refused by both workflows.

![Making a release and patching an earlier version](repo:docs/diagrammes/release.svg)

<sub>Source: [`diagrammes/release.puml`](repo:docs/diagrammes/release.puml).</sub>

| What starts | On what | What it does |
| --- | --- | --- |
| `docker-ghcr.yml` | the tag push | `linux/amd64` build pushed only as `sha-…`, smoke test of the published image, SBOM, cosign signature, then tags `1.2.0` and `1.2`, and `:latest` if the tag is the most recent; for a pre-release, `1.2.0-rc.1` only |
| `release.yml` | the release publication | writes the release body: the section rendered by `git cliff --current` |

Both are independent and neither places nor moves a tag: the number stays a human decision. The smoke test starts the published image, by its digest, against a PostgreSQL 19 and a Mailpit, with the minimal production environment, and checks readiness, the exposed version, uid 1000, the presence of a `pg_dump` of the same major as the `postgres:` of `docker-compose.prod.yml` and a writable `/backup`; on failure, the container logs are shown. Only then is the image signed and the readable tags placed, by digest, without rebuilding: an image that does not start stays under `sha-…` for diagnosis, never `1.2.0`, `:main` or `:latest`. If this check fails on a release tag, delete the release and its tag, fix, start again at the same number.

What you write in the body at creation (the summary an annotated tag used to carry) is kept: `release.yml` leaves it at the top and writes the generated section only after a separator line and the `<!-- git-cliff -->` marker. Everything after that marker is rewritten on each run; re-running the workflow by hand (*Actions* → *Release notes* → *Run workflow*, with the tag) is safe and catches up an older release.

Two checks then run and fail **after** writing the notes (the release is already published, a red job is the only channel that warns): a number that lies (a merged `!` under a PATCH bump, a `feat` under a PATCH), or a tag that is neither on `main` nor on a `release/X.Y` branch (§ 3). A pre-release is compared with the last final version; the check refuses a pre-release of an already published version or whose `N` does not exceed that of a pre-release of the same number. In every case, delete the release and its tag, start again at the right number. Re-running the workflow by hand replays these checks with the scripts of `main`, not those of the tag.

### `:latest` never moves implicitly

`docker/metadata-action` by default would move `:latest` on **every** tag push: a `1.2.4` fix published after `1.3.0` would put `:latest` back on the old line. The workflow forces `latest=false`, and a separate step sets `:latest` only if the pushed tag is the greatest `vX.Y.Z` of the repository; it is skipped for a pre-release.

### Notes are generated, not written

There is no `CHANGELOG.md`: `cliff.toml` turns conventional messages (`feat:`, `fix:`…, the convention is in [`AGENTS.md`](repo:AGENTS.md)) into dated sections, which form the **release body** and nothing else. A file regenerated at tag time would have its commit *after* the tag, and the tagged tree would never contain its own entry; the release page is dated from the tag it documents. So the generated section is not edited by hand: a badly worded entry is fixed by rewording the commit *before* merging. The same subjects feed the **What's new** screen (same filters and headings as `cliff.toml`, but only the highlights), so a badly worded subject is read twice.

## 3. Patch an earlier version

Maintenance branches are created on demand, never in advance: while every deployment is on the latest version, there are none. Procedure, the day a real operator cannot move up (example: a flaw to fix, a production on `1.2.0`, `main` already on `1.3.x`):

```bash
# 1. The fix goes to main first. Always. No exception.
#    A fix that only exists on a maintenance branch is a regression
#    scheduled for the next version.
git switch main && … && git commit     # normal PR, green CI, merge

# 2. The maintenance branch, created from the TAG, not from main
git switch -c release/1.2 v1.2.0

# 3. Bring back the fix already merged on main
git cherry-pick -x <sha>               # -x records the origin in the message

# 4. Publish the branch; the tag is born from the release (§ 2): target
#    `release/1.2` in the form, not `main`
git push origin release/1.2
```

`release.yml` goes back to the previous tag of **that line** to compose the notes and check the bump: on `release/1.2`, a `v1.2.1` reads after `v1.2.0`, never after the `v1.3.0` of `main`. The rules that make this safe:

- `main` first, always, and nothing on a maintenance branch that is not already on `main`;
- `cherry-pick -x`, so the commit says which `main` commit it comes from. If the fix does not apply as is, write an adaptation and review it like new code;
- no Flyway migration in a patch, unless strictly additive: the schema is *forward-only*, a database already on `1.3.0` will not go back down. A patch that touches the schema is a version bump;
- `release/1.2` never merges into `main`;
- `:latest` does not move: `v1.2.1` is not the most recent tag of the repository.

The branch name is `release/X.Y`, exactly: `release.yml` does not accept `release/4.x`. No earlier line is maintained today ([version numbers](versioning.md#combien-de-temps-une-ligne-est-corrigée)): this procedure is the mechanism, not a commitment.
