drizzle 0.1.15

A type-safe SQL query builder for Rust
Documentation
name: Update

on:
  # Auto-create / update the release PR on every push to main. release-plz
  # internally checks whether there's anything releasable since the last tag —
  # if not (e.g. the push was a pure chore: / style: commit that our parser
  # skips, and no other unreleased work exists), no PR is created or updated.
  # Manual trigger is kept so you can force a refresh if needed.
  workflow_dispatch:
  push:
    branches: [main]

permissions:
  actions: write
  contents: write
  pull-requests: write

concurrency:
  # Single in-flight release-PR update per branch — rapid pushes coalesce so
  # we only do the work once, against the latest commit.
  group: update-${{ github.ref }}
  cancel-in-progress: true

jobs:
  update:
    runs-on: ubuntu-latest
    timeout-minutes: 15
    # Skip release-PR merge commits and internal-only commits. release-plz can
    # bump on package-content diffs even when its changelog parser skips the
    # commit, so CI/config-only pushes must not run the release-PR updater.
    # workflow_dispatch always runs so you can force a refresh if needed.
    if: >-
      github.event_name == 'workflow_dispatch' ||
      (
        !startsWith(github.event.head_commit.message, 'chore') &&
        !startsWith(github.event.head_commit.message, 'style') &&
        !startsWith(github.event.head_commit.message, 'test') &&
        !startsWith(github.event.head_commit.message, 'ci') &&
        !startsWith(github.event.head_commit.message, 'lint') &&
        !startsWith(github.event.head_commit.message, 'build') &&
        !contains(github.event.head_commit.message, 'release-plz-')
      )
    steps:
      - name: Clone repository
        uses: actions/checkout@v6
        with:
          fetch-depth: 0
          token: ${{ secrets.GITHUB_TOKEN }}

      - name: Get Rust version
        id: rust-version
        run: |
          RUST_VERSION=$(grep '^rust-version = ' Cargo.toml | sed 's/rust-version = "\(.*\)"/\1/')
          echo "version=$RUST_VERSION" >> $GITHUB_OUTPUT

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: ${{ steps.rust-version.outputs.version }}

      - name: Install nightly Rust for formatting
        uses: dtolnay/rust-toolchain@nightly
        with:
          components: rustfmt

      - name: Cache Rust dependencies
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: msrv

      # Format before release-plz so any formatting changes are included in the release PR
      - name: Format code with nightly
        run: cargo +nightly fmt

      - name: Install release-plz
        uses: taiki-e/install-action@v2
        with:
          tool: release-plz

      - name: Create release PR
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          release-plz release-pr --git-token "$GITHUB_TOKEN" || {
            echo "::error::release-plz release-pr failed"
            exit 1
          }

      - name: Trigger release PR checks
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: |
          PR_NUMBER=$(gh pr list \
            --state open \
            --base main \
            --json number,headRefName,updatedAt \
            --jq 'map(select(.headRefName | startswith("release-plz-"))) | sort_by(.updatedAt) | last | .number // empty')

          if [[ -z "$PR_NUMBER" ]]; then
            echo "No open release PR found; skipping explicit CI dispatch."
            exit 0
          fi

          HEAD_REF=$(gh pr view "$PR_NUMBER" --json headRefName --jq '.headRefName')
          HEAD_SHA=$(gh pr view "$PR_NUMBER" --json headRefOid --jq '.headRefOid')

          echo "Dispatching CI for release PR #$PR_NUMBER ($HEAD_REF @ $HEAD_SHA)."
          gh workflow run ci.yml --ref "$HEAD_REF"
          gh workflow run benchmarks.yml --ref "$HEAD_REF"