shithub: candycrisis

ref: 9acc208ae7427727a736faf0fe971756a34ae019
dir: /.github/workflows/release-aarch64.yml/

View raw version
name: Make Release Builds (linux/aarch64)

on: [workflow_dispatch]

jobs:
  build-linux-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

      - 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 it 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
            cmake --build build
            bash packaging/prepare_appimage_appdir.sh build/CandyCrisis
            cd build
            tar cvf /artifacts/aarch64-dist.tar ./*.AppDir

      # 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

          APPIMAGE_INPUT=$(ls -d --indicator-style=none *.AppDir)
          APPIMAGE_OUTPUT=${APPIMAGE_INPUT%.AppDir}.AppImage
          echo "APPIMAGE_OUTPUT=$APPIMAGE_OUTPUT" >> $GITHUB_ENV

          ./appimagetool-x86_64.AppImage -v --runtime-file runtime-aarch64 --no-appstream $APPIMAGE_INPUT $APPIMAGE_OUTPUT

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