name: Setup version

runs:
  using: "composite"
  steps:
    - name: Set GDEXTENSION_VERSION & LIMBOAI_VERSION
      shell: bash
      run: |
        cd godot-cpp
        GDEXTENSION_VERSION=$( (git describe --tags --exact-match HEAD || git rev-parse --short HEAD) | sed 's/\(.*\)-\(.*\)/\1/g' )

        if [[ ${GDEXTENSION_VERSION} == godot-* ]]; then
           GDEXTENSION_VERSION=${GDEXTENSION_VERSION#"godot-"}
        fi

        echo "GDEXTENSION_VERSION=${GDEXTENSION_VERSION}" >> "$GITHUB_ENV"

        cd ../limboai
        echo "LIMBOAI_VERSION=$( (git describe --tags --exact-match HEAD || git rev-parse --short HEAD) | sed 's/\(.*\)-\(.*\)/\1.\2/g' )" >> "$GITHUB_ENV"

    - name: Set NAME_PREFIX
      shell: bash
      run: |
        echo "NAME_PREFIX=limboai+${LIMBOAI_VERSION}.gdextension-${GDEXTENSION_VERSION}" >> "$GITHUB_ENV"
