forked from RockLib/RockLib.Logging
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRockLib.Logging.appveyor.yml
114 lines (101 loc) · 4.55 KB
/
RockLib.Logging.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
version: 'RockLib.Logging.{build}.0.0-ci'
image: Visual Studio 2017
configuration: Release
only_commits:
files:
- RockLib.Logging/
- RockLib.Logging.Tests/
- RockLib.Logging.sln
- RockLib.Logging.appveyor.yml
- .gitmodules
install:
- git submodule update --init --recursive --remote
before_build:
- ps: |
# The path to the solution to restore.
$sln_path = "RockLib.Logging.sln"
# The path to the main csproj file. It will be patched during the build.
$csproj_path = "RockLib.Logging\RockLib.Logging.csproj"
# The version of the build artifact's nuget package when created by CI builds.
$ci_package_version = "$Env:appveyor_build_number.0.0-ci"
# This before_build script does four things:
#
# 1) Update the csproj's package release notes to be the current commit message.
# 2) Synchronize the AppVeyor build version and the csproj's package version.
# a) If the current build is a deploy build*, update the AppVeyor build version to match
# the csproj's nuget package version.
# b) If the current build is a CI build*, update the csproj's package version to match
# the AppVeyor build version.
# 3) Set an AppVeyor build variable named 'csproj_build_version' to the csproj's package version.
# This value is used by deploy providers to determine whether the current commit should be deployed.
# 4) Restore packages for the sln. .NET Standard libraries won't build without restoring first.
#
# *The current build is a deploy build if the 'appveyor_repo_tag' variable is 'true' and the
# 'appveyor_repo_tag_name' variable is the the value of the 'csproj_build_version' variable, as set in
# #3 above. Otherwise, the current build is a CI build.
function Get-Csproj-Build-Version ($csproj)
{
$package_id = $csproj.SelectSingleNode("/Project/PropertyGroup/PackageId").InnerText
$package_version = $csproj.SelectSingleNode("/Project/PropertyGroup/PackageVersion").InnerText
Return "$package_id.$package_version"
}
function Update-Package-Release-Notes ($csproj)
{
$commit_message = "$Env:appveyor_repo_commit_message`n`n$Env:appveyor_repo_commit_message_extended"
$commit_message = $commit_message.Replace("\n", "`n").TrimEnd()
$package_release_notes_node = $csproj.SelectSingleNode("/Project/PropertyGroup/PackageReleaseNotes")
$package_release_notes_node.InnerText = $commit_message
}
function Synchronize-AppVeyor-And-Csproj-Versions ($csproj)
{
$csproj_build_version = Get-Csproj-Build-Version $csproj
If ($Env:appveyor_repo_tag -eq "true" -AND $Env:appveyor_repo_tag_name -eq $csproj_build_version) {
# If this is a deploy build, update the AppVeyor build version to match the csproj's package version.
Update-AppVeyorBuild -Version $csproj_build_version
} else {
# Else, update the csproj's package version to match the AppVeyor build version.
$package_version_node = $csproj.SelectSingleNode("/Project/PropertyGroup/PackageVersion")
$package_version_node.InnerText = $ci_package_version
}
}
function Set-Csproj-Build-Version-Variable ($csproj)
{
$csproj_build_version = Get-Csproj-Build-Version $csproj
Set-AppVeyorBuildVariable -Name "csproj_build_version" -Value $csproj_build_version
}
# The $csproj xml object contains the contents of the csproj file.
$csproj = [xml](Get-Content $csproj_path)
Update-Package-Release-Notes $csproj
Synchronize-AppVeyor-And-Csproj-Versions $csproj
Set-Csproj-Build-Version-Variable $csproj
# Patch the csproj file with the modified xml object after all changes have been made.
$csproj.Save((Get-Item $csproj_path))
nuget restore $sln_path
build:
project: RockLib.Logging.sln
verbosity: minimal
artifacts:
- path: '**/RockLib.Logging.*.nupkg'
deploy:
- provider: GitHub
tag: $(appveyor_repo_tag_name)
release: $(appveyor_repo_commit_message)
description: $(appveyor_repo_commit_message_extended)
auth_token:
secure: yjDw1QLeuxM3Wvq9ZEJIB8JaEK/L2e7MhwrKicm3/SBh0FwbAEb3Fpg82h0fFALU
on:
appveyor_repo_tag: true
appveyor_repo_tag_name: $(csproj_build_version)
- provider: NuGet
api_key:
secure: cWRnVOIg+HzwFkVkKWFBMbkSC0753NI/LCcxQErp8ulvVQAFCIbH4Kml/XnpQiVM
on:
appveyor_repo_tag: true
appveyor_repo_tag_name: $(csproj_build_version)
notifications:
- provider: Email
to:
- itteamappcore@quickenloans.com
on_build_success: false
on_build_failure: false
on_build_status_changed: true