Skip to content

Commit

Permalink
Add manifest to combine windows builds
Browse files Browse the repository at this point in the history
  • Loading branch information
wmaxey committed Jun 10, 2023
1 parent 71bbce4 commit cabdf48
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .github/actions/create-and-push-manifest/action.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Param(
[Parameter(Mandatory=$true)]
[string]
$msvcVersion,
[Parameter(Mandatory=$true)]
[string]
$cudaVersion="latest",
[Parameter(Mandatory=$true)]
[string]
$repo
)

$ErrorActionPreference = "Stop"

# Assume this script is launched from repo root.
.\scripts\windows\vs-version-matrix.ps1
$clVerArray = $vsVerToCompilers[$msvcVersion]

foreach ($cl in $clVerArray) {
.\scripts\windows\make-image-manifest -clVersion $cl -cudaVersion $cudaVersion -repo $repo
}
28 changes: 28 additions & 0 deletions .github/actions/create-and-push-manifest/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Create and push image manifest"
description: "Push an image manifest that combines several images"

inputs:
repo:
type: string
required: true
description: Image repository
vs_version:
type: string
required: true
description: MSVC version
cuda_version:
type: string
required: true
description: CUDA version

runs:
using: composite
steps:
- name: Run action script to build images
id: build
shell: powershell
run: |
.github\actions\create-and-push-manifest\action.ps1 `
-cudaVersion ${{ inputs.cuda_version }} `
-msvcVersion ${{ inputs.vs_version }} `
-repo ${{ inputs.repo }}
40 changes: 38 additions & 2 deletions .github/workflows/trigger_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ on:
workflow_dispatch:

jobs:
dispatch-builder-job:
name: Build Windows Image
build-all-images:
name: Build Windows images
strategy:
fail-fast: false
matrix:
Expand All @@ -37,3 +37,39 @@ jobs:
vs_version: ${{ matrix.vs_version }}
cuda_version: ${{ matrix.cuda_version }}
push_image: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}

create-manifests:
name: Create Windows image manifests
needs: build-all-images
runs-on: windows-2022
strategy:
fail-fast: false
matrix:
cuda_version: ["12.1", "11.1"]
vs_version: ["2017", "2019", "2022"]
exclude:
# Exclude MSVC 2022 and 11.1 as it is unsupported
- vs_version: "2022"
cuda_version: "11.1"

steps:
- name: Checkout ${{ github.repository }}
uses: actions/checkout@v3
with:
fetch-depth: 0
persist-credentials: false

- name: Login to ghcr.io
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}

- name: Create manifest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
uses: ./.github/actions/create-and-push-manifest
with:
vs_version: ${{ matrix.vs_version }}
cuda_version: ${{ matrix.cuda_version }}
repo: ghcr.io/${{ github.repository }}
38 changes: 38 additions & 0 deletions scripts/windows/make-image-manifest.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# msvcVersion, cudaVersion, OS edition, isolation mode
Param(
[Parameter(Mandatory=$true)]
[string]
$clVersion="latest",
[Parameter(Mandatory=$false)]
[string]
$cudaVersion="latest",
[Parameter(Mandatory=$false)]
[string]
$repo="local"
)

function TestReturnCode {
if (-not $?) {
throw 'Step Failed'
}
}

Push-location "$PSScriptRoot"

try {
$image_name_2019="$(.\generate-image-name.ps1 -clVersion $clVersion -cudaVersion $cudaVersion -edition "windows-2019" -repo $repo)"
$image_name_2022="$(.\generate-image-name.ps1 -clVersion $clVersion -cudaVersion $cudaVersion -edition "windows-2022" -repo $repo)"

$manifest_name="${repo}:windows-cuda-${cudaVersion}-cl-${clVersion}"

docker manifest rm $manifest_name
docker manifest create $manifest_name $image_name_2019 $image_name_2022
docker manifest push $manifest_name
}
catch {
Pop-Location
throw
}
finally {
Pop-Location
}

0 comments on commit cabdf48

Please sign in to comment.