name: AppImage

on:
  push:
  pull_request:

jobs:
  build:
    runs-on: ubuntu-20.04
    container:
      image: amd64/ubuntu:20.04
      # So that fuse works inside the container (needed to run AppImages.)
      options: --privileged

    env:
      CC: gcc-9
      CXX: g++-9

    steps:
      - run: apt update

      - name: Install deps
        run: DEBIAN_FRONTEND=noninteractive apt install -y
          build-essential
          cmake
          fuse
          git
          grep
          libfontconfig1-dev
          libfreetype-dev
          libjpeg-dev
          libsdl2-mixer-dev
          libspeechd-dev
          patchelf
          qtbase5-dev
          qtbase5-dev-tools
          wget

      - uses: actions/checkout@v2

      - name: Build AppImage
        run: |
          echo $(date +"%Y%m%d").$(echo $GITHUB_SHA | cut -b 1-7) > VERSION
          ./gargoyle-appimage.sh

      - name: Upload AppImage
        if: github.event_name != 'pull_request'
        uses: actions/upload-artifact@v2
        with:
          name: Gargoyle-x86_64.AppImage
          path: Gargoyle-x86_64.AppImage
