rustchain 0.1.0

Workflow transpilation and execution framework - import LangChain, Airflow, GitHub Actions, and more
Documentation
name: Release Pipeline

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:
    inputs:
      version:
        description: 'Version to release (e.g., v1.0.1)'
        required: true

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  # Pre-flight checks to prevent failures
  preflight:
    name: Pre-flight Checks
    runs-on: ubuntu-latest
    outputs:
      version: ${{ steps.version.outputs.version }}
      should_publish: ${{ steps.checks.outputs.should_publish }}
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0

    - name: Extract version
      id: version
      run: |
        if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
          VERSION="${{ github.event.inputs.version }}"
        else
          VERSION="${GITHUB_REF#refs/tags/}"
        fi
        echo "version=${VERSION}" >> $GITHUB_OUTPUT
        echo "Version: ${VERSION}"

    - name: Setup Rust toolchain
      uses: dtolnay/rust-toolchain@stable

    - name: Cache dependencies
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

    - name: Validate Cargo.toml
      run: |
        echo "๐Ÿ” Validating Cargo.toml..."
        CARGO_VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
        TAG_VERSION="${{ steps.version.outputs.version }}"
        TAG_VERSION_CLEAN="${TAG_VERSION#v}"
        
        echo "Cargo.toml version: ${CARGO_VERSION}"
        echo "Git tag version: ${TAG_VERSION_CLEAN}"
        
        if [[ "${CARGO_VERSION}" != "${TAG_VERSION_CLEAN}" ]]; then
          echo "โŒ Version mismatch: Cargo.toml (${CARGO_VERSION}) != tag (${TAG_VERSION_CLEAN})"
          exit 1
        fi
        echo "โœ… Version validated"

    - name: Check compilation
      run: |
        echo "๐Ÿ”ง Checking compilation..."
        cargo check --all-features --verbose
        echo "โœ… Compilation check passed"

    - name: Run tests
      run: |
        echo "๐Ÿงช Running test suite..."
        cargo test --all-features --verbose
        echo "โœ… Tests passed"

    - name: Check crate package
      run: |
        echo "๐Ÿ“ฆ Validating crate package..."
        cargo package --list | head -20
        cargo package --allow-dirty
        echo "โœ… Package validation passed"

    - name: Security audit
      run: |
        echo "๐Ÿ”’ Running security audit..."
        cargo install cargo-audit || true
        cargo audit || echo "โš ๏ธ Security audit completed with warnings"

    - name: Final validation
      id: checks
      run: |
        echo "โœ… All pre-flight checks passed!"
        echo "๐Ÿš€ Ready for release pipeline"
        echo "should_publish=true" >> $GITHUB_OUTPUT

  # Cross-platform binary builds
  build:
    name: Build ${{ matrix.target }}
    needs: preflight
    if: needs.preflight.outputs.should_publish == 'true'
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            name: rustchain-linux-x64
          - target: x86_64-apple-darwin
            os: macos-latest
            name: rustchain-macos-x64
          - target: aarch64-apple-darwin
            os: macos-latest
            name: rustchain-macos-arm64
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            name: rustchain-windows-x64.exe

    steps:
    - uses: actions/checkout@v4

    - name: Setup Rust toolchain
      uses: dtolnay/rust-toolchain@stable
      with:
        targets: ${{ matrix.target }}

    - name: Cache dependencies
      uses: actions/cache@v3
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}

    - name: Build release binary
      run: |
        echo "๐Ÿ”ง Building for ${{ matrix.target }}..."
        cargo build --release --target ${{ matrix.target }} --verbose
        echo "โœ… Build completed"

    - name: Prepare artifacts
      shell: bash
      run: |
        if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
          cp target/${{ matrix.target }}/release/rustchain.exe ${{ matrix.name }}
        else
          cp target/${{ matrix.target }}/release/rustchain ${{ matrix.name }}
        fi

    - name: Upload artifacts
      uses: actions/upload-artifact@v3
      with:
        name: ${{ matrix.name }}
        path: ${{ matrix.name }}

  # Docker builds
  docker:
    name: Build Docker Images
    needs: preflight
    if: needs.preflight.outputs.should_publish == 'true'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v3

    - name: Login to Docker Hub
      uses: docker/login-action@v3
      with:
        username: ${{ secrets.DOCKER_USERNAME }}
        password: ${{ secrets.DOCKER_PASSWORD }}

    - name: Extract metadata
      id: meta
      uses: docker/metadata-action@v5
      with:
        images: ${{ secrets.DOCKER_USERNAME }}/rustchain
        tags: |
          type=ref,event=tag
          type=raw,value=latest

    - name: Build and push Docker image
      uses: docker/build-push-action@v5
      with:
        context: .
        platforms: linux/amd64,linux/arm64
        push: true
        tags: ${{ steps.meta.outputs.tags }}
        labels: ${{ steps.meta.outputs.labels }}
        cache-from: type=gha
        cache-to: type=gha,mode=max

  # Create GitHub release
  create-release:
    name: Create GitHub Release
    needs: [preflight, build, docker]
    if: always() && needs.preflight.outputs.should_publish == 'true'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Download all artifacts
      uses: actions/download-artifact@v3

    - name: Create release
      uses: softprops/action-gh-release@v1
      with:
        tag_name: ${{ needs.preflight.outputs.version }}
        name: Rustchain ${{ needs.preflight.outputs.version }}
        body: |
          ## ๐Ÿš€ Rustchain ${{ needs.preflight.outputs.version }}
          
          **Cross-platform AI agent framework built in Rust**
          
          ### ๐Ÿ“ฆ Installation
          
          **From crates.io:**
          ```bash
          cargo install rustchain
          ```
          
          **From Docker:**
          ```bash
          docker pull ${{ secrets.DOCKER_USERNAME }}/rustchain:${{ needs.preflight.outputs.version }}
          ```
          
          ### ๐Ÿ”ฝ Downloads
          Choose the binary for your platform below.
          
          ### ๐ŸŒ Links
          - **Website**: https://rustchain.dev
          - **Documentation**: https://docs.rs/rustchain
          - **Docker Hub**: https://hub.docker.com/r/${{ secrets.DOCKER_USERNAME }}/rustchain
        files: |
          rustchain-linux-x64/rustchain-linux-x64
          rustchain-macos-x64/rustchain-macos-x64
          rustchain-macos-arm64/rustchain-macos-arm64
          rustchain-windows-x64.exe/rustchain-windows-x64.exe
        draft: false
        prerelease: false