dataexcept 0.1.0-beta.2

Structured errors and failure observability for data, ML, and data-engineering systems
Documentation
name: Release

on:
  workflow_dispatch:
    inputs:
      version:
        description: Crate version to publish, without the v prefix
        required: true

permissions:
  attestations: write
  contents: write
  id-token: write

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: "-Dwarnings"

jobs:
  publish:
    name: Publish crate
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          ref: main
          fetch-depth: 0

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

      - name: Cache Cargo
        uses: Swatinem/rust-cache@v2

      - name: Install SBOM generator
        run: cargo install cargo-cyclonedx --version 0.5.9 --locked

      - name: Verify release version
        shell: bash
        run: |
          set -euo pipefail
          expected="${{ inputs.version }}"
          actual="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1)"
          test "$actual" = "$expected" || {
            echo "Cargo.toml version is $actual, expected $expected" >&2
            exit 1
          }

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Clippy
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: Test
        run: cargo test --all-features

      - name: Documentation
        run: cargo doc --no-deps --all-features

      - name: Inspect package contents
        run: cargo package --list

      - name: Dry-run publish
        run: cargo publish --dry-run

      - name: Build release package
        env:
          VERSION: ${{ inputs.version }}
        shell: bash
        run: |
          set -euo pipefail
          cargo package
          crate="target/package/dataexcept-$VERSION.crate"
          test -f "$crate"
          sha256sum "$crate" > "$crate.sha256"

      - name: Generate CycloneDX SBOM
        env:
          VERSION: ${{ inputs.version }}
        shell: bash
        run: |
          set -euo pipefail
          cargo cyclonedx \
            --all-features \
            --format json \
            --spec-version 1.5 \
            --override-filename "dataexcept-$VERSION.cdx"
          sbom="dataexcept-$VERSION.cdx.json"
          test -f "$sbom"
          mv "$sbom" "target/package/$sbom"

      - name: Attest release package
        uses: actions/attest@v4
        with:
          subject-path: target/package/dataexcept-${{ inputs.version }}.crate

      - name: Attest release SBOM
        uses: actions/attest@v4
        with:
          subject-path: target/package/dataexcept-${{ inputs.version }}.cdx.json

      - name: Authenticate with crates.io
        id: auth
        uses: rust-lang/crates-io-auth-action@v1

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
        run: cargo publish

      - name: Create release tag
        env:
          VERSION: ${{ inputs.version }}
        shell: bash
        run: |
          set -euo pipefail
          tag="v$VERSION"
          git config user.name "github-actions[bot]"
          git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
          git tag -a "$tag" -m "$tag"
          git push origin "$tag"

      - name: Create GitHub prerelease
        env:
          GH_TOKEN: ${{ github.token }}
          VERSION: ${{ inputs.version }}
        shell: bash
        run: |
          set -euo pipefail
          tag="v$VERSION"
          crate="target/package/dataexcept-$VERSION.crate"
          sbom="target/package/dataexcept-$VERSION.cdx.json"
          gh release create "$tag" \
            "$crate" \
            "$crate.sha256" \
            "$sbom" \
            --prerelease \
            --title "$tag" \
            --generate-notes