Files
IfcOpenShell/.github/workflows/build_win.yml
T
2026-04-18 15:46:21 +02:00

151 lines
5.9 KiB
YAML

name: Build IfcOpenShell Windows
on:
workflow_dispatch:
jobs:
build_ifcopenshell:
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
arch: ['x64']
steps:
- name: Checkout Repository
uses: actions/checkout@v5
with:
submodules: recursive
- name: Checkout Build Repository
uses: actions/checkout@v5
with:
repository: IfcOpenShell/build-outputs
path: _deps-vs2022-x64-installed
ref: windows-${{ matrix.arch }}
lfs: true
token: ${{ secrets.BUILD_REPO_TOKEN }}
- name: Install Dependencies
run: |
choco install -y sed 7zip.install awscli
- name: Unpack Dependencies
run: |
cd _deps-vs2022-x64-installed
Get-ChildItem -Path . -Filter 'cache-*.zip' | ForEach-Object {
7z x $_.FullName
}
- name: ccache
# TODO: Use tag after 1.2.20 releases.
uses: hendrikmuhs/ccache-action@5ebbd400eff9e74630f759d94ddd7b6c26299639
with:
key: win-${{ matrix.arch }}
# Windows ccache needs ~1GB
# and with default 500MB some cache gets deleted, leading to misses.
max-size: 5000MB
- name: Run Build Script And Pack .zip Archives
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
cd win
python build-all-win.py
- name: Repack .zip Archives With Runtime Plugins
shell: powershell
run: |
$version = (Get-Content VERSION | Select-Object -First 1).Trim()
$sha = $env:GITHUB_SHA.Substring(0, 7)
$outputDir = Join-Path $env:USERPROFILE "output"
$installDir = Get-ChildItem -Path . -Directory | Where-Object { $_.Name -like "_installed*" } | Select-Object -First 1
if (-not $installDir) {
throw "Install directory not found."
}
$runtimeFiles = @()
foreach ($runtimeDir in @((Join-Path $installDir.FullName "bin"), (Join-Path $installDir.FullName "lib"))) {
if (Test-Path $runtimeDir) {
$runtimeFiles += Get-ChildItem -Path $runtimeDir -Recurse -File | Where-Object { $_.Extension -ieq ".dll" }
}
}
$runtimeFiles = $runtimeFiles | Sort-Object FullName -Unique
Get-ChildItem -Path $outputDir -Filter *.zip -ErrorAction SilentlyContinue | Remove-Item -Force
$binDir = Join-Path $installDir.FullName "bin"
foreach ($exe in Get-ChildItem -Path $binDir -File -Filter *.exe) {
$stageDir = Join-Path $env:RUNNER_TEMP ("package-" + $exe.BaseName)
Remove-Item -Path $stageDir -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path $stageDir | Out-Null
Copy-Item -Path $exe.FullName -Destination $stageDir
foreach ($runtimeFile in $runtimeFiles) {
Copy-Item -Path $runtimeFile.FullName -Destination $stageDir -Force
}
$zipPath = Join-Path $outputDir ("{0}-v{1}-{2}-win64.zip" -f $exe.BaseName, $version, $sha)
Compress-Archive -Path (Join-Path $stageDir '*') -DestinationPath $zipPath -Force
}
$depsRoot = Join-Path (Get-Location) "_deps"
if (Test-Path $depsRoot) {
foreach ($pythonRoot in Get-ChildItem -Path $depsRoot -Directory | Where-Object { $_.Name -like "python.*" }) {
$pythonVersion = $pythonRoot.Name.Substring("python.".Length)
$pythonVersionMajorMinor = ($pythonVersion.Split(".")[0..1] -join "")
$sitePackages = Join-Path $pythonRoot.FullName "tools\\Lib\\site-packages"
$packagePath = Join-Path $sitePackages "ifcopenshell"
if (!(Test-Path $packagePath)) {
continue
}
Get-ChildItem -Path $packagePath -Recurse -Filter *.pyc -ErrorAction SilentlyContinue | Remove-Item -Force
foreach ($runtimeFile in $runtimeFiles) {
Copy-Item -Path $runtimeFile.FullName -Destination $packagePath -Force
}
$zipPath = Join-Path $outputDir ("ifcopenshell-python-{0}-v{1}-{2}-win64.zip" -f $pythonVersionMajorMinor, $version, $sha)
Push-Location $sitePackages
try {
Compress-Archive -Path "ifcopenshell" -DestinationPath $zipPath -Force
} finally {
Pop-Location
}
}
}
- name: Pack Dependencies
run: |
cd _deps-vs2022-x64-installed
Get-ChildItem -Path . -Directory | ForEach-Object {
$cacheFile = "cache-$($_.Name).zip"
echo $cacheFile
if (!(Test-Path $cacheFile)) {
7z a $cacheFile $_.FullName
}
}
- name: Commit and Push Changes to Build Repository
run: |
cd _deps-vs2022-x64-installed
git config user.name "IfcOpenBot"
git config user.email "ifcopenbot@ifcopenshell.org"
git add *.zip
git commit -m "Update build artifacts [skip ci]" || echo "No changes to commit"
git push || echo "Push failed"
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v5
with:
aws-access-key-id: ${{ secrets.AWS_UPLOAD_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_UPLOAD_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Upload .zip Archives to S3
env:
AWS_DEBUG: 1
AWS_RETRY_MODE: standard
AWS_MAX_ATTEMPTS: 3
run: |
dir "$env:USERPROFILE\output"
foreach ($zip in Get-ChildItem -Path "$env:USERPROFILE\output" -Filter *.zip) {
aws s3 cp "$($zip.FullName)" s3://ifcopenshell-builds/ --debug
Start-Sleep -Seconds 5
}