From 50b73626605fe42d9365c492663ce0a1ec52f5e6 Mon Sep 17 00:00:00 2001 From: salaros Date: Tue, 5 Jun 2018 19:52:23 +0300 Subject: [PATCH] improving AppVeyor's version calculation init (PowerShell) script --- appveyor.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index b9163d7..639ec44 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -28,11 +28,8 @@ environment: init: - ps: | - [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 - $github_last_release=(Invoke-WebRequest -Uri https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/releases/latest) -join '`n' | ConvertFrom-Json - $github_tag_name=$github_last_release.tag_name - $env:VERSION_SIMPLE = "$github_tag_name.$env:APPVEYOR_BUILD_NUMBER" - $env:VERSION_INFORMATIONAL = $github_tag_name + $env:VERSION_INFORMATIONAL = $env:APPVEYOR_BUILD_VERSION + $env:VERSION_SIMPLE = "$env:APPVEYOR_BUILD_VERSION.$env:APPVEYOR_BUILD_NUMBER" if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) { @@ -47,12 +44,28 @@ init: } else { + try { + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + $github_last_release=(Invoke-WebRequest -Uri https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/releases/latest) -join '`n' | ConvertFrom-Json + $github_tag_name=$github_last_release.tag_name + if ($github_tag_name -match '^([0-9]+\.[0-9]+\.[0-9]+)$') + { + $github_tag_ver = [version]$github_tag_name + $github_tag_name = "{0}.{1}.{2}" -f $github_tag_ver.Major, $github_tag_ver.Minor, ($github_tag_ver.Build + 1) + } + $env:VERSION_INFORMATIONAL = $github_tag_name + } catch { + $env:VERSION_INFORMATIONAL = "1.0.0" + Write-Host "Failed to get version from the last GitHub release falling back on '$env:VERSION_INFORMATIONAL' base version"; + } + $env:VERSION_INFORMATIONAL = "$env:VERSION_INFORMATIONAL$env:VERSION_SUFFIX" } Update-AppveyorBuild -Version $env:VERSION_INFORMATIONAL Write-Host "Using build version: $env:APPVEYOR_BUILD_VERSION"; + dotnet_csproj: patch: true file: '**\*.csproj'