Switch to go-winres to create Windows resources
follow-up https://github.com/docker/cli/pull/3310 and https://github.com/moby/moby/pull/42872

**- What I did**

Replace windres with native Go implementation to be able to create a syso file which contains Microsoft Windows Version Information, an icon and the Windows Event Logging Manifest using [go-winres](https://github.com/tc-hib/go-winres).

**- How I did it**

Remove windres references and replace with go-winres. Also use `go:generate` for better integration and add legal copyright field.

Also add cross target to the GHA ci workflow.

**- How to verify it**

```console
docker buildx bake --set *.args.DOCKER_CROSSPLATFORMS=windows/amd64 cross
```

hack/make/.go-autogen.ps1
﻿<#
.NOTES
    Author:  @jhowardmsft

    Summary: Windows native version of .go-autogen which generates the
             .go source code for building, and performs resource compilation.

.PARAMETER CommitString
     The commit string. This is calculated externally to this script.

.PARAMETER DockerVersion
     The version such as 17.04.0-dev. This is calculated externally to this script.
#>

param(
    [Parameter(Mandatory=$true)][string]$CommitString,
    [Parameter(Mandatory=$true)][string]$DockerVersion,
    [Parameter(Mandatory=$false)][string]$Platform,
    [Parameter(Mandatory=$false)][string]$Product,
    [Parameter(Mandatory=$false)][string]$DefaultProductLicense
)

$ErrorActionPreference = "Stop"

# Utility function to get the build date/time in UTC
Function Get-BuildDateTime() {
    return $(Get-Date).ToUniversalTime()
}

try {
    $buildDateTime=Get-BuildDateTime

    if (Test-Path ".\autogen") {
        Remove-Item ".\autogen" -Recurse -Force | Out-Null
    }

    $fileContents = '
// +build autogen

// Package dockerversion is auto-generated at build-time
package dockerversion

// Default build-time variable for library-import.
// This file is overridden on build with build-time information.
const (
	GitCommit             string = "'+$CommitString+'"
	Version               string = "'+$DockerVersion+'"
	BuildTime             string = "'+$buildDateTime+'"
	PlatformName          string = "'+$Platform+'"
	ProductName           string = "'+$Product+'"
	DefaultProductLicense string = "'+$DefaultProductLicense+'"
)

// AUTOGENERATED FILE; see hack\make\.go-autogen.ps1
'

    # Write the file without BOM
    $outputFile="$(Get-Location)\dockerversion\version_autogen.go"
    if (Test-Path $outputFile) { Remove-Item $outputFile }
    [System.IO.File]::WriteAllText($outputFile, $fileContents, (New-Object System.Text.UTF8Encoding($False)))

    New-Item -ItemType Directory -Path "autogen\winresources\tmp" | Out-Null
    New-Item -ItemType Directory -Path "autogen\winresources\dockerd" | Out-Null
    Copy-Item "hack\make\.resources-windows\resources.go" "autogen\winresources\dockerd"

    # Generate a version in the form major,minor,patch,build
    $versionQuad=$DockerVersion -replace "[^0-9.]*" -replace "\.", ","

    # Compile the messages
    windmc hack\make\.resources-windows\event_messages.mc -h autogen\winresources\tmp -r autogen\winresources\tmp
    if ($LASTEXITCODE -ne 0) { Throw "Failed to compile event message resources" }

    # If you really want to understand this madness below, search the Internet for powershell variables after verbatim arguments... Needed to get double-quotes passed through to the compiler options.
    # Generate the .syso files containing all the resources and manifest needed to compile the final docker binaries. Both 32 and 64-bit clients.
    $env:_ag_dockerVersion=$DockerVersion
    $env:_ag_gitCommit=$CommitString

    windres -i hack/make/.resources-windows/dockerd.rc -o autogen/winresources/dockerd/rsrc_amd64.syso -F pe-x86-64 --use-temp-file -I autogen/winresources/tmp -D DOCKER_VERSION_QUAD=$versionQuad --% -D DOCKER_VERSION=\"%_ag_dockerVersion%\" -D DOCKER_COMMIT=\"%_ag_gitCommit%\"
    if ($LASTEXITCODE -ne 0) { Throw "Failed to compile daemon resources" }
}
Catch [Exception] {
    # Throw the error onto the caller to display errors. We don't expect this script to be called directly 
    Throw ".go-autogen.ps1 failed with error $_"
}
Finally {
    Remove-Item .\autogen\winresources\tmp -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
    $env:_ag_dockerVersion=""
    $env:_ag_gitCommit=""
}

﻿<#
.NOTES
    Author:  @jhowardmsft

    Summary: Windows native version of .go-autogen which generates the
             .go source code for building, and performs resource compilation.

.PARAMETER CommitString
     The commit string. This is calculated externally to this script.

.PARAMETER DockerVersion
     The version such as 17.04.0-dev. This is calculated externally to this script.

.PARAMETER Platform
     The platform name, such as "Docker Engine - Community".

.PARAMETER Product
     The product name, used to set version.ProductName, which is used to set BuildKit's
     ExportedProduct variable in order to show useful error messages to users when a
     certain version of the product doesn't support a BuildKit feature.

.PARAMETER DefaultProductLicense
     Sets the version.DefaultProductLicense string, such as "Community Engine". This field
     can contain a summary of the product license of the daemon if a commercial license has
     been applied to the daemon.

.PARAMETER PackagerName
     The name of the packager (e.g. "Docker, Inc."). This used to set CompanyName in the manifest.
#>

param(
    [Parameter(Mandatory=$true)][string]$CommitString,
    [Parameter(Mandatory=$true)][string]$DockerVersion,
    [Parameter(Mandatory=$false)][string]$Platform,
    [Parameter(Mandatory=$false)][string]$Product,
    [Parameter(Mandatory=$false)][string]$DefaultProductLicense,
    [Parameter(Mandatory=$false)][string]$PackagerName
)

$ErrorActionPreference = "Stop"

# Utility function to get the build date/time in UTC
Function Get-BuildDateTime() {
    return $(Get-Date).ToUniversalTime()
}

Function Get-Year() {
    return $(Get-Date).year
}

Function Get-FixQuadVersionNumber($number) {
    if ($number -eq 0) {
        return $number
    }
    return $number.TrimStart("0")
}

try {
    $buildDateTime=Get-BuildDateTime
    $currentYear=Get-Year

    # Update PATH
    $env:PATH="$env:GOPATH\bin;$env:PATH"

    # Generate a version in the form major,minor,patch,build
    $versionQuad=($DockerVersion -replace "[^0-9.]*")
    if ($versionQuad -Match "^\d+`.\d+`.\d+$"){
        $versionQuad = $versionQuad + ".0"
    }
    $versionMatches = $($versionQuad | Select-String -AllMatches -Pattern "(\d+)`.(\d+)`.(\d+)`.(\d+)").Matches

    $mkwinresContents = '{
  "RT_GROUP_ICON": {
    "#1": {
      "0409": "../../winresources/docker.ico"
    }
  },
  "RT_MANIFEST": {
    "#1": {
      "0409": {
        "identity": {},
        "description": "Docker Engine",
        "minimum-os": "vista",
        "execution-level": "",
        "ui-access": false,
        "auto-elevate": false,
        "dpi-awareness": "unaware",
        "disable-theming": false,
        "disable-window-filtering": false,
        "high-resolution-scrolling-aware": false,
        "ultra-high-resolution-scrolling-aware": false,
        "long-path-aware": false,
        "printer-driver-isolation": false,
        "gdi-scaling": false,
        "segment-heap": false,
        "use-common-controls-v6": false
      }
    }
  },
  "RT_MESSAGETABLE": {
    "#1": {
      "0409": "../../winresources/event_messages.bin"
    }
  },
  "RT_VERSION": {
    "#1": {
      "0409": {
        "fixed": {
          "file_version": "'+(Get-FixQuadVersionNumber($versionMatches.Groups[1].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[2].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[3].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[4].Value))+'",
          "product_version": "'+(Get-FixQuadVersionNumber($versionMatches.Groups[1].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[2].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[3].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[4].Value))+'",
          "type": "Unknown"
        },
        "info": {
          "0000": {
            "CompanyName": "'+$PackagerName+'",
            "FileVersion": "'+$DockerVersion+'",
            "LegalCopyright": "Copyright (C) 2015-'+$currentYear+' Docker Inc.",
            "OriginalFileName": "dockerd.exe",
            "ProductName": "'+$Product+'",
            "ProductVersion": "'+$DockerVersion+'",
            "SpecialBuild": "'+$CommitString+'"
          }
        }
      }
    }
  }
}'

    # Write the file
    $outputFile="$(Get-Location)\cli\winresources\dockerd\winres.json"
    if (Test-Path $outputFile) { Remove-Item $outputFile }
    [System.IO.File]::WriteAllText($outputFile, $mkwinresContents)
    Get-Content $outputFile | Out-Host

    # Create winresources package stub if removed while using tmpfs in Dockerfile
    $stubPackage="$(Get-Location)\cli\winresources\dockerd\winresources.go"
    if(![System.IO.File]::Exists($stubPackage)){
        Set-Content -NoNewline -Path $stubPackage -Value 'package winresources'
    }

    # Generate
    go generate -v "github.com/docker/docker/cmd/dockerd"
    if ($LASTEXITCODE -ne 0) { Throw "Failed to generate version info" }
}
Catch [Exception] {
    # Throw the error onto the caller to display errors. We don't expect this script to be called directly 
    Throw ".go-autogen.ps1 failed with error $_"
}
Finally {
    $env:_ag_dockerVersion=""
    $env:_ag_gitCommit=""
}

`Set-Content` does the sane thing by default on PowerShell 7, encoding as UTF-8 without BOM; however the cmdlet on Windows PowerShell (v5.1; installed by default on Windows) defaults to "the encoding that corresponds to the system's active code page (usually ANSI)" which is going to result in invalid UTF-8 if the input string contains any non-ASCII characters or the script is run on a non-English Windows system. Since this script went out of its way to support Windows PowerShell before, we should probably try to maintain that support.
```suggestion
    [System.IO.File]::WriteAllText($outputFile, $mkwinresContents)
```