#i was on the verge of killing myself while writing this build script (they have my family please help)
name: Build Installer

on:
  push:
    branches:
      - main

env:
  ACTIONS_ALLOW_UNSECURE_COMMANDS: true  # allow fortnite wallhacks 

jobs:
  build:
    runs-on: windows-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Install MSVC
        uses: microsoft/setup-msbuild@v1.0.0

      - name: Download and install Vcpkg
        run: |
          git clone https://github.com/microsoft/vcpkg.git
          cd vcpkg
          .\bootstrap-vcpkg.bat
          .\vcpkg.exe integrate install
        working-directory: ${{ github.workspace }}

      - name: Install Vcpkg dependencies
        run: |
          ${{ github.workspace }}/vcpkg/vcpkg.exe install nlohmann-json:x64-windows

      - name: Build Installer
        run: |
          msbuild /p:Configuration=Release /p:Platform=x64 /m installer.sln
        working-directory: ${{ github.workspace }}

      - name: Set MSBuild path
        run: |
          echo "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin" >> $GITHUB_PATH
        shell: cmd

      - name: Create Release Artifact
        uses: actions/upload-artifact@v2
        with:
          name: millennium-installer
          path: ${{ github.workspace }}/dist/installer-prod.Release-x64Windows/millennium.exe  # Use the new build path