# CI

> Run bump in CI with a full clone and a git identity, push the release commit and its tags, and read the result in a script.

bump runs in CI as it runs on your machine. It needs three things there: the full history with all tags, a git identity for the release commit, and a step that pushes the release.

## Full clone

bump finds changes with the git history and the tags. A shallow clone lacks most of the history and tags. bump stops because the clone is shallow:

```console
$ bump patch
FAIL A full clone is needed: the history and tags are used to find changes (in CI, fetch all history and tags)
```

Most CI systems make a shallow clone by default. In GitHub Actions, set `fetch-depth: 0` on `actions/checkout`. It fetches all history and all tags:

```yaml
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
  with:
    fetch-depth: 0
```

In other CI systems, fetch the rest of the history and the tags before you run bump:

```sh
git fetch --unshallow --tags
```

## Git identity

bump makes a commit and annotated tags, so git needs a name and an email. A CI runner often has neither, and the commit fails. bump then undoes the release, and the error starts with `Could not commit:`.

Set the identity before you run bump:

```sh
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
```

Use any name and email that your team wants to see on release commits.

## GitHub Actions

This workflow releases on demand. You start it from the Actions tab, and give it a type or an exact version:

```yaml [.github/workflows/release.yml]
name: Release

on:
  workflow_dispatch:
    inputs:
      type:
        description: A release type, or an exact version
        required: true
        default: patch

concurrency:
  group: release

permissions: {}

jobs:
  release:
    runs-on: ubuntu-24.04
    permissions:
      contents: write
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          fetch-depth: 0
      - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
        with:
          no-cache: true

      - run: bun ci

      - run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

      - run: bunx bump "$TYPE"
        env:
          TYPE: ${{ inputs.type }}

      - run: git push --follow-tags
```

- `contents: write` lets the job push the commit and the tags.
- `concurrency` makes sure that only one release runs at a time.
- `bun ci` installs the packages from the lockfile, with bump. If you use npm, pnpm, or Yarn, install with that tool, but keep `setup-bun`: bump runs on Bun.
- The input goes through `env`, not straight into the script, so its text cannot run as shell code.
- `git push --follow-tags` pushes the branch and the annotated tags that point to its commits. bump makes only annotated tags.

When there is nothing to release, bump exits with `0`, and the push has nothing to send.

<bongo:note>
GitHub does not start other workflows for a push that uses the default `GITHUB_TOKEN`. So a workflow that runs on tag pushes, such as a publish workflow, does not start after this push. Publish in the same job after the push, or push with a token that is not `GITHUB_TOKEN`.
</bongo:note>

If a rule protects your branch from direct pushes, the push fails. Then push with a GitHub App token or a deploy key that the rule lets bypass.

## Lockfiles in CI

In CI, pnpm and Yarn freeze their lockfiles by default. bump turns that off for its own lockfile update, so a release can update `pnpm-lock.yaml` and `yarn.lock`. You do not need to change anything. See [Lockfiles](/lockfiles/#ci).

## Scripts

### JSON

With `--json`, stdout holds only the [Result](/json/) object, and the log goes to stderr. Use it to read the new tags or to decide what to publish:

```sh
bunx bump patch --json > release.json
jq -r '.units[].tag' release.json
jq -r '.units[].packages[] | select(.publish) | .dir' release.json
```

With an error, stdout is empty, and the exit code is `1`.

### Quiet

With `--quiet`, bump prints only the new tags on stdout, one on each line. See [Quiet](/cli/#quiet). To keep the tags in a shell variable:

```sh
tags=$(bunx bump minor --quiet)
```

### Exit codes

bump exits with `0`, `1`, `130`, or `143`. See [Exit codes](/cli/#exit-codes). When a `SIGINT` or `SIGTERM` stops bump during a release, bump undoes the release before it exits. So a canceled job does not leave a half-made release in the clone.
