> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Bach builds Windows installers from one bach.toml with the bach command: bach init, bach check, bach preview, bach build. Installs are per user and need no administrator rights by default. installer.scope = "machine" installs for every user after one Windows prompt. On Windows, run setup files with Start-Process -Wait -PassThru in PowerShell, and give signtool arguments that start with the word sign.

# Build in GitHub Actions and other CI

> Build installers in CI with the usebach/bach-installer GitHub Action or the install scripts, publish releases, sign, handle secrets and pin the Bach version.

This page shows how to build your installer on a build server, mainly with Bach's GitHub Action. If you'd rather have a complete release workflow written for you, use [one-click releases](/docs/guides/releasing.md) instead.

## Build on every tag

This workflow builds and publishes a release whenever you push a tag like `v1.4.0`:

```yaml .github/workflows/release.yml theme={"theme":{"light":"github-light","dark":"github-dark"}}
on:
  push:
    tags: ['v*']
permissions:
  contents: write          # needed to publish the release
jobs:
  release:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      # Build your app into the folder bach.toml's files.source names.
      - run: cargo build --release
      - uses: usebach/bach-installer@v0
        with:
          config: bach.toml
          release: true
```

The tag sets the app version: `v1.4.0` builds version `1.4.0`, so you don't have to edit `bach.toml` for each release.

## Only build, don't publish

```yaml .github/workflows/build.yml theme={"theme":{"light":"github-light","dark":"github-dark"}}
jobs:
  build:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4
      - run: cargo build --release
      - uses: usebach/bach-installer@v0
        id: bach
        with:
          config: bach.toml
      - uses: actions/upload-artifact@v4
        with:
          name: installer
          path: ${{ steps.bach.outputs.setup }}
```

The action works on Windows, macOS and Linux runners. It runs `bach doctor` and then `bach build`. Build on `windows-latest` so your setup file gets your icon; elsewhere it keeps Bach's.

## Inputs

| Input | Default | What it does |
| - | - | - |
| `config` | none | The `bach.toml` to build. Without it, the action only installs `bach`. |
| `version` | the tag you pinned | Which Bach to use: `0.11.1`, `0.11`, `latest`, or `local` for a `bach` already on `PATH`. |
| `app-version` | `auto` | Your app's version. `auto` takes it from the tag; empty keeps `bach.toml`'s. |
| `args` | none | Extra arguments for `bach build`, such as `--fast` or `--patch-from OLD.exe`. Quote values with spaces. |
| `sign-command` | none | A PowerShell command that signs the file in `$env:BACH_SETUP_FILE`. Windows runners only. |
| `release` | `false` | Publish the setup file and `latest.json` as a GitHub release. |
| `tag` | `v` + version | The release tag. |
| `notes`, `notes-file` | none | What's new, for the release and the update feed. |
| `prerelease`, `draft`, `latest` | `false`, `false`, `true` | How the release is published. |
| `compare` | `false` | Compare with the last release's setup file and report what changed in the job summary and on pull requests. |
| `github-token` | the workflow's token | Used to publish and to look up releases. |

For `compare` to comment on pull requests, the job needs `pull-requests: write`.

## Outputs

| Output | What it holds |
| - | - |
| `setup` | Path of the setup file |
| `setup-macos` | Path of the macOS file, with `[macos]` |
| `web-setup` | Path of the online installer, if `installer.online` is on |
| `patch` | Path of the update patch, with `--patch-from` |
| `version` | The version that was built |
| `feed` | Path of `latest.json`, with `[updates]` |
| `tag`, `release-url` | The published release, with `release: true` |
| `bach-version` | The Bach version used |

## Sign in CI

```yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
- uses: usebach/bach-installer@v0
  env:
    CERT_PASSWORD: ${{ secrets.CERT_PASSWORD }}
  with:
    config: bach.toml
    release: true
    sign-command: signtool sign /fd sha256 /f cert.pfx /p $env:CERT_PASSWORD /tr http://timestamp.digicert.com /td sha256 $env:BACH_SETUP_FILE
```

Getting `cert.pfx` onto the runner from a secret is up to your workflow. The signature is added before `latest.json` is written, so the feed's checksum matches the signed file. See [Signing](/docs/guides/signing.md).

## Secrets for protected apps and signed feeds

If your app uses an [access key](/docs/guides/paid-apps.md) or a [signed feed](/docs/guides/update-security.md), pass the secrets as environment variables:

```yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
- uses: usebach/bach-installer@v0
  env:
    BACH_ACCESS_KEY: ${{ secrets.BACH_ACCESS_KEY }}
    BACH_FEED_KEY: ${{ secrets.BACH_FEED_KEY }}
  with:
    config: bach.toml
```

## Pin the action

| `uses:` | Follows |
| - | - |
| `usebach/bach-installer@v0` | the newest 0.x release |
| `usebach/bach-installer@v0.11` | the newest 0.11 release |
| `usebach/bach-installer@v0.11.1` | exactly this release |
| `usebach/bach-installer@<commit>` | exactly this commit and the Bach version in it |

## Other CI systems

Install `bach` in the job and call it as you would locally:

> [tab] Windows runner
>
> ```powershell theme={"theme":{"light":"github-light","dark":"github-dark"}}
> $env:BACH_NO_PATH = '1'
> irm https://raw.githubusercontent.com/usebach/bach-installer/main/install.ps1 | iex
> & "$env:LOCALAPPDATA\Programs\bach-cli\bach.exe" build --strict
> ```

> [tab] macOS or Linux runner
>
> ```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
> curl -fsSL https://raw.githubusercontent.com/usebach/bach-installer/main/install.sh | sh
> ~/.local/bin/bach build --strict
> ```

`bach` exits with a non-zero code and a readable message when anything is wrong. `--strict` also fails on warnings, and `--json` prints a machine-readable result.

If the runner can't download from GitHub, put `bach-setup.exe` next to `bach`, or pass `--runtime <path>`. Set `BACH_NO_DOWNLOAD` to forbid downloads. See [Environment variables](/docs/reference/setup/environment-variables.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.