cargo-binutils 0.4.0

Proxy for LLVM tools like llvm-nm, llvm-objdump and llvm-size
Documentation
name: release
on:
  push:
    branches:
      - master
    tags:
      - v*.*.*
  workflow_dispatch:

jobs:
  build:
    strategy:
      matrix:
        include:
          - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest,  suffix: .tar.gz }
          - { target: x86_64-apple-darwin,      os: macos-latest,   suffix: .tar.gz }
          - { target: aarch64-apple-darwin,     os: macos-latest,   suffix: .tar.gz }
          - { target: x86_64-pc-windows-msvc,   os: windows-latest, suffix: .zip    }
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - name: Setup Rust
        shell: bash
        run: |
          rustup toolchain install stable --profile minimal --target ${{ matrix.target }}
          rustup default stable
          echo "::add-matcher::.github/workflows/rust.json"
      - name: Cache Dependencies
        uses: Swatinem/rust-cache@v2
      - run: cargo build --target ${{ matrix.target }} --release

      - name: (Not Windows) Move executables and compress
        if: ${{ matrix.os != 'windows-latest' }}
        run: |
          mkdir ${{ matrix.target }}
          for bin in src/bin/*.rs; do
            mv target/${{ matrix.target }}/release/$(basename $bin .rs) ${{ matrix.target }};
          done
          tar -zcvf ${{ matrix.target }}.tar.gz ${{ matrix.target }}

      - name: (Windows) Move executables and compress
        if: ${{ matrix.os == 'windows-latest' }}
        run: |
          mkdir ${{ matrix.target }}
          $bins = Get-ChildItem -Path src/bin -Recurse -Filter "*.rs"
          foreach ($b in $bins) {
            Move-Item -Path ("target/${{ matrix.target }}/release/" + $b.BaseName + ".exe") -Destination "${{ matrix.target }}/"
          }
          Compress-Archive -Path ${{ matrix.target }} -DestinationPath ${{ matrix.target }}.zip

      - uses: actions/upload-artifact@v4
        with:
          name: ${{ matrix.target }}
          path: ${{ matrix.target }}${{ matrix.suffix }}

  release:
    name: release
    runs-on: ubuntu-latest
    needs: [build]
    steps:
      - uses: actions/checkout@v4
      - uses: actions/download-artifact@v4
        with:
          path: artifacts
      - run: ls -R ./artifacts

      - name: Set current date as environment variable
        run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV

      - id: changelog-reader
        uses: mindsers/changelog-reader-action@v2.2.3
        with:
          version: ${{ (github.ref_type == 'tag' && github.ref_name) || 'Unreleased' }}

      - uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ steps.changelog-reader.outputs.version }}
          name: ${{ (github.ref_type == 'tag' && steps.changelog-reader.outputs.version) || format('Prereleased {0}', env.CURRENT_DATE) }}
          body: ${{ steps.changelog-reader.outputs.changes }}
          prerelease: ${{ steps.changelog-reader.outputs.status == 'unreleased' }}
          files: |
            artifacts/**/*