From cabdf48e5e52941a9d9ef1fe1accb12c039bef5a Mon Sep 17 00:00:00 2001 From: Wesley Maxey Date: Fri, 9 Jun 2023 16:03:56 -0700 Subject: [PATCH] Add manifest to combine windows builds --- .../create-and-push-manifest/action.ps1 | 21 ++++++++++ .../create-and-push-manifest/action.yml | 28 +++++++++++++ .github/workflows/trigger_windows.yml | 40 ++++++++++++++++++- scripts/windows/make-image-manifest.ps1 | 38 ++++++++++++++++++ 4 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 .github/actions/create-and-push-manifest/action.ps1 create mode 100644 .github/actions/create-and-push-manifest/action.yml create mode 100644 scripts/windows/make-image-manifest.ps1 diff --git a/.github/actions/create-and-push-manifest/action.ps1 b/.github/actions/create-and-push-manifest/action.ps1 new file mode 100644 index 0000000..f4a8933 --- /dev/null +++ b/.github/actions/create-and-push-manifest/action.ps1 @@ -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 +} diff --git a/.github/actions/create-and-push-manifest/action.yml b/.github/actions/create-and-push-manifest/action.yml new file mode 100644 index 0000000..3a8a70c --- /dev/null +++ b/.github/actions/create-and-push-manifest/action.yml @@ -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 }} diff --git a/.github/workflows/trigger_windows.yml b/.github/workflows/trigger_windows.yml index 83cc9e2..85b3f38 100644 --- a/.github/workflows/trigger_windows.yml +++ b/.github/workflows/trigger_windows.yml @@ -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: @@ -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 }} diff --git a/scripts/windows/make-image-manifest.ps1 b/scripts/windows/make-image-manifest.ps1 new file mode 100644 index 0000000..8ef8138 --- /dev/null +++ b/scripts/windows/make-image-manifest.ps1 @@ -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 +}