name: job_appimage

on:
  workflow_call:
    inputs:
      version:
        required: true
        type: string

jobs:
  build:
    name: Build
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
      - name: Install build dependencies
        run: |
          sudo apt update
          sudo apt install python3 python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace fuse
      - name: Install appimage-builder
        run: |
          sudo wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O /usr/local/bin/appimagetool
          sudo chmod +x /usr/local/bin/appimagetool
          sudo pip3 install appimage-builder
      - name: Build
        run: |
          appimage-builder --skip-test
          mv Rare-*.AppImage Rare.AppImage
          mv Rare-*.AppImage.zsync Rare.AppImage.zsync

      - name: Upload artifact
        uses: actions/upload-artifact@v3
        with:
          name: Rare-${{ inputs.version }}.AppImage
          path: Rare.AppImage
      - name: Upload artifact
        uses: actions/upload-artifact@v3
        with:
          name: Rare-${{ inputs.version }}.AppImage.zsync
          path: Rare.AppImage.zsync