diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..811df5dbc --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,130 @@ +name: Build + +on: + push: + branches: + - 'master' + - 'develop' + - 'github-action' + paths: + - '.github/workflows/build.yml' + - 'action.yml' + +jobs: + Build: + runs-on: windows-2019 + steps: + +# - name: Install Windows XP Support for Visual Studio 2022 # windows-2022 # v141_xp # Installation takes more than 5 minutes +# run: | +# Set-Location "C:\Program Files (x86)\Microsoft Visual Studio\Installer\" +# $InstallPath = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise" +# $componentsToAdd = @( +# "Microsoft.VisualStudio.Component.WinXP" +# ) +# [string]$workloadArgs = $componentsToAdd | ForEach-Object {" --add " + $_} +# $Arguments = ('/c', "vs_installer.exe", 'modify', '--installPath', "`"$InstallPath`"",$workloadArgs, '--quiet', '--norestart', '--nocache') +# $process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru -WindowStyle Hidden +# if ($process.ExitCode -eq 0) +# { +# Write-Host "components have been successfully added" +# Get-ChildItem C:\ProgramData\Microsoft\VisualStudio\Packages\Microsoft.Windows.XPSupport.* +# } +# else +# { +# Write-Host "components were not installed" +# exit 1 +# } + + - name: Clone cnc-ddraw + uses: actions/checkout@v4 + + - name: Release build + id: build-release + uses: ./ + with: + release: true + + - name: ReleaseWin2000 build + id: build-releasewin2000 + uses: ./ + with: + releasewin2000: true + + - name: Debug build + id: build-debug + uses: ./ + with: + debug: true + + - name: DebugLog build + id: build-debuglog + uses: ./ + with: + debuglog: true + + - name: DebugLogMini build + id: build-debuglogmini + uses: ./ + with: + debuglogmini: true + + - name: Prepare artifact + run: | + : + + mkdir -p cnc-ddraw-release + mkdir -p cnc-ddraw-releasewin2000 + mkdir -p cnc-ddraw-debug + mkdir -p cnc-ddraw-debuglog + mkdir -p cnc-ddraw-debuglogmini + + cp "${{ steps.build-release.outputs.release }}" cnc-ddraw-release + + cp "${{ steps.build-releasewin2000.outputs.releasewin2000 }}" cnc-ddraw-releasewin2000 + + cp "${{ steps.build-debug.outputs.debug }}" cnc-ddraw-debug + cp "${{ steps.build-debug.outputs.debug-pdb }}" cnc-ddraw-debug + + cp "${{ steps.build-debuglog.outputs.debuglog }}" cnc-ddraw-debuglog + cp "${{ steps.build-debuglog.outputs.debuglog-pdb }}" cnc-ddraw-debuglog + + cp "${{ steps.build-debuglogmini.outputs.debuglogmini }}" cnc-ddraw-debuglogmini + cp "${{ steps.build-debuglogmini.outputs.debuglogmini-pdb }}" cnc-ddraw-debuglogmini + + shell: bash + + - name: Upload artifacts cnc-ddraw-release + uses: actions/upload-artifact@v4 + with: + name: cnc-ddraw-release + path: cnc-ddraw-release + retention-days: 14 + + - name: Upload artifacts cnc-ddraw-releasewin2000 + uses: actions/upload-artifact@v4 + with: + name: cnc-ddraw-releasewin2000 + path: cnc-ddraw-releasewin2000 + retention-days: 14 + + - name: Upload artifacts cnc-ddraw-debug + uses: actions/upload-artifact@v4 + with: + name: cnc-ddraw-debug + path: cnc-ddraw-debug + retention-days: 14 + + - name: Upload artifacts cnc-ddraw-debuglog + uses: actions/upload-artifact@v4 + with: + name: cnc-ddraw-debuglog + path: cnc-ddraw-debuglog + retention-days: 14 + + - name: Upload artifacts cnc-ddraw-debuglogmini + uses: actions/upload-artifact@v4 + with: + name: cnc-ddraw-debuglogmini + path: cnc-ddraw-debuglogmini + retention-days: 14 diff --git a/action.yml b/action.yml new file mode 100644 index 000000000..0b1e1cc3c --- /dev/null +++ b/action.yml @@ -0,0 +1,198 @@ +#name: 'sfall' +#description: 'Builds sfall binaries' +#author: '@wipe2238' + +### +# +# Example: +# +# - name: Build sfall +# id: sfall +# uses: phobos2077/sfall@develop +# with: +# release-xp: true +# +# - name: Copy sfall to mod directory +# run: copy "${{ steps.sfall.outputs.release-xp }}" "my/mod/directory/ddraw.dll" +# +### + +# While both inputs are marked as required, users needs to set only one of them (at minimum) to 'true' for action to work +inputs: + + release: + description: 'Set to true to enable building with Release configuration' + required: true + + releasewin2000: + description: 'Set to true to enable building with ReleaseWin2000 configuration' + required: true + + debug: + description: 'Set to true to enable building with Debug configuration' + required: true + + debuglog: + description: 'Set to true to enable building with DebugLog configuration' + required: true + + debuglogmini: + description: 'Set to true to enable building with DebugLogMini configuration' + required: true + +# Outputs are always using Windows directory separator (`\`) +outputs: + + release: + description: 'Full path to ddraw.dll built with Release configuration' + value: ${{ steps.build-release.outputs.ddraw-dll }} + + releasewin2000: + description: 'Full path to ddraw.dll built with ReleaseWin2000 configuration' + value: ${{ steps.build-releasewin2000.outputs.ddraw-dll }} + + debug: + description: 'Full path to ddraw.dll built with Debug configuration' + value: ${{ steps.build-debug.outputs.ddraw-dll }} + debug-pdb: + description: 'Full path to ddraw.pdb built with Debug configuration' + value: ${{ steps.build-debug.outputs.ddraw-pdb }} + + debuglog: + description: 'Full path to ddraw.dll built with DebugLog configuration' + value: ${{ steps.build-debuglog.outputs.ddraw-dll }} + debuglog-pdb: + description: 'Full path to ddraw.pdb built with DebugLog configuration' + value: ${{ steps.build-debuglog.outputs.ddraw-pdb }} + + debuglogmini: + description: 'Full path to ddraw.dll built with DebugLogMini configuration' + value: ${{ steps.build-debuglogmini.outputs.ddraw-dll }} + debuglogmini-pdb: + description: 'Full path to ddraw.pdb built with DebugLogMini configuration' + value: ${{ steps.build-debuglogmini.outputs.ddraw-pdb }} + +runs: + using: 'composite' + steps: + + # Quick check for things which should never happen + - name: Sanity checks + run: | + if [[ "${{ runner.os }}" != "Windows" ]]; then + echo "[ERROR] This action can only be used on Windows" + exit 1 + elif [[ "${{ inputs.release }}" != "true" ]] && [[ "${{ inputs.releasewin2000 }}" != "true" ]] && [[ "${{ inputs.debug }}" != "true" ]] && [[ "${{ inputs.debuglog }}" != "true" ]] && [[ "${{ inputs.debuglogmini }}" != "true" ]]; then + echo "[ERROR] At least one of following inputs must be set to 'true' -- 'release', 'releasewin2000', 'debug', 'debuglog', 'debuglogmini'" + exit 1 + # + elif [[ ! -f "$(cygpath --unix "$GITHUB_ACTION_PATH/cnc-ddraw.sln")" ]]; then + echo "[ERROR] Solution file not found -- '\\cnc-ddraw.sln'" + exit 1 + fi + # + shell: bash + + # MSBuild is not in PATH on Windows machines + # Using `::set-output` to make sure workflow environment remains unchanged + - name: Prepare MSBuild + id: msbuild + run: | + echo "::group::Prepare MSBuild" + + MSBUILD_EXE="$("/c/Program Files (x86)/Microsoft Visual Studio/Installer/vswhere.exe" -latest -requires Microsoft.Component.MSBuild -find MSBuild/**/Bin/MSBuild.exe)" + echo "exe=$MSBUILD_EXE" >> $GITHUB_OUTPUT + + echo "::endgroup::" + shell: bash + + # Creating empty `PostBuild.cmd` to avoid false-positive build error + - name: Build Release + id: build-release + run: | + if [[ "${{ inputs.release }}" == "true" ]]; then + echo ::group::Build Release + + # + # echo "@echo off" > "$GITHUB_ACTION_PATH/sfall/PostBuild.cmd" + "${{ steps.msbuild.outputs.exe }}" "$GITHUB_ACTION_PATH/cnc-ddraw.sln" -p:Configuration=Release -p:Platform=x86 -p:PlatformToolset=v141_xp + # + echo "ddraw-dll=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/Release/ddraw.dll")" >> $GITHUB_OUTPUT + + echo "::endgroup::" + fi + shell: bash + + # Creating empty `PostBuild.cmd` to avoid false-positive build error + - name: Build ReleaseWin2000 + id: build-releasewin2000 + run: | + if [[ "${{ inputs.releasewin2000 }}" == "true" ]]; then + echo ::group::Build ReleaseWin2000 + + # + # echo "@echo off" > "$GITHUB_ACTION_PATH/sfall/PostBuild.cmd" + "${{ steps.msbuild.outputs.exe }}" "$GITHUB_ACTION_PATH/cnc-ddraw.sln" -p:Configuration=ReleaseWin2000 -p:Platform=x86 -p:PlatformToolset=v141_xp + # + echo "ddraw-dll=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/ReleaseWin2000/ddraw.dll")" >> $GITHUB_OUTPUT + + echo "::endgroup::" + fi + shell: bash + + # Creating empty `PostBuild.cmd` to avoid false-positive build error + - name: Build Debug + id: build-debug + run: | + : + if [[ "${{ inputs.debug }}" == "true" ]]; then + echo "::group::Build Debug" + + # + # echo "@echo off" > "$GITHUB_ACTION_PATH/sfall/PostBuild.cmd" + "${{ steps.msbuild.outputs.exe }}" "$GITHUB_ACTION_PATH/cnc-ddraw.sln" -p:Configuration=Debug -p:Platform=x86 -p:PlatformToolset=v141_xp + # + echo "ddraw-dll=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/Debug/ddraw.dll")" >> $GITHUB_OUTPUT + echo "ddraw-pdb=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/Debug/ddraw.pdb")" >> $GITHUB_OUTPUT + + echo "::endgroup::" + fi + shell: bash + + # Creating empty `PostBuild.cmd` to avoid false-positive build error + - name: Build DebugLog + id: build-debuglog + run: | + : + if [[ "${{ inputs.debuglog }}" == "true" ]]; then + echo "::group::Build DebugLog" + + # + # echo "@echo off" > "$GITHUB_ACTION_PATH/sfall/PostBuild.cmd" + "${{ steps.msbuild.outputs.exe }}" "$GITHUB_ACTION_PATH/cnc-ddraw.sln" -p:Configuration=DebugLog -p:Platform=x86 -p:PlatformToolset=v141_xp + # + echo "ddraw-dll=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/DebugLog/ddraw.dll")" >> $GITHUB_OUTPUT + echo "ddraw-pdb=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/DebugLog/ddraw.pdb")" >> $GITHUB_OUTPUT + + echo "::endgroup::" + fi + shell: bash + + # Creating empty `PostBuild.cmd` to avoid false-positive build error + - name: Build DebugLogMini + id: build-debuglogmini + run: | + : + if [[ "${{ inputs.debuglogmini }}" == "true" ]]; then + echo "::group::Build DebugLogMini" + + # + # echo "@echo off" > "$GITHUB_ACTION_PATH/sfall/PostBuild.cmd" + "${{ steps.msbuild.outputs.exe }}" "$GITHUB_ACTION_PATH/cnc-ddraw.sln" -p:Configuration=DebugLogMini -p:Platform=x86 -p:PlatformToolset=v141_xp + # + echo "ddraw-dll=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/DebugLogMini/ddraw.dll")" >> $GITHUB_OUTPUT + echo "ddraw-pdb=$(cygpath --windows "$GITHUB_ACTION_PATH/bin/DebugLogMini/ddraw.pdb")" >> $GITHUB_OUTPUT + + echo "::endgroup::" + fi + shell: bash