@@ -20,47 +20,35 @@ install:
20
20
environment :
21
21
VERSION_SIMPLE : ' {version}'
22
22
VERSION_INFORMATIONAL : ' {version}'
23
- VERSION_UNSTABLE_SUFFIX : ' - preview-$(APPVEYOR_BUILD_NUMBER) '
23
+ VERSION_UNSTABLE_SUFFIX : ' preview'
24
24
APPVEYOR_TOKEN :
25
25
secure : LtoVAPATN9iTCl1zkCvEktqP92QSEEngyS3vqG3GphE=
26
-
26
+
27
27
init :
28
28
- ps : |
29
- $env:VERSION_INFORMATIONAL = $env:APPVEYOR_BUILD_VERSION
30
- $env:VERSION_SIMPLE = "$env:APPVEYOR_BUILD_VERSION.$env:APPVEYOR_BUILD_NUMBER "
29
+ $env:VERSION_SIMPLE = $env:APPVEYOR_BUILD_VERSION.TrimStart("v")
30
+ $env:VERSION_INFORMATIONAL = "$env:VERSION_SIMPLE "
31
31
$env:GITHUB_REPO_API = "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/tags"
32
32
33
33
if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
34
34
### CHECK IF A IT'S A TAGGED BUILD
35
- $git_current_tag = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
35
+ $env:APPVEYOR_REPO_TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
36
36
Write-Host "Building a tagged Git commit: $git_current_tag";
37
-
38
- if ($git_current_tag -match '^([0-9]+\.[0-9]+\.[0-9]+)$' -Or $git_current_tag -match '([0-9]+[\.-][0-9]+[\.-][0-9]+-[-A-Za-z0-9]+)') {
39
- $env:VERSION_INFORMATIONAL = "$git_current_tag"
37
+ if ($env:APPVEYOR_REPO_TAG_NAME -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
38
+ $tag_ver = [version]$env:APPVEYOR_REPO_TAG_NAME
39
+ $env:VERSION_INFORMATIONAL = "{0}.{1}.{2}" -f $tag_ver.Major, $tag_ver.Minor, $tag_ver.Build
40
+ $env:VERSION_SIMPLE = "$env:VERSION_INFORMATIONAL.$env:APPVEYOR_BUILD_NUMBER"
40
41
}
41
- } else {
42
- ### OTHERWISE IT'S A REGULAR BUILD
43
- try {
44
- ### TRY TO GET VERSION FROM THE LATEST GITHUB TAG/REALEASE
45
- [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
46
- $github_latest_tags=(Invoke-WebRequest -Uri $env:GITHUB_REPO_API) -join '`n' | ConvertFrom-Json
47
- $github_last_tag=$github_latest_tags[0].name.TrimStart("v")
48
- if ($github_last_tag -match '^([0-9]+\.[0-9]+\.[0-9]+)$') {
49
- $github_tag_ver = [version]$github_last_tag
50
- $github_last_tag = "{0}.{1}.{2}" -f $github_tag_ver.Major, $github_tag_ver.Minor, ($github_tag_ver.Build + 1)
51
- }
52
- $env:VERSION_INFORMATIONAL = $github_last_tag
53
- } catch {
54
- $env:VERSION_INFORMATIONAL = "1.0.0"
55
- Write-Host "Failed to get version from the last GitHub release falling back on '$env:VERSION_INFORMATIONAL' base version";
56
- }
57
-
58
- $env:VERSION_INFORMATIONAL = "$env:VERSION_INFORMATIONAL$env:VERSION_UNSTABLE_SUFFIX"
42
+ } elseif ($env:VERSION_INFORMATIONAL -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
43
+ $current_ver = [version]$env:VERSION_INFORMATIONAL
44
+ $env:VERSION_INFORMATIONAL = "{0}.{1}.{2}" -f $current_ver.Major, $current_ver.Minor, $current_ver.Build
45
+ $env:VERSION_INFORMATIONAL = "{0}-{1}{2}" -f $env:VERSION_INFORMATIONAL, $env:VERSION_UNSTABLE_SUFFIX, $env:APPVEYOR_BUILD_NUMBER
59
46
}
60
47
61
48
### MAKE CALCULATED INFORMATIONAL VERSION THE ACTUAL BUILD VERSION
62
49
Update-AppveyorBuild -Version $env:VERSION_INFORMATIONAL
63
- Write-Host "Using build version: $env:APPVEYOR_BUILD_VERSION";
50
+ Write-Host "Using build version: $env:VERSION_SIMPLE"
51
+ Write-Host "Using (informational) build version: $env:VERSION_INFORMATIONAL"
64
52
65
53
dotnet_csproj :
66
54
patch : true
@@ -125,22 +113,24 @@ deploy:
125
113
api_key :
126
114
secure : 3zmnmVBweTgdk4SBM/rWHdC9JOM9s0pxm1bw1d+WHDo=
127
115
artifact : NuGet_Files
128
-
129
116
130
117
after_deploy :
131
- - ps : |
118
+ - ps : |
132
119
if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
133
120
$apiUrl = 'https://ci.appveyor.com/api'
134
121
$headers = @{
135
122
"Authorization" = "Bearer $env:APPVEYOR_TOKEN"
136
123
"Content-type" = "application/json"
137
- "Accept" = "application/json"
138
124
}
139
- $build = @{
140
- nextBuildNumber = 1
125
+ Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/build-number" -Body '{"nextBuildNumber": 1 }' -Headers $headers
126
+
127
+ $env:APPVEYOR_REPO_TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
128
+ if ($env:APPVEYOR_REPO_TAG_NAME -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
129
+ $tag_ver = [version]$env:APPVEYOR_REPO_TAG_NAME
130
+ $ver_format = "version: {0}.{1}.{2}.{3}" -f $tag_ver.Major, $tag_ver.Minor, ($tag_ver.Build + 1), '{build}'
131
+ $headers."Content-type" = "text/plain";
132
+ Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/yaml" -Body $ver_format -Headers $headers
141
133
}
142
- $json = $build | ConvertTo-Json
143
- Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/build-number" -Body $json -Headers $headers
144
134
}
145
135
146
136
# Start builds on tags only (GitHub and BitBucket)
0 commit comments