tetration 0.1.9

Chunked tensor .tet format, tet CLI, and optional C ABI (tetration-ffi)
Documentation
name: Release

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:

permissions:
  contents: write

jobs:
  ffi-artifacts:
    name: FFI libs (${{ matrix.platform }})
    if: startsWith(github.ref, 'refs/tags/')
    runs-on: ${{ matrix.runner }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - runner: ubuntu-latest
            platform: linux-x86_64
          - runner: macos-latest
            platform: macos-aarch64
          - runner: windows-latest
            platform: windows-x86_64
    steps:
      - name: Checkout
        uses: actions/checkout@v6

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: '1.95'

      - name: Package FFI release archive
        shell: bash
        env:
          TAG: ${{ github.ref_name }}
          PLATFORM: ${{ matrix.platform }}
        run: bash .github/scripts/package-ffi-release.sh

      - name: Upload FFI archive
        uses: actions/upload-artifact@v4
        with:
          name: ffi-${{ matrix.platform }}
          path: dist/tetration-ffi-*.tar.gz
          if-no-files-found: error

  release:
    name: Create draft GitHub release
    needs: ffi-artifacts
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    steps:
      - name: Download FFI archives
        uses: actions/download-artifact@v4
        with:
          pattern: ffi-*
          path: release-assets
          merge-multiple: true

      - name: Create draft release with FFI assets
        uses: softprops/action-gh-release@v3
        with:
          name: Release ${{ github.ref_name }}
          tag_name: ${{ github.ref_name }}
          draft: true
          generate_release_notes: true
          files: release-assets/*.tar.gz
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  bump-homebrew-formula:
    name: Bump Homebrew formula
    runs-on: ubuntu-latest
    # workflow_dispatch has no tag — tarball URL would be wrong.
    if: startsWith(github.ref, 'refs/tags/')
    steps:
      - name: Checkout main
        uses: actions/checkout@v6
        with:
          ref: main
          fetch-depth: 0

      - name: Update Formula/tetration.rb (url + sha256)
        env:
          TAG: ${{ github.ref_name }}
          REPO: ${{ github.repository }}
        run: python3 .github/scripts/bump-homebrew-formula.py

      # Plain `git commit` is unsigned; main requires verified signatures.
      - name: Commit and push (verified)
        uses: iarekylew00t/verified-bot-commit@v2
        with:
          ref: main
          message: "brew: bump formula to ${{ github.ref_name }}"
          files: |
            Formula/tetration.rb
          if-no-commit: info

  publish:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v6

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: '1.95'

      - name: Install HDF5 and NetCDF (Ubuntu)
        run: |
          sudo apt-get update
          sudo apt-get install -y libhdf5-dev libnetcdf-dev pkg-config

      - uses: rust-lang/crates-io-auth-action@v1
        id: auth

      - run: cargo publish --locked
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}