forked from chummer5a/chummer5a
-
Notifications
You must be signed in to change notification settings - Fork 0
/
appveyor.yml
123 lines (123 loc) · 5.02 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
version: 5.222.{build}
branches:
only:
- master
skip_tags: true
image: Visual Studio 2022
configuration: Release
platform: Any CPU
init:
- ps: iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
assembly_info:
patch: true
file: '**\AssemblyInfo.*'
assembly_version: '{version}'
assembly_file_version: '{version}'
assembly_informational_version: '{version}'
environment:
SolutionDir: C:\projects\chummer\
install:
- ps: ''
nuget:
disable_publish_on_pr: true
cache:
- packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified
- '%USERPROFILE%\.nuget\packages -> **\project.json' # project.json cache
before_build:
- ps: |
$token = $env:api_token
$headers = @{
"Authorization" = "Bearer $token"
"Content-type" = "application/json"
}
$apiURL = "https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG"
$history = Invoke-RestMethod -Uri "$apiURL/history?recordsNumber=2" -Headers $headers -Method Get
$exitBuild = $false
if ($history.builds.Count -eq 2)
{
$CurrentCommitID = $history.builds[0].commitId
$PreviousCommitID = $history.builds[1].commitId
Write-host "Current Commit ID: $CurrentCommitID"
Write-host "Previous Commit ID: $PreviousCommitID"
if (($CurrentCommitID -eq $PreviousCommitID) -and ($env:APPVEYOR_SCHEDULED_BUILD -eq $true))
{
$PreviousCommitStatus = $history.builds[1].status
if ($PreviousCommitStatus -eq "failed")
{
Write-Host "Current Commit ID is the same as previous, but previous build failed, so going ahead and building."
}
else
{
Write-host "Current Commit ID is the same as previous, exiting build."
$exitBuild = $true
}
}
}
# Needs to be in this format, otherwise Exit-AppVeyorBuild won't work. That command has to be the final one executed in the script
if ($exitBuild)
{
Exit-AppVeyorBuild
}
else
{
nuget restore
& 'C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\TextTransform.exe' 'C:\projects\chummer\Chummer\Properties\contributors.tt'
Set-AppveyorBuildVariable -Name OldMinorVersion -Value $($env:APPVEYOR_BUILD_VERSION).Split('.')[1]
Write-Host "Environment Variable: $env:OldMinorVersion"
$Assemblyfile = "C:\projects\chummer\Chummer\Properties\AssemblyInfo.cs"
$regex = new-object System.Text.RegularExpressions.Regex ('(AssemblyVersion(Attribute)?\s*\(\s*\")(.*)(\"\s*\))', [System.Text.RegularExpressions.RegexOptions]::MultiLine)
$content = [IO.File]::ReadAllText($assemblyFile)
$version = $null
$match = $regex.Match($content)
if($match.Success) {
$version = $match.groups[3].value
}
$Major = $version.Split('.')[0]
$Minor = $version.Split('.')[1]
if ($Minor -ne $($env:OldMinorVersion))
{
Write-Host "Current Minor: $Minor"
Write-Host "Old Minor: $($env:OldMinorVersion))"
Write-Host "Resetting build version to 1, assuming that a new .0 release has been issued already."
$apiUrl = 'https://ci.appveyor.com/api/projects/$accountName/$projectSlug'
$BuildNumber = '{ nextBuildNumber: 1; }'
$Format = '{ versionFormat: $Major.$Minor.1; }'
# get project with last build details
Invoke-RestMethod -Method Put -Uri "$apiUrlsettings/build-number" -Headers $headers -Body $BuildNumber
Invoke-RestMethod -Method Put -Uri "$apiUrl/settings" -Headers $headers -Body $BuildNumber
Update-AppveyorBuild -Version "$Major.$Minor.1"
}
else
{
Update-AppveyorBuild -Version "$Major.$Minor.$env:appveyor_build_number"
}
Write-Host "Setting Docker target OS to Linux."
& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon -SwitchLinuxEngine
}
build:
project: Chummer.sln
verbosity: minimal
after_build:
- ps: 7z a Chummer.Nightly.zip C:\projects\chummer\Chummer\bin\release\* -r
test_script:
- cmd: vstest.console /logger:Appveyor "%APPVEYOR_BUILD_FOLDER%\Chummer.Tests\bin\Release\Chummer.Tests.dll"
artifacts:
- path: Chummer.Nightly.zip
name: Chummer
deploy:
- provider: GitHub
tag: Nightly-v$(appveyor_build_version)
auth_token:
secure: eh1lnecGeM5jlVA2x7bLrKGaN/5dft7U4LSNiMenMrDTj7rHinhLQnTTnL2BXY5J
artifact: Chummer
draft: false
prerelease: true
on_failure:
- ps: |
Update-AppveyorBuild -Version "$Major.$Minor.$env:appveyor_build_number-$(Get-Date -format HHmmss)-failed"
if ($env:APPVEYOR_SCHEDULED_BUILD -eq $true)
{
# Webhook throws errors during build.
Invoke-RestMethod https://raw.githubusercontent.com/DiscordHooks/appveyor-discord-webhook/master/send.ps1 -o send.ps1
./send.ps1 failure $env:DISCORD_WEBHOOK_URL
}