ai-context-gen 0.1.2

A context generator for Rust repositories that creates structured markdown files with relevant information for LLMs and AI agents
Documentation
name: Release

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

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  # Test before release
  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install Rust
      uses: dtolnay/rust-toolchain@stable
    - name: Cache cargo
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
    - name: Run tests
      run: cargo test --verbose
    - name: Run clippy
      run: cargo clippy -- -D warnings
    - name: Check formatting
      run: cargo fmt --all -- --check

  # Build binaries for different platforms
  build:
    name: Build
    needs: test
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
            name: ai-context-gen-linux-x86_64.tar.gz
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            name: ai-context-gen-linux-musl-x86_64.tar.gz
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            name: ai-context-gen-linux-aarch64.tar.gz
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v4
    - name: Install Rust
      uses: dtolnay/rust-toolchain@stable
      with:
        targets: ${{ matrix.target }}
    - name: Install cross-compilation tools
      if: matrix.target == 'aarch64-unknown-linux-gnu'
      run: |
        sudo apt-get update
        sudo apt-get install -y gcc-aarch64-linux-gnu
    - name: Install musl tools
      if: matrix.target == 'x86_64-unknown-linux-musl'
      run: |
        sudo apt-get update
        sudo apt-get install -y musl-tools
    - name: Setup cross-compilation linker
      if: matrix.target == 'aarch64-unknown-linux-gnu'
      run: |
        # Ensure .cargo/config.toml exists with correct linker configuration
        mkdir -p .cargo
        if [ ! -f .cargo/config.toml ]; then
          echo '[target.aarch64-unknown-linux-gnu]' > .cargo/config.toml
          echo 'linker = "aarch64-linux-gnu-gcc"' >> .cargo/config.toml
        fi
    - name: Cache cargo
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
    - name: Build binary
      run: cargo build --release --target ${{ matrix.target }}
    - name: Package binary
      run: |
        cd target/${{ matrix.target }}/release
        tar czf ../../../${{ matrix.name }} ai-context-gen
        cd -
    - name: Upload binary
      uses: actions/upload-artifact@v4
      with:
        name: ${{ matrix.name }}
        path: ${{ matrix.name }}

  # Create GitHub release
  release:
    name: Create Release
    needs: [test, build]
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Download all artifacts
      uses: actions/download-artifact@v4
    - name: Get version from tag
      id: get_version
      run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
    - name: Extract changelog entry
      id: changelog
      run: |
        # Extract the changelog entry for this version
        VERSION="${{ steps.get_version.outputs.VERSION }}"
        CHANGELOG_ENTRY=$(awk "/^### $VERSION/{flag=1; next} /^### /{flag=0} flag" README.md)
        echo "CHANGELOG_ENTRY<<EOF" >> $GITHUB_OUTPUT
        echo "$CHANGELOG_ENTRY" >> $GITHUB_OUTPUT
        echo "EOF" >> $GITHUB_OUTPUT
    - name: Create Release
      id: create_release
      uses: softprops/action-gh-release@v1
      with:
        tag_name: ${{ steps.get_version.outputs.VERSION }}
        name: ${{ steps.get_version.outputs.VERSION }}
        body: |
          ## What's Changed
          
          ${{ steps.changelog.outputs.CHANGELOG_ENTRY }}
          
          ## Installation
          
          ### Download Binary
          Download the appropriate binary for your platform from the assets below.
          
          ### From Source
          ```bash
          git clone https://github.com/brbtavares/ai-context-gen
          cd ai-context-gen
          git checkout ${{ steps.get_version.outputs.VERSION }}
          make install
          ```
          
          ### As Library
          ```toml
          [dependencies]
          ai-context-gen = "${{ steps.get_version.outputs.VERSION }}"
          ```
        files: |
          ai-context-gen-linux-x86_64.tar.gz/ai-context-gen-linux-x86_64.tar.gz
          ai-context-gen-linux-musl-x86_64.tar.gz/ai-context-gen-linux-musl-x86_64.tar.gz
          ai-context-gen-linux-aarch64.tar.gz/ai-context-gen-linux-aarch64.tar.gz
        draft: false
        prerelease: false

  # Publish to crates.io
  # Note: CRATES_IO_TOKEN secret must be configured in GitHub repository settings
  # Go to: Settings > Secrets and variables > Actions > New repository secret
  # Name: CRATES_IO_TOKEN, Value: your crates.io API token
  publish:
    name: Publish to crates.io
    needs: [test, build]
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4
    - name: Install Rust
      uses: dtolnay/rust-toolchain@stable
    - name: Cache cargo
      uses: actions/cache@v4
      with:
        path: |
          ~/.cargo/registry
          ~/.cargo/git
          target
        key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
    - name: Publish to crates.io
      run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }}