join-ai 0.3.0

A tool to traverse files in a folder and concatenate them into a single text file for GenAI models.
Documentation
name: Release

on:
  release:
    types: [created]

permissions:
  contents: write

jobs:
  create-release-artifacts:
    name: Build Release Artifacts
    if: startsWith(github.event.release.tag_name, 'v')
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-pc-windows-msvc
            os: windows-latest
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

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

      - name: Setup cross-compilation for Linux aarch64
        if: matrix.target == 'aarch64-unknown-linux-gnu'
        run: |
          sudo apt-get update
          sudo apt-get install -y gcc-aarch64-linux-gnu

      - name: Build binary
        run: cargo build --release --target ${{ matrix.target }}
        env:
          CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc

      - name: Prepare artifacts for release
        shell: bash
        run: |
          # Define a clean filename without any path prefixes
          ARTIFACT_FILENAME="join-ai-${{ matrix.target }}"
          EXECUTABLE_PATH="./target/${{ matrix.target }}/release/join-ai"

          if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
            ARTIFACT_FILENAME="${ARTIFACT_FILENAME}.exe"
            mv "${EXECUTABLE_PATH}.exe" "./${ARTIFACT_FILENAME}"
          else
            mv "${EXECUTABLE_PATH}" "./${ARTIFACT_FILENAME}"
          fi

          # Set the asset path for finding the local file
          echo "ASSET_PATH=./${ARTIFACT_FILENAME}" >> $GITHUB_ENV
          # Set a clean asset name for the release upload
          echo "ASSET_NAME=${ARTIFACT_FILENAME}" >> $GITHUB_ENV

      - name: Upload Release Asset
        uses: actions/upload-release-asset@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          upload_url: ${{ github.event.release.upload_url }}
          asset_path: ${{ env.ASSET_PATH }}
          asset_name: ${{ env.ASSET_NAME }}
          asset_content_type: application/octet-stream

  publish-to-crates:
    name: Publish to crates.io
    needs: create-release-artifacts
    if: startsWith(github.event.release.tag_name, 'v')
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

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

      - name: Dry-run publish to crates.io (Pre-release)
        if: github.event.release.prerelease
        run: cargo publish --token ${{ secrets.CARGO_API_TOKEN }} --dry-run

      - name: Publish to crates.io (Full Release)
        if: "!github.event.release.prerelease"
        run: cargo publish --token ${{ secrets.CARGO_API_TOKEN }}