name: Setup Breakpad Dump Symbols
description: Sets up + builds the dump_syms utility from Breakpad

inputs:
  dump_syms_version:
    description: "Revision of mozilla/dump_syms repository to fetch"
    required: true
    default: "v2.3.3"
outputs:
  binary-path:
    description: "Path of the dump_syms utility, including the executable."
    value: ${{ steps.get-path.outputs.binary-path }}

runs:
  using: "composite"
  steps:
  - uses: dtolnay/rust-toolchain@stable
    id: toolchain

  - uses: actions/cache@v4
    id: binary-cache
    with:
      path: "./dump_syms/target/release/dump_syms"
      key: dump_syms-${{ inputs.dump_syms_version }}-${{steps.toolchain.outputs.cachekey}}

  - uses: actions/checkout@v4
    if: steps.binary-cache.outputs.cache-hit != 'true'
    with:
      repository: "mozilla/dump_syms"
      ref: ${{ inputs.dump_syms_version }}
      path: "./dump_syms"

  - run: cargo build --release
    shell: bash
    if: steps.binary-cache.outputs.cache-hit != 'true'
    working-directory: "./dump_syms"

  - run: echo "binary-path=$(realpath target/release/dump_syms)" >> "$GITHUB_OUTPUT"
    shell: bash
    id: get-path
    working-directory: "./dump_syms"