shithub: candycrisis

ref: d6986d5f616a7cd189abb239e2ec2019819cfeb9
dir: /.github/workflows/release-windows.yml/

View raw version
name: Release Windows

on: [workflow_dispatch, workflow_call]

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

jobs:
  release-windows:
    runs-on: windows-2022
    timeout-minutes: 20

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

      - name: Get SDL
        run: |
          Invoke-WebRequest -OutFile SDL2-VC.zip -Uri https://github.com/libsdl-org/SDL/releases/download/release-${{env.SDL2_VERSION}}/SDL2-devel-${{env.SDL2_VERSION}}-VC.zip
          Expand-Archive SDL2-VC.zip
          move SDL2-VC/SDL2-* SDL2

      - name: Configure
        run: cmake -S . -B build -G 'Visual Studio 17 2022'

      - name: Prepare artifact names
        run: |
          $GAME_VERSION = Get-Content build/version.txt
          $FOLDER_NAME = "${{env.GAME_LONGNAME}} $GAME_VERSION"
          $ARTIFACT_NAME = "${{env.GAME_SHORTNAME}}-$GAME_VERSION-windows-x64.zip"
          echo "GAME_VERSION=$GAME_VERSION" >> $env:GITHUB_ENV
          echo "FOLDER_NAME=$FOLDER_NAME" >> $env:GITHUB_ENV
          echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $env:GITHUB_ENV

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

      # Note: if the game contains C++, you should also copy msvcp140.dll and vcruntime140_1.dll
      - name: Copy extra stuff
        run: |
          cmake --install build --prefix build/install
          copy build/ReadMe.txt build/Release
          copy build/install/bin/vcruntime140.dll build/Release

      - name: Zip it up
        run: |
          move build/Release "build/${{env.FOLDER_NAME}}"
          Compress-Archive -Path "build/${{env.FOLDER_NAME}}" -DestinationPath build/${{env.ARTIFACT_NAME}} -CompressionLevel Optimal

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