Created
March 2, 2018 17:34
-
-
Save IlyaFinkelshteyn/49dba21a55ac4ca60789443fbbd2dd8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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