growthbook-rust 0.2.2

Official Growthbook Rust SDK
Documentation
name: release-please

on:
  push:
    branches: [main]

permissions:
  contents: write
  pull-requests: write

jobs:
  # 1. Maintains a release PR from conventional commits. On merge it bumps
  #    Cargo.toml/Cargo.lock, updates CHANGELOG.md, tags the release, and
  #    creates the GitHub Release. Config lives in release-please-config.json
  #    + .release-please-manifest.json.
  #
  #    `release_created` is true only on the push that merges the release PR;
  #    the publish job below gates on it, so it runs exactly once per release
  #    and never on ordinary pushes.
  release-please:
    runs-on: ubuntu-latest
    outputs:
      release_created: ${{ steps.release.outputs.release_created }}
    steps:
      # PRs opened with the default GITHUB_TOKEN do not trigger other workflows,
      # so CI won't auto-run on the release PR. Set a fine-grained PAT with
      # contents+pull-requests write as RELEASE_PLEASE_TOKEN to get CI on it;
      # falls back to GITHUB_TOKEN (release PR just won't get CI) if unset.
      - id: release
        uses: googleapis/release-please-action@v4
        with:
          token: ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}

  # 2. Publish the freshly-tagged version to crates.io. Runs in the same
  #    workflow invocation that created the release, so it never depends on a
  #    GITHUB_TOKEN-created event chain-firing.
  publish-crate:
    needs: release-please
    if: ${{ needs.release-please.outputs.release_created == 'true' }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
      - name: Verify build/tests before publishing
        run: cargo test --locked
      - name: Publish to crates.io
        run: cargo publish --locked
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}