name: Latest release

on:
  workflow_call:
    inputs:
      owner:
        type: string
        description: Owner of the repo
        default: lf-lang
      repo:
        type: string
        description: Repo to find the latest release of
        default: lingua-franca
    outputs:
      ref:
        description: "The tag of the latest release"
        value: ${{ jobs.get-latest-release.outputs.ref }}
      ver:
        description: "The semver of the latest release (without a leading 'v')"
        value: ${{ jobs.get-latest-release.outputs.ver }}

  workflow_dispatch:
    inputs:
      owner:
        type: string
        description: Owner of the repo
        default: lf-lang
      repo:
        type: string
        description: Repo to find the latest release of
        default: lingua-franca

jobs:
  get-latest-release:
    runs-on: ubuntu-24.04
    outputs:
      ref: ${{ steps.semver.outputs.ref }}
      ver: ${{ steps.semver.outputs.ver }}
    steps:
      - name: Check out repository
        uses: actions/checkout@v3
        with:
          repository: ${{ github.event.inputs.owner || inputs.owner }}/${{ github.event.inputs.repo || inputs.repo }}
      - id: semver
        uses: lf-lang/lingua-franca/.github/actions/latest-release@master
