Release a New Version - Clippy Documentation

## Keyboard shortcuts

Press `←` or `→` to navigate between chapters

Press `S` or `/` to search in the book

Press `?` to show this help

Press `Esc` to hide this help

# Release a new Clippy Version

> NOTE: This document is probably only relevant to you, if you’re a member of the Clippy team.

Clippy is released together with stable Rust releases. The dates for these releases can be found at the Rust Forge. This document explains the necessary steps to create a Clippy release.

1. Defining Remotes
2. Bump Version
3. Find the Clippy commit
4. Update the `beta` branch
5. Update the `stable` branch
6. Tag the stable commit
7. Update `CHANGELOG.md`

## Defining Remotes

You may want to define the `upstream` remote of the Clippy project to simplify the following steps. However, this is optional and you can replace `upstream` with the full URL instead.

    git remote add upstream git@github.com:rust-lang/rust-clippy

## Bump Version

When a release needs to be done, `cargo test` will fail, if the versions in the `Cargo.toml` are not correct. During that sync, the versions need to be bumped. This is done by running:

    cargo dev release bump_version

This will increase the version number of each relevant `Cargo.toml` file. After that, just commit the updated files with:

    git commit -m "Bump Clippy version -> 0.1.XY" **/*Cargo.toml

`XY` should be exchanged with the corresponding version

## Find the Clippy commit

For both updating the `beta` and the `stable` branch, the first step is to find the Clippy commit of the last Clippy sync done in the respective Rust branch.

Running the following commands in the Rust repo will get the commit for the specified `<branch>`:

    git switch <branch>
    SHA=$(git log --oneline -- src/tools/clippy/ | grep -o "Merge commit '[a-f0-9]*' into .*" | head -1 | sed -e "s/Merge commit '\([a-f0-9]*\)' into .*/\1/g")

Where `<branch>` is one of `stable`, `beta`, or `master`.

## Update the `beta` branch

After getting the commit of the `beta` branch, the `beta` branch in the Clippy repository can be updated.

    git checkout beta
    git reset --hard $SHA
    git push upstream beta

## Update the `stable` branch

After getting the commit of the `stable` branch, the `stable` branch in the Clippy repository can be updated.

    git checkout stable
    git reset --hard $SHA
    git push upstream stable

## Tag the `stable` commit

After updating the `stable` branch, tag the HEAD commit and push it to the Clippy repo.

    git tag rust-1.XX.0               # XX should be exchanged with the corresponding version
    git push upstream rust-1.XX.0     # `upstream` is the `rust-lang/rust-clippy` remote

After this, the release should be available on the Clippy tags page.

## Publish `clippy_utils`

The `clippy_utils` crate is published to `crates.io` without any stability guarantees. To do this, after the sync and the release is done, switch back to the `upstream/master` branch and publish `clippy_utils`:

> Note: The Rustup PR bumping the nightly and Clippy version must be merged before doing this.

    git switch master && git pull upstream master
    cargo publish --manifest-path clippy_utils/Cargo.toml

## Update `CHANGELOG.md`

For this see the document on how to update the changelog.

If you don’t have time to do a complete changelog update right away, just update the following parts:

- Remove the `(beta)` from the new stable version:

      ## Rust 1.XX (beta) -> ## Rust 1.XX

- Update the release date line of the new stable version:

      Current beta, release 20YY-MM-DD -> Current stable, released 20YY-MM-DD

- Update the release date line of the previous stable version:

      Current stable, released 20YY-MM-DD -> Released 20YY-MM-DD