cless 0.0.2

A less-like terminal pager with tree-sitter syntax highlighting
name: release

on:
  push:
    tags:
      - "v*"
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build:
    name: build (${{ matrix.target }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            cross: true
          - target: x86_64-apple-darwin
            os: macos-13
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-pc-windows-msvc
            os: windows-latest
    steps:
      - uses: actions/checkout@v4

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

      - name: Install cross (linux aarch64)
        if: matrix.cross == true
        run: cargo install cross --locked

      - name: Build
        shell: bash
        run: |
          if [ "${{ matrix.cross }}" = "true" ]; then
            cross build --release --target ${{ matrix.target }}
          else
            cargo build --release --target ${{ matrix.target }}
          fi

      - name: Package
        id: package
        shell: bash
        run: |
          tag="${GITHUB_REF#refs/tags/}"
          if [ -z "$tag" ] || [ "$tag" = "$GITHUB_REF" ]; then
            tag="v0.0.0-dev"
          fi
          name="cless-${tag}-${{ matrix.target }}"
          mkdir "$name"
          if [ "${{ runner.os }}" = "Windows" ]; then
            cp "target/${{ matrix.target }}/release/cless.exe" "$name/"
            cp README.md CLAUDE.md LICENSE-MIT LICENSE-APACHE "$name/" || true
            7z a "${name}.zip" "$name"
            echo "asset=${name}.zip" >> "$GITHUB_OUTPUT"
          else
            cp "target/${{ matrix.target }}/release/cless" "$name/"
            cp README.md CLAUDE.md LICENSE-MIT LICENSE-APACHE "$name/" || true
            tar czf "${name}.tar.gz" "$name"
            echo "asset=${name}.tar.gz" >> "$GITHUB_OUTPUT"
          fi

      - name: Upload to release
        if: startsWith(github.ref, 'refs/tags/')
        uses: softprops/action-gh-release@v2
        with:
          files: ${{ steps.package.outputs.asset }}
          fail_on_unmatched_files: true

      - name: Upload as workflow artifact (manual run)
        if: github.event_name == 'workflow_dispatch'
        uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.target }}
          path: ${{ steps.package.outputs.asset }}