# This workflow sets up and runs MSBuild and VSTest
# to build and test a Visual Studio solution.

name: Nightly Build Windows32 GDI

on: [push]

jobs:
  winGDI-32:
   runs-on: windows-latest
   steps:
    - name: Setup MSBuild and add to PATH
      uses: microsoft/setup-msbuild@v2

    - name: Checkout code
      uses: actions/checkout@v6
      id: checkout_code

    - name: Make NSIS
      shell: pwsh
      run:
        ./.github/prepare-nsis.ps1

    - name: Run MSBuild
      shell: pwsh
      working-directory: ${{env.GITHUB_WORKSPACE}}
      run: |
        git clone https://github.com/Microsoft/vcpkg.git
        cd vcpkg
        ./bootstrap-vcpkg.bat
        ./vcpkg integrate install
        cd ..
        msbuild /m .\Simutrans-GDI.vcxproj -p:Configuration=Release /p:platform=Win32

    - name: Build zipfile
      shell: pwsh
      run: |
        move-item "build/GDI/Simutrans GDI Nightly.exe" "simutrans/simutrans.exe"
        move-item "src\Windows\nsis\download-paksets.exe" "simutrans/download-pakset.exe"
        tools/get_lang_files.ps1
        Compress-Archive -Path simutrans -DestinationPath "simuwin-gdi32-nightly.zip"
        dir

    - name: Update binaries of Nightly Release
      uses: svenstaro/upload-release-action@v2
      with:
        repo_token: ${{ secrets.GITHUB_TOKEN }}
        file: ./simuwin-gdi32-nightly.zip
        asset_name: simuwin-gdi32-nightly.zip
        tag: Nightly
        overwrite: true
