name: Latest release
description: Report the latest release of the current repo
outputs:
  ref:
    value: ${{ steps.find.outputs.ref }}
    description: The latest semver tag
  ver:
    value: ${{ steps.find.outputs.ver }}
    description: The semver corresponding to the latest semver tag

runs:
  using: "composite"
  steps:
    - name: Install semver-tool
      run: |
        wget -O /usr/local/bin/semver https://raw.githubusercontent.com/fsaintjacques/semver-tool/master/src/semver
        chmod +x /usr/local/bin/semver
        semver --version
      shell: bash
    - name: Fetch all tags
      run: git fetch --all --tags
      shell: bash
    - name: Fetch latest-release script
      run: |
        wget https://raw.githubusercontent.com/lf-lang/lingua-franca/master/.github/scripts/latest-release.sh
        chmod +x latest-release.sh
      shell: bash
    - name: Find the latest release
      id: find
      run: |
        export tag=$(./latest-release.sh)
        echo  "ref=${tag}" >> $GITHUB_OUTPUT
        shopt -s extglob
        export ver="${tag##v}"
        echo  "ver=${ver}" >> $GITHUB_OUTPUT
        echo "Latest release tag: ${tag}"
        echo "Without a leading 'v': ${ver}"
      shell: bash
