From 16dfc3b59295430097b9e85697aeec970f14c11b Mon Sep 17 00:00:00 2001 From: Jamie Phillips Date: Fri, 12 Nov 2021 12:27:33 -0500 Subject: [PATCH] Adding Windows Server 2022 support. Signed-off-by: Jamie Phillips --- .drone.yml | 115 ++++++++++--------- manifest.tmpl | 6 + scripts/package.ps1 | 14 ++- scripts/version.ps1 | 8 ++ tests/integration/integration_suite_test.ps1 | 8 +- 5 files changed, 89 insertions(+), 62 deletions(-) diff --git a/.drone.yml b/.drone.yml index c6c051dd..0da04389 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,5 +1,6 @@ --- kind: pipeline +type: docker name: windows-1809 platform: @@ -10,7 +11,7 @@ platform: steps: - name: build pull: always - image: rancher/dapper:v0.5.6 + image: rancher/dapper:v0.5.8 commands: - dapper.exe -f Dockerfile.dapper -d ci volumes: @@ -18,7 +19,7 @@ steps: path: \\\\.\\pipe\\docker_engine - name: stage-binaries - image: rancher/dapper:v0.5.6 + image: rancher/dapper:v0.5.8 commands: - "Get-ChildItem -Path ./bin; Get-ChildItem -Path ./dist; Copy-Item -Force -Path ./bin/wins.exe -Destination ./package/windows/; Get-ChildItem -Path ./package/windows" @@ -79,12 +80,13 @@ trigger: --- kind: pipeline -name: windows-2004 +type: docker +name: windows-20H2 platform: os: windows arch: amd64 - version: 2004 + version: 20H2 # remove this and use upstream images when https://github.com/drone/drone-git/pull/25 is merged clone: @@ -92,11 +94,11 @@ clone: steps: - name: clone - image: rancher/drone-images:git-2004 + image: rancher/drone-images:git-20H2 - name: build pull: always - image: rancher/dapper:v0.5.6 + image: rancher/dapper:v0.5.8 commands: - dapper.exe -f Dockerfile.dapper -d ci volumes: @@ -104,15 +106,15 @@ steps: path: \\\\.\\pipe\\docker_engine - name: stage-binaries - image: rancher/dapper:v0.5.6 + image: rancher/dapper:v0.5.8 commands: - "Get-ChildItem -Path ./bin; Get-ChildItem -Path ./dist; Copy-Item -Force -Path ./bin/wins.exe -Destination ./package/windows/; Get-ChildItem -Path ./package/windows" - name: docker-publish - image: rancher/drone-images:docker-2004 + image: rancher/drone-images:docker-20H2 settings: build_args: - - SERVERCORE_VERSION=2004 + - SERVERCORE_VERSION=20H2 - ARCH=amd64 - VERSION=${DRONE_TAG} context: package/windows @@ -123,7 +125,7 @@ steps: password: from_secret: docker_password repo: rancher/wins - tag: ${DRONE_TAG}-windows-2004 + tag: ${DRONE_TAG}-windows-20H2 volumes: - name: docker_pipe path: \\\\.\\pipe\\docker_engine @@ -146,60 +148,61 @@ trigger: --- kind: pipeline -name: windows-20H2 +type: docker +name: windows-ltsc2022 platform: os: windows arch: amd64 - version: 20H2 + version: 2022 # remove this and use upstream images when https://github.com/drone/drone-git/pull/25 is merged clone: disable: true steps: -- name: clone - image: rancher/drone-images:git-20H2 - -- name: build - pull: always - image: rancher/dapper:v0.5.6 - commands: - - dapper.exe -f Dockerfile.dapper -d ci - volumes: - - name: docker_pipe - path: \\\\.\\pipe\\docker_engine - -- name: stage-binaries - image: rancher/dapper:v0.5.6 - commands: - - "Get-ChildItem -Path ./bin; Get-ChildItem -Path ./dist; Copy-Item -Force -Path ./bin/wins.exe -Destination ./package/windows/; Get-ChildItem -Path ./package/windows" - -- name: docker-publish - image: rancher/drone-images:docker-20H2 - settings: - build_args: - - SERVERCORE_VERSION=20H2 - - ARCH=amd64 - - VERSION=${DRONE_TAG} - context: package/windows - custom_dns: 1.1.1.1 - dockerfile: package/windows/Dockerfile - username: - from_secret: docker_username - password: - from_secret: docker_password - repo: rancher/wins - tag: ${DRONE_TAG}-windows-20H2 - volumes: - - name: docker_pipe - path: \\\\.\\pipe\\docker_engine - when: - event: - - tag - ref: - - refs/heads/main - - refs/tags/* + - name: clone + image: rancher/drone-images:git-amd64-ltsc2022 + + - name: build + pull: always + image: rancher/dapper:v0.5.8 + commands: + - dapper.exe -f Dockerfile.dapper -d ci + volumes: + - name: docker_pipe + path: \\\\.\\pipe\\docker_engine + + - name: stage-binaries + image: rancher/dapper:v0.5.8 + commands: + - "Get-ChildItem -Path ./bin; Get-ChildItem -Path ./dist; Copy-Item -Force -Path ./bin/wins.exe -Destination ./package/windows/; Get-ChildItem -Path ./package/windows" + + - name: docker-publish + image: rancher/drone-images:docker-amd64-ltsc2022 + settings: + build_args: + - SERVERCORE_VERSION=ltsc2022 + - ARCH=amd64 + - VERSION=${DRONE_TAG} + context: package/windows + custom_dns: 1.1.1.1 + dockerfile: package/windows/Dockerfile + username: + from_secret: docker_username + password: + from_secret: docker_password + repo: rancher/wins + tag: ${DRONE_TAG}-windows-ltsc2022 + volumes: + - name: docker_pipe + path: \\\\.\\pipe\\docker_engine + when: + event: + - tag + ref: + - refs/heads/main + - refs/tags/* volumes: - name: docker_pipe @@ -212,6 +215,7 @@ trigger: - promote --- kind: pipeline +type: docker name: manifest platform: @@ -238,11 +242,12 @@ trigger: depends_on: - windows-1809 -- windows-2004 - windows-20H2 +- windows-ltsc2022 --- kind: pipeline +type: docker name: fossa platform: diff --git a/manifest.tmpl b/manifest.tmpl index 8c5dbb42..2b864ed1 100644 --- a/manifest.tmpl +++ b/manifest.tmpl @@ -18,3 +18,9 @@ manifests: architecture: amd64 os: windows version: 20H2 + - + image: rancher/wins:{{build.tag}}-windows-ltsc2022 + platform: + architecture: amd64 + os: windows + version: ltsc2022 \ No newline at end of file diff --git a/scripts/package.ps1 b/scripts/package.ps1 index 55f189c5..e31b241f 100644 --- a/scripts/package.ps1 +++ b/scripts/package.ps1 @@ -29,17 +29,19 @@ if ($env:DRONE_TAG) { $TAG = $env:DRONE_TAG } -# Get release id as image tag suffix -$HOST_RELEASE_ID = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\' -ErrorAction Ignore).ReleaseId -$IMAGE = ('{0}/wins:{1}-windows-{2}' -f $REPO, $TAG, $HOST_RELEASE_ID) -if (-not $HOST_RELEASE_ID) { - Log-Fatal "release ID not found" +$buildTags = @{ "17763" = "1809"; "19042" = "20H2"; "20348" = "ltsc2022";} +$buildNumber = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\' -ErrorAction Ignore).CurrentBuildNumber +$WINDOWS_VERSION = $buildTags[$buildNumber] +if (-not $WINDOWS_VERSION) { + $WINDOWS_VERSION = "1809" } +$IMAGE = ('{0}/wins:{1}-windows-{2}' -f $REPO, $TAG, $WINDOWS_VERSION) + $ARCH = $env:ARCH docker build ` - --build-arg SERVERCORE_VERSION=$HOST_RELEASE_ID ` + --build-arg SERVERCORE_VERSION=$WINDOWS_VERSION ` --build-arg ARCH=$ARCH ` --build-arg VERSION=$TAG ` -t $IMAGE ` diff --git a/scripts/version.ps1 b/scripts/version.ps1 index a3c1970d..1b96a58c 100644 --- a/scripts/version.ps1 +++ b/scripts/version.ps1 @@ -27,5 +27,13 @@ if (-not $ARCH) { } $env:ARCH = $ARCH +$buildTags = @{ "17763" = "1809"; "19042" = "20H2"; "20348" = "ltsc2022";} +$buildNumber = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\' -ErrorAction Ignore).CurrentBuildNumber +$SERVERCORE_VERSION = $buildTags[$buildNumber] +if (-not $SERVERCORE_VERSION) { + $env:SERVERCORE_VERSION = "1809" +} + Write-Host "ARCH: $ARCH" Write-Host "VERSION: $VERSION" +Write-Host "SERVERCORE_VERSION: $SERVERCORE_VERSION" diff --git a/tests/integration/integration_suite_test.ps1 b/tests/integration/integration_suite_test.ps1 index 21a76974..f335c30b 100644 --- a/tests/integration/integration_suite_test.ps1 +++ b/tests/integration/integration_suite_test.ps1 @@ -1,7 +1,13 @@ $ErrorActionPreference = "Stop" # docker build -$SERVERCORE_VERSION = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\' | Select-Object -ExpandProperty ReleaseId +$buildTags = @{ "17763" = "1809"; "19042" = "20H2"; "20348" = "ltsc2022";} +$buildNumber = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\' -ErrorAction Ignore).CurrentBuildNumber +$SERVERCORE_VERSION = $buildTags[$buildNumber] +if (-not $SERVERCORE_VERSION) { + $SERVERCORE_VERSION = "1809" +} + Get-ChildItem -Path $PSScriptRoot\docker -Name Dockerfile.* | ForEach-Object { $dockerfile = $_ $tag = $dockerfile -replace "Dockerfile.", ""