Build Windows #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Windows | |
on: | |
workflow_dispatch: | |
jobs: | |
build-windows: | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
include: | |
- QT_ARCH: 'win64_msvc2017_64' | |
PLATFORM: 'amd64' | |
PLATFORM_ALT_NAME: 'x64' | |
OUTPUT_BIN_DIR: 'bin64' | |
- QT_ARCH: 'win32_msvc2017' | |
PLATFORM: 'x86' | |
PLATFORM_ALT_NAME: 'x86' | |
OUTPUT_BIN_DIR: 'bin32' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Install Visual Studio 2017 Build Tools | |
- name: Install Visual Studio 2017 Build Tools | |
shell: powershell | |
run: | | |
# Download the VS 2017 Build Tools installer | |
Invoke-WebRequest -Uri "https://aka.ms/vs/15/release/vs_buildtools.exe" -OutFile "$env:TEMP\vs_buildtools.exe" | |
# Install the Build Tools with necessary workloads and components | |
& "$env:TEMP\vs_buildtools.exe" --quiet --wait --norestart --nocache ` | |
--installPath "C:\BuildTools" ` | |
--add Microsoft.VisualStudio.Workload.VCTools ` | |
--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ` | |
--add Microsoft.VisualStudio.Component.Windows10SDK.17763 ` | |
--includeRecommended | |
# Wait for the installation to complete | |
Start-Sleep -Seconds 30 | |
# Debug: List BuildTools directory structure | |
- name: Debug - List BuildTools Directory Structure | |
shell: powershell | |
run: | | |
Write-Host "=== Listing BuildTools Directory Structure ===" | |
if (Test-Path "C:\BuildTools") { | |
Get-ChildItem -Path "C:\BuildTools" -Recurse -Depth 3 | Select-Object FullName | Sort-Object FullName | |
# Check specifically for VC folder and vcvarsall.bat | |
Write-Host "`n=== Checking for VC folder ===" | |
if (Test-Path "C:\BuildTools\VC") { | |
Write-Host "VC folder exists" | |
Get-ChildItem -Path "C:\BuildTools\VC" -Recurse -Depth 3 | Select-Object FullName | Sort-Object FullName | |
} else { | |
Write-Host "VC folder does not exist" | |
} | |
# Search for vcvarsall.bat in entire BuildTools directory | |
Write-Host "`n=== Searching for vcvarsall.bat ===" | |
Get-ChildItem -Path "C:\BuildTools" -Filter "vcvarsall.bat" -Recurse -File | Select-Object FullName | |
# List all possible paths for VS installation | |
Write-Host "`n=== Checking other possible VS installation locations ===" | |
$possiblePaths = @( | |
"C:\Program Files (x86)\Microsoft Visual Studio\2017", | |
"C:\Program Files\Microsoft Visual Studio\2017", | |
"C:\Program Files (x86)\Microsoft Visual Studio\2019", | |
"C:\Program Files\Microsoft Visual Studio\2019" | |
) | |
foreach ($path in $possiblePaths) { | |
if (Test-Path $path) { | |
Write-Host "Found: $path" | |
Get-ChildItem -Path $path -Recurse -Depth 2 | Select-Object FullName | Sort-Object FullName | |
} | |
} | |
} else { | |
Write-Host "C:\BuildTools directory does not exist!" | |
} | |
- name: Install Qt (64-bit & 32-bit) | |
uses: jurplel/install-qt-action@v3 | |
with: | |
aqtversion: '==3.1.*' | |
version: '5.12.12' | |
host: 'windows' | |
target: 'desktop' | |
arch: '${{ matrix.QT_ARCH }}' | |
# Mimic the AppVeyor "clone_folder" setting by moving the repo to C:\dev\labrador | |
- name: Move repository to C:\dev\labrador | |
shell: cmd | |
run: | | |
mkdir C:\dev\labrador | |
xcopy /s /e /i /y "%GITHUB_WORKSPACE%\*" C:\dev\labrador\ | |
- name: Setup Visual Studio environment and build | |
shell: cmd | |
run: | | |
cd C:\dev\labrador | |
echo "Current directory: %CD%" | |
echo "Showing available vcvarsall.bat files:" | |
dir /s /b C:\*vcvarsall.bat | |
call "C:\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.PLATFORM }} | |
echo "After calling vcvarsall.bat" | |
echo "PATH=%PATH%" | |
where cl 2>nul || echo cl not found | |
where nmake 2>nul || echo nmake not found | |
set "PATH=C:\Qt\5.12.12\${{ matrix.QT_ARCH }}\bin;%PATH%" | |
cd Desktop_Interface | |
echo "Before running qmake" | |
where qmake | |
for /f "delims=" %%i in ('git rev-parse --short HEAD') do set GIT_HASH_SHORT=%%i | |
qmake CONFIG+=release DEFINES+=GIT_HASH_SHORT=%GIT_HASH_SHORT% | |
echo "Before running nmake" | |
where nmake | |
nmake | |
- name: Post-build steps | |
shell: cmd | |
run: | | |
cd C:\dev\labrador\Desktop_Interface | |
windeployqt bin\Labrador.exe | |
xcopy /i /s /y "build_win\fftw\${{ matrix.PLATFORM_ALT_NAME }}"\libfftw3-3.dll bin | |
del bin\vcredist*.exe | |
del bin\*.pdb | |
- name: Upload Windows artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Labrador_${{ matrix.PLATFORM }} | |
path: C:\dev\labrador\Desktop_Interface\bin | |
- name: Publish update to Labrador-win-builder | |
if: success() | |
shell: pwsh | |
env: | |
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} | |
OUTPUT_BIN_DIR: ${{ matrix.OUTPUT_BIN_DIR }} | |
run: | | |
cd C:\dev | |
git clone --depth 1 https://github.com/espotek-org/Labrador-win-builder | |
cd Labrador-win-builder | |
git config --global credential.helper store | |
Add-Content "$env:USERPROFILE\.git-credentials" "https://$env:ACCESS_TOKEN:[email protected]`n" | |
git config --global user.email "[email protected]" | |
git config --global user.name "Chris Esposito" | |
git checkout master | |
xcopy /i /s /y C:\dev\labrador\Desktop_Interface\bin $env:OUTPUT_BIN_DIR | |
git add $env:OUTPUT_BIN_DIR | |
git commit -a -m "Automatic update from main Labrador repository" | |
git push |