shithub: candycrisis

ref: 56f1e92bcab1dad60dad8791428b84a0a4c0453b
dir: /.github/workflows/release-appimage-aarch64.yml/

View raw version
name: Release AppImage aarch64

on: [workflow_dispatch, workflow_call]

env:
  SDL2_VERSION: "2.28.1"
  APPIMAGETOOL_VERSION: "13"
  GAME_SHORTNAME: "candycrisis"
  GAME_LONGNAME: "Candy Crisis"

jobs:
  release-appimage-aarch64:
    runs-on: ubuntu-20.04
    timeout-minutes: 100  # this job may take up to an hour

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

      # Create shared directory ON HOST. (If it's done within qemu, it'll be created with root permissions)
      - name: Create artifacts directory shared with docker
        run: |
          mkdir -p "artifacts"

      # QEMU can't run appimagetool-aarch64, so we have to build the AppImage on x86_64
      - name: Download appimagetool
        run : |
          pushd artifacts
          wget -q https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage
          wget -q https://github.com/AppImage/AppImageKit/releases/download/13/runtime-aarch64
          chmod +x appimagetool-x86_64.AppImage
          chmod +x runtime-aarch64
          popd

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

      - uses: uraimo/run-on-arch-action@v2
        name: Build game via QEMU
        id: buildgame
        with:
          arch: aarch64

          # Distro must be kept in sync with `runs-on` above.
          # See: https://github.com/uraimo/run-on-arch-action#supported-platforms
          distro: ubuntu20.04

          # (Optional) Speeds up builds by storing container images in a GitHub package registry.
          githubToken: ${{ github.token }}

          # Mount the artifacts directory as /artifacts in the container
          dockerRunArgs: |
            --volume "${PWD}/artifacts:/artifacts"

          # Install build tools for the game and SDL build dependencies.
          # See: https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md (last updated for SDL 2.26.0)
          install: |
            apt update -y
            apt install -y build-essential cmake
            #apt install -y libsdl2-dev  #----- for quick testing
            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

          # Build the aarch64 version under dist/, then tar it up and move the tarball to /artifacts.
          # (We're not building directly in /artifacts as this would cause permission issues when moving back to the x86_64 host)
          run: |
            #cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo  #----- for quick testing
            cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_SDL_FROM_SOURCE=1 -DSTATIC_SDL=1
            cmake --build build
            bash packaging/prepare_appimage_appdir.sh build/${{env.GAME_SHORTNAME}}
            cd build
            tar cvf /artifacts/aarch64-dist.tar ./*.AppDir ./version.txt

      # QEMU can't run appimagetool-aarch64, so we have to build the AppImage on x86_64
      - name: Create AppImage on x86_64 host
        run: |
          cd artifacts
          tar xvf aarch64-dist.tar

          GAME_VERSION=$(cat version.txt)
          ARTIFACT_NAME="${{env.GAME_SHORTNAME}}-$GAME_VERSION-linux-aarch64.AppImage"
          echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV

          APPIMAGE_INPUT=$(ls -d --indicator-style=none *.AppDir)
          ./appimagetool-x86_64.AppImage -v --runtime-file runtime-aarch64 --no-appstream $APPIMAGE_INPUT $ARTIFACT_NAME

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