github.com/containers/podman/v4@v4.9.4/contrib/win-installer/check.ps1 (about)

     1  function SkipExists {
     2      param(
     3          [Parameter(Mandatory)]
     4          [string]$url,
     5          [Parameter(Mandatory)]
     6          [string]$desc
     7      )
     8      try {
     9          Invoke-WebRequest -Method HEAD -UseBasicParsing -ErrorAction Stop -Uri $url
    10          Write-Host "$desc already uploaded, skipping..."
    11          Exit 2
    12      } Catch {
    13          if ($_.Exception.Response.StatusCode -eq 404) {
    14              Write-Host "$desc does not exist,  continuing..."
    15              Return
    16          }
    17  
    18          throw $_.Exception
    19      }
    20  }
    21  
    22  function SkipNotExists {
    23      param(
    24          [Parameter(Mandatory)]
    25          [string]$url,
    26          [Parameter(Mandatory)]
    27          [string]$desc
    28      )
    29      $ret = ""
    30      try {
    31          Invoke-WebRequest -Method HEAD -UseBasicParsing -ErrorAction Stop -Uri $url
    32          Write-Host "$desc exists, continuing..."
    33      } Catch {
    34          if ($_.Exception.Response.StatusCode -eq 404) {
    35              Write-Host "$desc does not exist, skipping ..."
    36              Exit 2
    37          }
    38  
    39          throw $_.Exception
    40      }
    41  }
    42  
    43  if ($args.Count -lt 1 -or $args[0].Length -lt 2) {
    44      Write-Host "Usage: " $MyInvocation.MyCommand.Name "<version>"
    45      Exit 1
    46  }
    47  
    48  $release = $args[0]
    49  $version = $release
    50  if ($release[0] -eq "v") {
    51      $version = $release.Substring(1)
    52  } else {
    53      $release = "v$release"
    54  }
    55  
    56  $base_url = "$ENV:FETCH_BASE_URL"
    57  if ($base_url.Length -le 0) {
    58      $base_url = "https://github.com/containers/podman"
    59  }
    60  
    61  $ENV:UPLOAD_ASSET_NAME = "podman-$version-setup.exe"
    62  SkipExists "$base_url/releases/download/$release/podman-$version-setup.exe" "Installer"
    63  SkipNotExists "$base_url/releases/download/$release/podman-remote-release-windows_amd64.zip" "Windows client zip"