name: 🎮️ Demo project
on:
  workflow_call:
    inputs:
      limboai-ref:
        description: A tag, branch or commit hash in the LimboAI repository.
        type: string
        default: master

  workflow_dispatch:
    inputs:
      limboai-ref:
        description: A tag, branch or commit hash in the LimboAI repository.
        type: string
        default: master

jobs:
  package-demo:
    runs-on: ubuntu-latest
    name: Package demo

    steps:
      - name: Clone LimboAI module
        uses: actions/checkout@v4
        with:
          fetch-tags: true
          ref: ${{ inputs.limboai-ref }}

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

      - name: Prepare artifact
        shell: bash
        run: |
          cp {README,LICENSE}.md demo/
          mkdir -p demo/addons/limboai/
          cp -R icons/ demo/addons/limboai/icons
          echo "${LIMBOAI_VERSION}" > demo/version.txt

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        env:
          NAME: limboai+${{env.LIMBOAI_VERSION}}.demo-project
        with:
          name: ${{ env.NAME }}
          path: demo/*
