-
-
Notifications
You must be signed in to change notification settings - Fork 22
/
appveyor.yml
109 lines (95 loc) · 4.23 KB
/
appveyor.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Operating system (build VM template)
os: Windows Server 2016
# If the build configuration does not specify build worker image
# then Visual Studio 2015 image is used.
image: Visual Studio 2017
# Restrict to Git branches below
branches:
only:
- master
environment:
VERSION_SIMPLE: '{version}'
VERSION_INFORMATIONAL: '{version}'
VERSION_UNSTABLE_SUFFIX: 'preview'
APPVEYOR_TOKEN:
secure: LtoVAPATN9iTCl1zkCvEktqP92QSEEngyS3vqG3GphE=
init:
- ps: |
$env:VERSION_SIMPLE = $env:APPVEYOR_BUILD_VERSION.TrimStart("v")
$env:VERSION_INFORMATIONAL = "$env:VERSION_SIMPLE"
$env:GITHUB_REPO_API = "https://api.github.com/repos/$env:APPVEYOR_REPO_NAME/tags"
if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
### CHECK IF A IT'S A TAGGED BUILD
$env:APPVEYOR_REPO_TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
Write-Host "Building a tagged Git commit: $git_current_tag";
if ($env:APPVEYOR_REPO_TAG_NAME -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$tag_ver = [version]$env:APPVEYOR_REPO_TAG_NAME
$env:VERSION_INFORMATIONAL = "{0}.{1}.{2}" -f $tag_ver.Major, $tag_ver.Minor, $tag_ver.Build
$env:VERSION_SIMPLE = "$env:VERSION_INFORMATIONAL.$env:APPVEYOR_BUILD_NUMBER"
}
} elseif ($env:VERSION_INFORMATIONAL -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$current_ver = [version]$env:VERSION_INFORMATIONAL
$env:VERSION_INFORMATIONAL = "{0}.{1}.{2}" -f $current_ver.Major, $current_ver.Minor, $current_ver.Build
$env:VERSION_INFORMATIONAL = "{0}-{1}{2}" -f $env:VERSION_INFORMATIONAL, $env:VERSION_UNSTABLE_SUFFIX, $env:APPVEYOR_BUILD_NUMBER
}
### MAKE CALCULATED INFORMATIONAL VERSION THE ACTUAL BUILD VERSION
Update-AppveyorBuild -Version $env:VERSION_INFORMATIONAL
Write-Host "Using build version: $env:VERSION_SIMPLE"
Write-Host "Using (informational) build version: $env:VERSION_INFORMATIONAL"
dotnet_csproj:
patch: true
file: '**\*.csproj'
assembly_version: $(VERSION_SIMPLE)
file_version: $(VERSION_SIMPLE)
version: $(VERSION_INFORMATIONAL)
package_version: $(VERSION_INFORMATIONAL)
informational_version: $(VERSION_INFORMATIONAL)
# Scripts that run after cloning repository
install:
- dotnet restore
# Run scripts below before
before_build:
- where msbuild
- cmd: msbuild /t:Clean
# To run your custom scripts instead of automatic MSBuild
build_script:
- cmd: msbuild /t:Rebuild
- ps: .\build.ps1
after_build:
- cmd: 7z a RevitAddin_2014-2020.zip %APPVEYOR_BUILD_FOLDER%\dist\*.*
- cmd: 7z a RevitAddin_2014-2020.zip %APPVEYOR_BUILD_FOLDER%\dist\**\*.*
artifacts:
- path: RevitAddin_2014-2020.zip
name: RevitAddin
after_deploy:
- ps: |
if ($env:APPVEYOR_REPO_TAG -eq "true" -and $env:APPVEYOR_REPO_TAG_NAME) {
$apiUrl = 'https://ci.appveyor.com/api'
$headers = @{
"Authorization" = "Bearer $env:APPVEYOR_TOKEN"
"Content-type" = "application/json"
}
Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/build-number" -Body '{"nextBuildNumber": 1 }' -Headers $headers
## Update the version in case of ragged build
$env:APPVEYOR_REPO_TAG_NAME = $env:APPVEYOR_REPO_TAG_NAME.TrimStart("v")
if ($env:APPVEYOR_REPO_TAG_NAME -match '^([0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?)$') {
$tag_ver = [version]$env:APPVEYOR_REPO_TAG_NAME
$ver_format = "version: {0}.{1}.{2}.{3}" -f $tag_ver.Major, $tag_ver.Minor, ($tag_ver.Build + 1), '{build}'
$headers."Content-type" = "text/plain";
Invoke-RestMethod -Method Put "$apiUrl/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/settings/yaml" -Body $ver_format -Headers $headers
}
}
# Deploy to GitHub releases
deploy:
-
provider: GitHub
auth_token:
secure: 2+d0KgCbWQpUR8TZfzvUEzbi4NQP6F/Tt0PUwLn6jXZCyO8FnrFVFJPsFa0QBQFl
artifact: RevitAddin
draft: false
force_update: true
prerelease: false
release: "Revit 2014-2020 C# Addin Template fro Visual Studio v$(APPVEYOR_REPO_TAG_NAME)"
tag: $(APPVEYOR_REPO_TAG_NAME)
on:
appveyor_repo_tag: true