source-map-php 0.1.3

CLI-first PHP code search indexer for Laravel and Hyperf repositories
Documentation
name: ci

on:
  pull_request:
  push:
    branches:
      - main
    tags:
      - "v*"
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: ci-${{ github.ref }}
  cancel-in-progress: true

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2

      - name: Format
        run: cargo fmt --check

      - name: Lint
        run: cargo clippy --locked --all-targets --all-features -- -D warnings

      - name: Test
        run: cargo test --locked --all-targets --all-features

  create-release:
    if: startsWith(github.ref, 'refs/tags/v')
    needs: test
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Create GitHub release
        uses: softprops/action-gh-release@v2
        with:
          generate_release_notes: true
          prerelease: ${{ contains(github.ref_name, '-') }}

  release-assets:
    if: startsWith(github.ref, 'refs/tags/v')
    needs: create-release
    permissions:
      contents: write
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - os: macos-latest
            target: aarch64-apple-darwin
          - os: macos-latest
            target: x86_64-apple-darwin
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4

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

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2

      - name: Build release binary
        run: cargo build --locked --release --target ${{ matrix.target }}

      - name: Package artifact
        shell: bash
        run: |
          asset_dir="dist/source-map-php-${{ github.ref_name }}-${{ matrix.target }}"
          mkdir -p "$asset_dir"
          cp target/${{ matrix.target }}/release/source-map-php "$asset_dir/source-map-php"
          tar -C dist -czf "source-map-php-${{ github.ref_name }}-${{ matrix.target }}.tar.gz" "$(basename "$asset_dir")"

      - name: Upload release artifact
        uses: softprops/action-gh-release@v2
        with:
          files: source-map-php-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
          fail_on_unmatched_files: true
          overwrite_files: true