scribe-cli 0.5.1

Advanced code analysis and repository exploration library with AI-powered insights
Documentation
name: Release

on:
  push:
    tags:
      - 'v*.*.*'
  workflow_dispatch:
    inputs:
      tag:
        description: 'Tag to release'
        required: true
        type: string

env:
  CARGO_TERM_COLOR: always
  RUST_BACKTRACE: 1

jobs:
  create-release:
    name: Create Release
    runs-on: ubuntu-latest
    outputs:
      upload_url: ${{ steps.create_release.outputs.upload_url }}
      version: ${{ steps.get_version.outputs.version }}
    steps:
    - name: Checkout code
      uses: actions/checkout@v4
      
    - name: Get version from tag
      id: get_version
      run: |
        if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
          VERSION="${{ github.event.inputs.tag }}"
        else
          VERSION=${GITHUB_REF#refs/tags/}
        fi
        echo "version=${VERSION}" >> $GITHUB_OUTPUT
        echo "Version: ${VERSION}"
        
    - name: Create Release
      id: create_release
      uses: actions/create-release@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tag_name: ${{ steps.get_version.outputs.version }}
        release_name: Release ${{ steps.get_version.outputs.version }}
        draft: false
        prerelease: ${{ contains(steps.get_version.outputs.version, '-') }}
        body: |
          Release ${{ steps.get_version.outputs.version }}
          
          ## What's Changed
          
          - See commit history for detailed changes
          
          ## Installation
          
          ### From Source
          ```bash
          cargo install --git https://github.com/sibyllinesoft/scribe --tag ${{ steps.get_version.outputs.version }}
          ```
          
          ### Pre-built Binaries
          Download the appropriate binary for your platform from the assets below.

  build:
    name: Build Release Binaries
    needs: create-release
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            name: scribe-linux-x86_64
            
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            name: scribe-linux-x86_64-musl
            
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            name: scribe-windows-x86_64.exe
            
          - target: x86_64-apple-darwin
            os: macos-latest
            name: scribe-macos-x86_64
            
          - target: aarch64-apple-darwin
            os: macos-latest
            name: scribe-macos-aarch64
            
    runs-on: ${{ matrix.os }}
    steps:
    - name: Checkout code
      uses: actions/checkout@v4
      
    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@stable
      with:
        targets: ${{ matrix.target }}
        
    - name: Install musl tools (Linux musl only)
      if: matrix.target == 'x86_64-unknown-linux-musl'
      run: sudo apt-get update && sudo apt-get install -y musl-tools
      
    - name: Cache Cargo registry
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-${{ matrix.target }}-release-cargo-${{ hashFiles('**/Cargo.lock') }}
        restore-keys: |
          ${{ runner.os }}-${{ matrix.target }}-release-cargo-
          
    - name: Build release binary
      run: |
        cargo build --release --target ${{ matrix.target }} --bin scribe
        
    - name: Strip binary (Unix)
      if: matrix.os != 'windows-latest'
      run: |
        if [[ "${{ matrix.target }}" == *"musl"* ]]; then
          strip target/${{ matrix.target }}/release/scribe
        elif [[ "${{ runner.os }}" == "Linux" ]]; then
          strip target/${{ matrix.target }}/release/scribe
        elif [[ "${{ runner.os }}" == "macOS" ]]; then
          strip target/${{ matrix.target }}/release/scribe
        fi
        
    - name: Create archive (Unix)
      if: matrix.os != 'windows-latest'
      run: |
        cd target/${{ matrix.target }}/release
        tar czf ../../../${{ matrix.name }}.tar.gz scribe
        cd ../../..
        
    - name: Create archive (Windows)
      if: matrix.os == 'windows-latest'
      run: |
        cd target/${{ matrix.target }}/release
        7z a ../../../${{ matrix.name }}.zip scribe.exe
        cd ../../..
        
    - name: Upload Release Asset (Unix)
      if: matrix.os != 'windows-latest'
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ needs.create-release.outputs.upload_url }}
        asset_path: ./${{ matrix.name }}.tar.gz
        asset_name: ${{ matrix.name }}.tar.gz
        asset_content_type: application/gzip
        
    - name: Upload Release Asset (Windows)
      if: matrix.os == 'windows-latest'
      uses: actions/upload-release-asset@v1
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        upload_url: ${{ needs.create-release.outputs.upload_url }}
        asset_path: ./${{ matrix.name }}.zip
        asset_name: ${{ matrix.name }}.zip
        asset_content_type: application/zip

  publish-crates:
    name: Publish to crates.io
    needs: [create-release, build]
    runs-on: ubuntu-latest
    if: ${{ !contains(needs.create-release.outputs.version, '-') }} # Only for non-prerelease
    steps:
    - name: Checkout code
      uses: actions/checkout@v4
      
    - name: Install Rust toolchain
      uses: dtolnay/rust-toolchain@stable
      
    - name: Cache Cargo registry
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ubuntu-publish-cargo-${{ hashFiles('**/Cargo.lock') }}
        restore-keys: |
          ubuntu-publish-cargo-
          
    - name: Login to crates.io
      run: cargo login ${{ secrets.CRATES_IO_TOKEN }}
      
    - name: Verify package
      run: cargo package --workspace --allow-dirty
      
    - name: Publish workspace packages
      run: |
        # Publish workspace packages in dependency order
        # Core first
        cd scribe-core && cargo publish --allow-dirty
        cd ../scribe-analysis && cargo publish --allow-dirty
        cd ../scribe-graph && cargo publish --allow-dirty
        cd ../scribe-scanner && cargo publish --allow-dirty
        cd ../scribe-patterns && cargo publish --allow-dirty
        cd ../scribe-selection && cargo publish --allow-dirty
        cd ../scribe-scaling && cargo publish --allow-dirty
        cd ..
        
        # Wait for packages to be available
        sleep 60
        
        # Publish main package
        cargo publish --allow-dirty

  docker:
    name: Build and Push Docker Image
    needs: [create-release, build]
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      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: sibyllinesoft/scribe
        tags: |
          type=ref,event=tag
          type=semver,pattern={{version}}
          type=semver,pattern={{major}}.{{minor}}
          type=semver,pattern={{major}}
          
    - name: Build and push Docker image
      uses: docker/build-push-action@v5
      with:
        context: .
        push: true
        tags: ${{ steps.meta.outputs.tags }}
        labels: ${{ steps.meta.outputs.labels }}
        platforms: linux/amd64,linux/arm64
        cache-from: type=gha
        cache-to: type=gha,mode=max

  release-summary:
    name: Release Summary
    runs-on: ubuntu-latest
    needs: [create-release, build, publish-crates, docker]
    if: always()
    steps:
    - name: Release summary
      run: |
        echo "## Release ${{ needs.create-release.outputs.version }} Summary" >> $GITHUB_STEP_SUMMARY
        echo "" >> $GITHUB_STEP_SUMMARY
        echo "| Component | Status |" >> $GITHUB_STEP_SUMMARY
        echo "|-----------|---------|" >> $GITHUB_STEP_SUMMARY
        echo "| Release Created | ${{ needs.create-release.result == 'success' && '✅ Success' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
        echo "| Binaries Built | ${{ needs.build.result == 'success' && '✅ Success' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
        echo "| Crates.io Publish | ${{ needs.publish-crates.result == 'success' && '✅ Success' || (needs.publish-crates.result == 'skipped' && '⏭️ Skipped (prerelease)' || '❌ Failed') }} |" >> $GITHUB_STEP_SUMMARY
        echo "| Docker Image | ${{ needs.docker.result == 'success' && '✅ Success' || '❌ Failed' }} |" >> $GITHUB_STEP_SUMMARY
        echo "" >> $GITHUB_STEP_SUMMARY
        echo "🚀 Release ${{ needs.create-release.outputs.version }} completed!" >> $GITHUB_STEP_SUMMARY