shithub: candycrisis

ref: ae730c8d493b92bcc630806267532f063bad35f4
dir: /.github/workflows/release-appimage-x86_64.yml/

View raw version
name: Release AppImage x86_64

on: [workflow_dispatch, workflow_call]

env:
  SDL2_VERSION: "2.26.3"
  APPIMAGETOOL_VERSION: "13"
  GAME_SHORTNAME: "CandyCrisis"
  GAME_LONGNAME: "Candy Crisis"

jobs:
  release-appimage-x86_64:
    runs-on: ubuntu-20.04  # Use oldest distro still supported by GitHub to cover the oldest possible glibc
    timeout-minutes: 20

    steps:
      - name: Get CPU count
        run: |
          NPROC=$(python3 -c 'import multiprocessing; print(multiprocessing.cpu_count())')
          echo "NPROC=$NPROC" >> $GITHUB_ENV
          echo CPU count = $NPROC

      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: 'recursive'

      # cf. https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md
      - name: Get build dependencies for SDL from APT  
        run: |
          sudo apt update
          sudo apt install -y libasound2-dev libpulse-dev \
            libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev \
            libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libwayland-dev \
            libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev \
            libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev

      - name: Get SDL source
        run: |
          git clone --depth 1 --branch release-${{ env.SDL2_VERSION }} https://github.com/libsdl-org/SDL

      - name: Configure
        run: cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SDL_FROM_SOURCE=1 -DSTATIC_SDL=1

      - name: Prepare artifact names
        run: |
          GAME_VERSION=$(cat build/version.txt)
          ARTIFACT_NAME="${{env.GAME_SHORTNAME}}-$GAME_VERSION-linux-x86_64.AppImage"
          echo "GAME_VERSION=$GAME_VERSION" >> $GITHUB_ENV
          echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV

      - name: Build
        run: cmake --build build -- -j ${{ env.NPROC }}

      - name: Prepare AppDir
        run: bash packaging/prepare_appimage_appdir.sh build/${{env.GAME_SHORTNAME}}

      - name: Make AppImage
        run: |
          wget https://github.com/AppImage/AppImageKit/releases/download/${{env.APPIMAGETOOL_VERSION}}/appimagetool-x86_64.AppImage
          chmod +x appimagetool-x86_64.AppImage
          ./appimagetool-x86_64.AppImage --no-appstream build/${{env.GAME_SHORTNAME}}.AppDir build/${{env.ARTIFACT_NAME}}

      - name: Upload
        uses: actions/upload-artifact@v3
        with:
          name: ${{env.ARTIFACT_NAME}}
          path: build/${{env.ARTIFACT_NAME}}