aboutsummaryrefslogtreecommitdiff
path: root/contrib/win-installer/check.ps1
blob: 6e3aa9c2e67eff8ccef47ca23069bf901a477f8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function SkipExists {
    param(
        [Parameter(Mandatory)]
        [string]$url,
        [Parameter(Mandatory)]
        [string]$desc
    )
    try {
        Invoke-WebRequest -Method HEAD -UseBasicParsing -ErrorAction Stop -Uri $url
        Write-Host "$desc already uploaded, skipping..."
        Exit 2
    } Catch {
        if ($_.Exception.Response.StatusCode -eq 404) {
            Write-Host "$desc does not exist,  continuing..."
            Return
        }

        throw $_.Exception
    }
}

function SkipNotExists {
    param(
        [Parameter(Mandatory)]
        [string]$url,
        [Parameter(Mandatory)]
        [string]$desc
    )
    $ret = ""
    try {
        Invoke-WebRequest -Method HEAD -UseBasicParsing -ErrorAction Stop -Uri $url
        Write-Host "$desc exists, continuing..."
    } Catch {
        if ($_.Exception.Response.StatusCode -eq 404) {
            Write-Host "$desc does not exist, skipping ..."
            Exit 2
        }

        throw $_.Exception
    }
}

if ($args.Count -lt 1 -or $args[0].Length -lt 2) {
    Write-Host "Usage: " $MyInvocation.MyCommand.Name "<version>"
    Exit 1
}

$release = $args[0]
$version = $release
if ($release[0] -eq "v") {
    $version = $release.Substring(1)
} else {
    $release = "v$release"
}

$base_url = "$ENV:FETCH_BASE_URL"
if ($base_url.Length -le 0) {
    $base_url = "https://github.com/containers/podman"
}

$ENV:UPLOAD_ASSET_NAME = "podman-$version-setup.exe"
SkipExists "$base_url/releases/download/$release/podman-$version-setup.exe" "Installer"
SkipNotExists "$base_url/releases/download/$release/podman-remote-release-windows_amd64.zip" "Windows client zip"