name: Build Meshy AppImage

on:
  workflow_dispatch:

jobs:
  build-appimage:
    runs-on: linux-64
    container:
      image: node:20-bookworm
    steps:
      - name: Check out repository
        uses: https://data.forgejo.org/actions/checkout@v4

      - name: Install system dependencies
        run: |
          apt-get update
          DEBIAN_FRONTEND=noninteractive apt-get install -y \
            appstream \
            build-essential \
            curl \
            desktop-file-utils \
            gettext \
            gobject-introspection \
            libadwaita-1-dev \
            libgeoclue-2-dev \
            libgirepository1.0-dev \
            libglib2.0-dev \
            libgstreamer-plugins-base1.0-dev \
            libgstreamer1.0-dev \
            libgtk-4-dev \
            libshumate-dev \
            libzbar-dev \
            meson \
            ninja-build \
            pkg-config \
            python3 \
            python3-cairo \
            python3-dev \
            python3-gi \
            python3-venv

      - name: Install uv
        run: curl -LsSf https://astral.sh/uv/install.sh | sh

      - name: Sync Python dependencies
        run: |
          export PATH="$HOME/.local/bin:$PATH"
          uv sync --python /usr/bin/python3 --dev

      - name: Build AppImage
        run: |
          export PATH="$HOME/.local/bin:$PATH"
          # build-appimage.sh runs downloaded linuxdeploy AppImages with APPIMAGE_EXTRACT_AND_RUN=1
          # so Forgejo CI does not need FUSE or /dev/fuse access.
          uv run ./build-aux/appimage/build-appimage.sh --download-tools

      - name: Show build output
        run: ls -la dist/
