-
Notifications
You must be signed in to change notification settings - Fork 3
/
appveyor.yml
274 lines (218 loc) · 8.89 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# Notes:
# - Minimal appveyor.yml file is an empty file. All sections are optional.
# - Indent each level of configuration with 2 spaces. Do not use tabs!
# - All section names are case-sensitive.
# - Section names should be unique on each level.
#---------------------------------#
# general configuration #
#---------------------------------#
# Any CPU will produce x64 for NotakeyNETProvider,
# which is the only project that has a bit-dependency
# (due to the version of credentialprovider_*.dll reference)
platform: Any CPU
configuration: Release
# version format
version: 1.0.{build}
# branches to build
branches:
# whitelist
only:
# - master
- /\d\.\d\.\d/
# Do not build on tags (GitHub and BitBucket)
skip_tags: false
# Start builds on tags only (GitHub and BitBucket)
skip_non_tags: true
#---------------------------------#
# environment configuration #
#---------------------------------#
# Build worker image (VM template)
image: Visual Studio 2015
init:
- git config --global core.autocrlf true
install:
- set PATH=C:\Ruby23-x64\bin;%PATH%
- set "PATH=C:\Program Files\wkhtmltopdf\bin;%PATH%"
# Set "build version number" to "short-commit-hash" or when tagged to "tag name" (Travis style)
- ps: |
$latestTag = $env:APPVEYOR_REPO_TAG_NAME
if ($env:APPVEYOR_REPO_TAG -eq "true")
{
$gitCommitTag = $(git describe --exact-match $env:APPVEYOR_REPO_COMMIT)
if ($env:APPVEYOR_REPO_TAG_NAME -eq $gitCommitTag)
{
Add-AppveyorMessage -Message "Using git tag: $gitCommitTag"
}
else
{
Add-AppveyorMessage -Message "Tag name missmatch $env:APPVEYOR_REPO_TAG_NAME and $gitCommitTag"
throw;
}
}
else
{
$latesttag=$(git describe)
$out = (git checkout $latesttag 2>&1 | % { $_.ToString() })
Add-AppveyorMessage -Message "Build is not initiated by git tag. Checking out latest tag: $out"
$latestTag = $latesttag
}
$hasBuildNumber = $latestTag -match '[0-9]+(\.([0-9]+|\*)){1,3}'
$latestTagBuildNumberFormattedCorrectly = $matches[0] -eq $latestTag
if (!$latestTagBuildNumberFormattedCorrectly)
{
Add-AppveyorMessage -Message "Latest tag not formated correctly."
return;
}
$env:buildtag = $latestTag
$globalAssemblyFile = "GlobalAssemblyInfo.cs"
$globalAssemblyVersion = Get-Content .\$globalAssemblyFile
$hasAssemblyVersion = "'"+$globalAssemblyVersion+"'" -match 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
if (!$hasAssemblyVersion)
{
Add-AppveyorMessage -Message "No AssemblyVersion found, using 1.0.0.0 instead."
$major=1
$minor=0
$build=0
$revision=0
}
else
{
$assemblyVersionFormattedCorrectly = $matches[0] -match "(?<major>[0-9]+)\.(?<minor>[0-9])+(\.(?<build>([0-9]+)))?(\.(?<revision>([0-9])))?"
if (!$assemblyVersionFormattedCorrectly)
{
Add-AppveyorMessage -Message "The Global Assembly Version is not formatted correctly."
return;
}
$assemblyVersionMatchesTag = $matches[0] -like $latestTag+'*'
if (!$assemblyVersionMatchesTag)
{
Add-AppveyorMessage -Message "The Global Assembly Version does not matches checked out tag."
return;
}
$major=$matches['major'] -as [int]
$minor=$matches['minor'] -as [int]
$build=$matches['build'] -as [int]
$revision=$matches['revision'] -as [int]
}
$AssemblyVersion = "$major.$minor.$build.$revision"
Add-AppveyorMessage -Message "Global Assembly Version: $AssemblyVersion ."
$AssemblyFileVersion = "$major.$minor.$build.$env:APPVEYOR_BUILD_NUMBER"
$AssemblyInformationalVersion = "$AssemblyFileVersion-$env:APPVEYOR_REPO_SCM" + ($env:APPVEYOR_REPO_COMMIT).Substring(0, 8)
Add-AppveyorMessage -Message "Patched File Version: $AssemblyFileVersion"
Add-AppveyorMessage -Message "Patched Informational Version: $AssemblyInformationalVersion"
Update-AppveyorBuild -Version "$AssemblyFileVersion"
$fileVersion = 'AssemblyFileVersion("' + $AssemblyFileVersion + '")';
$informationalVersion = 'AssemblyInformationalVersion("' + $AssemblyInformationalVersion + '")';
$foundFiles = get-childitem .\*AssemblyInfo.cs -recurse
foreach( $file in $foundFiles )
{
if ($file.Name -eq $globalAssemblyFile)
{
#Don't patch the global info.
continue;
}
$content = Get-Content "$file"
Add-AppveyorMessage -Message "Patching $file"
$env:afv = $AssemblyFileVersion
$env:aiv = $AssemblyInformationalVersion
$hasFileAssemblyVersion = "'"+$content+"'" -match 'AssemblyVersion\("[0-9]+(\.([0-9]+|\*)){1,3}"\)'
$hasDefaultAssemblyVersion = "'"+$content+"'" -match 'AssemblyVersion\("(1.0.0)(.0)*"\)'
if ($hasFileAssemblyVersion -and !$hasDefaultAssemblyVersion)
{
$assemblyVersionFormattedCorrectly = $matches[0] -match "(?<major>[0-9]+)\.(?<minor>[0-9])+(\.(?<build>([0-9]+)))?(\.(?<revision>([0-9])))?"
if ($assemblyVersionFormattedCorrectly)
{
$fileMajor=$matches['major'] -as [int]
$fileMinor=$matches['minor'] -as [int]
$fileBuild=$matches['build'] -as [int]
$fileRevision=$matches['revision'] -as [int]
$env:afv = "$fileMajor.$fileMinor.$fileBuild.$env:APPVEYOR_BUILD_NUMBER"
$env:aiv = "$env:afv-$env:APPVEYOR_REPO_SCM" + ($env:APPVEYOR_REPO_COMMIT).Substring(0, 8)
Add-AppveyorMessage -Message "• Specific AssemblyVersion found, using that instead: $fileMajor.$fileMinor.$fileBuild.$fileRevision ."
Add-AppveyorMessage -Message " ○ Patched File Version: $env:afv"
Add-AppveyorMessage -Message " ○ Patched Informational Version: $env:aiv"
}
else
{
Add-AppveyorMessage -Message "• Specific AssemblyVersion found, but it's default 1.0.0.0 or not formatted correctly, skipping."
}
}
}
- cd docs
- cd manual
- rem bundle install
- rem choco install wkhtmltopdf --version 0.12.4 -ia "'/D=C:\wkhtmltopdf'"
- rem bundle exec middleman build --verbose
- cd ..
- cd ..
before_build:
- nuget restore
build:
project: NotakeyNETProvider.sln
after_build:
- ps: |
$dir = "notakey-wcp-64bit $env:afv"
$env:wcpartifact = $dir
$env:changelogContent = (Get-Content changelogs\$env:buildtag.md) -join [Environment]::NewLine
mkdir "$dir"
mkdir "$dir\NotakeyNETProvider\bin\x64\$env:configuration\"
mkdir "$dir\NotakeyBGService\bin\$env:configuration"
mkdir "$dir\CredUIInvokerNET\bin\$env:configuration\"
cp "NotakeyNETProvider\bin\x64\$env:configuration\*" "$dir\NotakeyNETProvider\bin\x64\$env:configuration\"
cp "NotakeyBGService\bin\$env:configuration\*" "$dir\NotakeyBGService\bin\$env:configuration\"
cp "CredUIInvokerNET\bin\$env:configuration\*" "$dir\CredUIInvokerNET\bin\$env:configuration\"
Get-ChildItem ".\" -include *.reg, *.pdf, register*.bat, unregister*.bat -Recurse | ?{-not ($_.PSIsContainer -or (Test-Path "$dir\$_"))} | Copy-Item -Destination "$dir"
mv "$dir\NotakeyBGService\bin\$env:configuration\winsw.*" "$dir\NotakeyBGService\"
$oldConfig = "Release"
$newConfig = "Debug"
$files = (Get-ChildItem -path .\* -include register*.bat, winsw.xml -recurse)
if ($env:configuration -eq "Release")
{
Remove-Item –path "$dir\*" -include *.pdb –recurse
$oldConfig = "Debug"
$newConfig = "Release"
}
foreach ($file in $files)
{
(Get-Content $file.PSPath) |
Foreach-Object { $_ -replace $oldConfig, $newConfig } |
Set-Content $file.PSPath
}
7z a -r "$dir.zip" "$dir\*"
Remove-Item –path "$dir" –recurse
artifacts:
- path: "$(wcpartifact).zip"
name: '$(wcpartifact)'
- path: 'register*.bat'
- path: 'unregister*.bat'
- path: '**\*.reg'
- path: '**\*.pdf'
- path: NotakeyNETProvider\bin\x64\$(configuration)
name: 'NotakeyNETProvider'
- path: NotakeyBGService\bin\$(configuration)
name: 'NotakeyBGService'
- path: CredUIInvokerNET\bin\$(configuration)
name: 'CredUIInvokerNET'
assembly_info:
patch: true
file: '**\AssemblyInfo.*'
assembly_version: $(afv)
assembly_file_version: $(afv)
assembly_informational_version: $(aiv)
deploy:
release: 'Notakey Windows Credential Provider $(afv)'
description: '$(changelogContent)'
provider: GitHub
auth_token:
secure: 6NEgRf+G3hcuxZrZtkykH/vQu6e4f2Xp6BPCna7z8ElnSR6zca0AIZ/WjG2hoLsk
artifact: '$(wcpartifact)'
draft: false
prerelease: false
#---------------------------------#
# notifications #
#---------------------------------#
notifications:
- provider: Slack
auth_token:
secure: Tw2kLnjsD3x7En1bjF0ubvbnuIRGoQu3F1q4eMrApJk=
channel: '#dev'