github.com/containers/podman/v4@v4.9.4/contrib/win-installer/process-release.ps1 (about) 1 function Copy-Artifact { 2 param( 3 [Parameter(Mandatory)] 4 [string]$fileName 5 ) 6 $file = Get-ChildItem -Recurse -Path . -Name $fileName 7 if (!$file) { 8 throw "Could not find $filename" 9 } 10 Write-Host "file:" $file 11 Copy-Item -Path $file -Destination "..\artifacts\$filename" -ErrorAction Stop 12 } 13 14 function DownloadOrSkip { 15 param( 16 [Parameter(Mandatory)] 17 [string]$url, 18 [Parameter(Mandatory)] 19 [string]$file 20 ) 21 $ProgressPreference = 'SilentlyContinue'; 22 try { 23 Invoke-WebRequest -UseBasicParsing -ErrorAction Stop -Uri $url -OutFile $file 24 } Catch { 25 if ($_.Exception.Response.StatusCode -eq 404) { 26 Write-Host "URL not available, signaling skip:" 27 Write-Host "URL: $url" 28 Exit 2 29 } 30 31 throw $_.Exception 32 } 33 } 34 35 function DownloadOptional { 36 param( 37 [Parameter(Mandatory)] 38 [string]$url, 39 [Parameter(Mandatory)] 40 [string]$file 41 ) 42 $ProgressPreference = 'SilentlyContinue'; 43 try { 44 Invoke-WebRequest -UseBasicParsing -ErrorAction Stop -Uri $url -OutFile $file 45 } Catch { 46 } 47 48 Return 49 } 50 51 52 if ($args.Count -lt 1) { 53 Write-Host "Usage: " $MyInvocation.MyCommand.Name "<version> [release_dir]" 54 Exit 1 55 } 56 57 $releaseDir = "" 58 if ($args.Count -gt 1 -and $args[1].Length -gt 0) { 59 $path = $args[1] 60 $releaseDir = (Resolve-Path -Path "$path" -ErrorAction Stop).Path 61 } 62 63 64 $base_url = "$ENV:FETCH_BASE_URL" 65 if ($base_url.Length -le 0) { 66 $base_url = "https://github.com/containers/podman" 67 } 68 69 $version = $args[0] 70 if ($version -notmatch '^v?([0-9]+\.[0-9]+\.[0-9]+)(-.*)?$') { 71 Write-Host "Invalid version" 72 Exit 1 73 } 74 75 # WiX burn requires a QWORD version only, numeric only 76 $Env:INSTVER=$Matches[1] 77 78 if ($version[0] -ne 'v') { 79 $version = 'v' + $version 80 } 81 82 $restore = 0 83 $exitCode = 0 84 85 try { 86 Write-Host "Cleaning up old artifacts" 87 Remove-Item -Force -Recurse -Path .\docs -ErrorAction SilentlyContinue | Out-Null 88 Remove-Item -Force -Recurse -Path .\artifacts -ErrorAction SilentlyContinue | Out-Null 89 Remove-Item -Force -Recurse -Path .\fetch -ErrorAction SilentlyContinue | Out-Null 90 91 New-Item fetch -ItemType Directory | Out-Null 92 New-Item artifacts -ItemType Directory | Out-Null 93 94 Write-Host "Fetching zip release" 95 96 Push-Location fetch -ErrorAction Stop 97 $restore = 1 98 $ProgressPreference = 'SilentlyContinue'; 99 100 if ($releaseDir.Length -gt 0) { 101 Copy-Item -Path "$releaseDir/podman-remote-release-windows_amd64.zip" "release.zip" 102 } else { 103 DownloadOrSkip "$base_url/releases/download/$version/podman-remote-release-windows_amd64.zip" "release.zip" 104 DownloadOptional "$base_url/releases/download/$version/shasums" ..\shasums 105 } 106 Expand-Archive -Path release.zip 107 $loc = Get-ChildItem -Recurse -Path . -Name win-sshproxy.exe 108 if (!$loc) { 109 if ($releaseDir.Length -gt 0) { 110 throw "Release dir only supports zip which includes win-sshproxy.exe" 111 } 112 Write-Host "Old release, zip does not include win-sshproxy.exe, fetching via msi" 113 DownloadOrSkip "$base_url/releases/download/$version/podman-$version.msi" "podman.msi" 114 dark -x expand ./podman.msi 115 if (!$?) { 116 throw "Dark command failed" 117 } 118 $loc = Get-ChildItem -Recurse -Path expand -Name 4A2AD125-34E7-4BD8-BE28-B2A9A5EDBEB5 119 if (!$loc) { 120 throw "Could not obtain win-sshproxy.exe" 121 } 122 Copy-Item -Path "expand\$loc" -Destination "win-sshproxy.exe" -ErrorAction Stop 123 Remove-Item -Recurse -Force -Path expand 124 } 125 126 Write-Host "Copying artifacts" 127 Foreach ($fileName in "win-sshproxy.exe", "podman.exe") { 128 Copy-Artifact($fileName) 129 } 130 131 $loc = Get-ChildItem -Recurse -Path . -Name gvproxy.exe 132 if (!$loc) { 133 Write-Host "Skipping gvproxy.exe artifact" 134 } else { 135 Copy-Artifact("gvproxy.exe") 136 } 137 138 $docsloc = Get-ChildItem -Path . -Name docs -Recurse 139 $loc = Get-ChildItem -Recurse -Path . -Name podman-for-windows.html 140 if (!$loc) { 141 Write-Host "Old release did not include welcome page, using podman-machine instead" 142 $loc = Get-ChildItem -Recurse -Path . -Name podman-machine.html 143 Copy-Item -Path $loc -Destination "$docsloc\podman-for-windows.html" 144 } 145 146 Write-Host "Copying docs" 147 Copy-Item -Recurse -Path $docsloc -Destination ..\docs -ErrorAction Stop 148 Write-Host "Done!" 149 150 if (!$loc) { 151 throw "Could not find docs" 152 } 153 } 154 catch { 155 Write-Host $_ 156 157 $exitCode = 1 158 } 159 finally { 160 if ($restore) { 161 Pop-Location 162 } 163 } 164 165 exit $exitCode