tinyhumans 0.1.0

Rust SDK for the TinyHumans backend
Documentation
name: Release Rust SDK

on:
  workflow_dispatch:
    inputs:
      bump:
        description: Version bump
        type: choice
        default: patch
        options: [patch, minor, major]

concurrency:
  group: release-main
  cancel-in-progress: false

permissions:
  contents: write

jobs:
  release:
    runs-on: ubuntu-latest
    environment: Production
    steps:
      - uses: actions/checkout@v4
        with:
          ref: main
          fetch-depth: 0

      - uses: actions/setup-node@v4
        with:
          node-version: 22

      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - uses: Swatinem/rust-cache@v2
        with:
          workspaces: .

      - name: Bump Rust crate version
        id: version
        env:
          BUMP: ${{ inputs.bump }}
        run: echo "version=$(node scripts/bump-versions.mjs "$BUMP")" >> "$GITHUB_OUTPUT"

      - name: Commit release version
        env:
          VERSION: ${{ steps.version.outputs.version }}
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git add Cargo.toml
          git commit -m "chore(release): rust v${VERSION}"
          git push origin HEAD:main

      - name: Validate and package
        run: |
          cargo fmt --all -- --check
          cargo clippy --all-targets -- -D warnings
          cargo test
          cargo package

      - name: Create GitHub Release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          VERSION: ${{ steps.version.outputs.version }}
        run: >-
          gh release create "rust-v${VERSION}"
          target/package/tinyhumans-sdk-${VERSION}.crate
          --target "$(git rev-parse HEAD)"
          --title "Rust SDK v${VERSION}"
          --notes "Rust SDK package for v${VERSION}. GitHub Packages has no Cargo registry, so the .crate artifact is attached here."