Skip to content

Windows builds

Windows builds #61

name: Build Windows
run-name: Windows builds
on:
push:
paths:
- "dockerfiles/**/windows/Dockerfile"
jobs:
changed_dockerfiles:
name: Get changed files
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.changed_dockerfiles.outputs.all_changed_files }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get changed files
id: changed_dockerfiles
uses: tj-actions/changed-files@v41
with:
json: true
escape_json: false
files: |
**/windows/Dockerfile
- name: Show changed dockerfiles
run: echo '${{ steps.changed_dockerfiles.outputs.all_changed_files }}'
get_nuke_sources:
name: Collect Nuke source files
runs-on: windows-latest
needs: [changed_dockerfiles]
strategy:
matrix:
files: ${{ fromJSON(needs.changed_dockerfiles.outputs.matrix) }}
fail-fast: false
outputs:
filename: ${{ steps.unique_name.outputs.filename}}
unique_name: ${{ steps.unique_name.outputs.unique_name}}
cache_key: ${{ steps.unique_name.outputs.cache_key}}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get cache name output
id: unique_name
shell: pwsh
run: |
echo "filename=${{ matrix.files }}" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
$uniqueName = ('${{ matrix.files }}' -replace '/', '_')
Write-Host "Got unique name '$uniqueName'"
echo "unique_name=$uniqueName" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
$cacheKey = "${uniqueName}_${{ hashFiles('**/scripts/nuke_source_from_dockerfile.ps1') }}"
Write-Host "Got cache key '$cacheKey'"
echo "cache_key=$cacheKey" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Get Nuke source files cache
id: cache_nuke_source
uses: actions/cache@v3
with:
path: C:\temp\nuke_source_files
key: ${{ steps.unique_name.outputs.cache_key }}
- name: Collect Nuke source files
if: steps.cache_nuke_source.outputs.cache-hit != 'true'
timeout-minutes: 30
shell: pwsh
run: |
$sourceFilesPath = "C:\temp\nuke_source_files"
Write-Host "Create temp dir for source files '$sourceFilesPath'"
New-Item -Type Directory -Path $sourceFilesPath | Out-Null
Write-Host "Starting collecting of source files'"
${{ github.workspace }}\scripts\nuke_source_from_dockerfile.ps1 "${{ matrix.files }}" "$sourceFilesPath"
- name: Create artifact tar
run: Compress-Archive -Path C:\temp\nuke_source_files -DestinationPath C:\temp\nuke_source_files.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nuke_source_files_${{ steps.unique_name.outputs.unique_name}}
path: C:\temp\nuke_source_files.zip
build:
name: Build, test and push image
runs-on: windows-latest
needs: [get_nuke_sources]
permissions: write-all
env:
PUSH_LOCATION: "ghcr.io/gillesvink/nukedockerbuild"
strategy:
matrix:
files: ${{ fromJSON(needs.changed_dockerfiles.outputs.matrix) }}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: nuke_source_files_${{ needs.get_nuke_sources.outputs.unique_name }}
path: C:\temp
- name: Prepare source files
shell: pwsh
run: |
$dockerfileDirectory=[System.IO.Path]::GetDirectoryName("${{ github.workspace }}\${{ needs.get_nuke_sources.outputs.filename }}")
echo "Directory set to $dockerfileDirectory"
Expand-Archive -Path C:\temp\nuke_source_files.zip -DestinationPath $dockerfileDirectory -Force
echo "dockerfile_directory=$dockerfileDirectory" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
- name: Build and export
shell: pwsh
run: |
cd ${{ env.dockerfile_directory }}
docker build . --tag nukedockerbuild:latest --build-arg="NUKE_SOURCE_FILES=nuke_source_files"
- name: Test image
shell: pwsh
run: |
mkdir C:\nuke_build_directory
docker run -v C:\nuke_build_directory:C:\nuke_build_directory `
nukedockerbuild:latest `
powershell -Command "cd C:\nuke_install\tests ; `
cmake . -DCMAKE_GENERATOR_PLATFORM=x64 -B C:\nuke_build_directory ; `
cmake --build C:\nuke_build_directory --config Release"
- name: Create artifact of test build
uses: actions/upload-artifact@v4
with:
name: test_build_${{ needs.get_nuke_sources.outputs.unique_name }}
path: C:\nuke_build_directory
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image
if: github.ref == 'refs/heads/main'
shell: pwsh
run: |
$dockerJSON = docker inspect --format '{{json .Config.Labels}}' nukedockerbuild:latest | ConvertFrom-Json
$nukeVersion = $dockerJSON | Select-Object -ExpandProperty "com.nukedockerbuild.nuke_version"
$operatingSystem = $dockerJSON | Select-Object -ExpandProperty "com.nukedockerbuild.operating_system"
$version = $dockerJSON | Select-Object -ExpandProperty "org.opencontainers.version"
$tag="$nukeVersion-$operatingSystem"
docker tag nukedockerbuild:latest ${{ env.PUSH_LOCATION }}:$tag-$version
docker tag nukedockerbuild:latest ${{ env.PUSH_LOCATION }}:$tag-latest
docker rmi nukedockerbuild:latest
docker image push ${{ env.PUSH_LOCATION }}:$tag-$version
docker image push ${{ env.PUSH_LOCATION }}:$tag-latest