shithub: candycrisis

ref: 6159713b2a0f55e2cd41797ed7aa3a5a4c0a06a3
dir: /.github/workflows/release.yml/

View raw version
name: Make Release Builds

on: [workflow_dispatch]

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

    steps:
      - name: Checkout
        uses: actions/checkout@v3  # Checks out repository under $GITHUB_WORKSPACE so the job can access it
        with:
          submodules: 'recursive'

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

      - name: Get build dependencies for SDL from APT  # cf. https://github.com/libsdl-org/SDL/blob/main/docs/README-linux.md
        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: Configure
        run: cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo

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

      - name: Prepare AppDir
        run: bash packaging/prepare_appimage_appdir.sh build/CandyCrisis

      - name: Make AppImage
        run: |
          wget https://github.com/AppImage/AppImageKit/releases/download/13/appimagetool-x86_64.AppImage
          chmod +x appimagetool-x86_64.AppImage
          ./appimagetool-x86_64.AppImage --no-appstream build/CandyCrisis.AppDir build/CandyCrisis-linux-x86_64.AppImage

      - name: Upload
        uses: actions/upload-artifact@v3
        with:
          name: CandyCrisis-linux-x86_64.AppImage
          path: build/CandyCrisis-linux-x86_64.AppImage
          
  build-windows:
    runs-on: windows-2022
    timeout-minutes: 20

    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: 'recursive'
          
      - name: Configure
        run: cmake -S . -B build -G 'Visual Studio 17 2022'

      - name: Build
        run: cmake --build build --config Release -- -m

      - name: Copy vcredist
        run: |
          cmake --install build --prefix build/install
          copy build/ReadMe.txt build/Release
          copy build/install/bin/vcruntime140.dll build/Release

      - name: Upload
        uses: actions/upload-artifact@v3
        with:
          name: CandyCrisis-windows-x64
          path: build/Release

  build-macos:
    runs-on: macos-11
    timeout-minutes: 20

    steps:
      - name: Import codesigning certs
        uses: apple-actions/import-codesign-certs@v1
        with:
          p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_BASE64 }}
          p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_PASSWORD }}

      - 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'

      - name: Configure
        run: cmake -S . -B build -G Xcode

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

      - name: Codesign
        run: codesign --force --sign ${{ secrets.APPLE_DEVELOPMENT_TEAM }} --options runtime "build/RelWithDebInfo/Candy Crisis.app"
      
      - name: Create dmg
        run: |
          cp build/ReadMe.txt build/RelWithDebInfo
          hdiutil create -fs HFS+ -srcfolder build/RelWithDebInfo -volname "Candy Crisis" build/CandyCrisis-mac.dmg

      - name: Notarize
        run: |
          xcrun notarytool store-credentials MyNotarizationProfileName --apple-id ${{ secrets.APPLE_NOTARIZATION_USERNAME }} --password ${{ secrets.APPLE_NOTARIZATION_PASSWORD }} --team-id ${{ secrets.APPLE_DEVELOPMENT_TEAM }}
          xcrun notarytool submit build/CandyCrisis-mac.dmg --keychain-profile MyNotarizationProfileName --wait

      - name: Staple
        run: xcrun stapler staple build/CandyCrisis-mac.dmg

      - name: Upload
        uses: actions/upload-artifact@v3
        with:
          name: CandyCrisis-mac.dmg
          path: build/CandyCrisis-mac.dmg