Skip to content

Instantly share code, notes, and snippets.

@Geertvdc
Created February 26, 2016 15:14
Show Gist options
  • Select an option

  • Save Geertvdc/cad0e2191243fb76c55f to your computer and use it in GitHub Desktop.

Select an option

Save Geertvdc/cad0e2191243fb76c55f to your computer and use it in GitHub Desktop.
Powershell script to upload UWP .zip packages to hockeyapp for deployment
Param(
[string]$HockeyAppAppID,
[string]$HockeyAppApiToken
)
$zipFile = Get-Item *.zip | Select-Object -first 1
Write-Host "Zip file found to upload $($zipFile)"
$create_url = "https://rink.hockeyapp.net/api/2/apps/$HockeyAppAppID/app_versions/new"
$zip = $zipFile.BaseName
$version = $zip.subString(0,$zip.LastIndexOf("_"))
$version = $version.subString(0,$version.LastIndexOf("_"))
$version = $version.subString($version.LastIndexOf("_")+1)
Write-Host "Extracted version from zip file $($version)"
$response = Invoke-RestMethod -Method POST -Uri $create_url -Header @{ "X-HockeyAppToken" = $HockeyAppApiToken } -Body @{bundle_version = $Version}
$update_url = "https://rink.hockeyapp.net/api/2/apps/$($HockeyAppAppID)/app_versions/$($response.id)"
$fileBin = [IO.File]::ReadAllBytes($zipFile)
$enc = [System.Text.Encoding]::GetEncoding("ISO-8859-1")
$fileEnc = $enc.GetString($fileBin)
$boundary = [System.Guid]::NewGuid().ToString()
$LF = "`r`n"
$bodyLines = (
"--$boundary",
"content-transfer-encoding: base64",
"Content-Disposition: form-data; content-transfer-encoding: `"base64`"; name=`"ipa`"; filename=`" [System.IO.Path]::GetFileName $zipFile`"$LF",$fileEnc,
"--$boundary",
"Content-Disposition: form-data; name=`"status`"$LF","2",
"--$boundary--$LF") -join $LF
Invoke-RestMethod -Uri $update_url -Method PUT -Headers @{ "X-HockeyAppToken" = $HockeyAppApiToken } -ContentType "multipart/form-data; boundary=`"$boundary`"" -Body $bodyLines
@ankitec98

Copy link
Copy Markdown

can we use this script for WPF application also?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment