Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save IlyaFinkelshteyn/49dba21a55ac4ca60789443fbbd2dd8f to your computer and use it in GitHub Desktop.
Save IlyaFinkelshteyn/49dba21a55ac4ca60789443fbbd2dd8f to your computer and use it in GitHub Desktop.
if ($env:APPVEYOR_REPO_BRANCH -ne "master") {
$headers = @{
"Authorization" = "Bearer $env:API_TOKEN"
"Content-type" = "application/json"
}
$apiURL = "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG"
$s = Invoke-RestMethod -Uri "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings" -Headers $headers -Method Get
$s.settings.nextBuildNumber = $s.settings.nextBuildNumber - 1
Invoke-RestMethod -Uri 'https://ci.appveyor.com/api/projects' -Headers $headers -Body ($s.settings | ConvertTo-Json -Depth 10) -Method Put
$history = Invoke-RestMethod -Uri "$apiURL/history?recordsNumber=2" -Headers $headers -Method Get
if (($history.builds.Count -eq 2) -and ($($history.builds[1].branch) -eq 'master')) {
Update-AppveyorBuild -Version "$($history.builds[1].version).$((New-Guid).ToString().Substring(0, 8))"
}
else {
Update-AppveyorBuild -Version "$env:APPVEYOR_BUILD_VERSION.$((New-Guid).ToString().Substring(0, 8))"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment