Skip to content

Commit bb55f31

Browse files
author
Bart Koelman
committed
cibuild matrix
1 parent 8b69a32 commit bb55f31

File tree

2 files changed

+105
-105
lines changed

2 files changed

+105
-105
lines changed

Build.ps1

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
1-
# Gets the version suffix from the repo tag
2-
# example: v1.0.0-preview1-final => preview1-final
3-
function Get-Version-Suffix-From-Tag {
4-
$tag=$env:APPVEYOR_REPO_TAG_NAME
5-
$split=$tag -split "-"
6-
$suffix=$split[1..2]
7-
$final=$suffix -join "-"
8-
return $final
9-
}
10-
111
function CheckLastExitCode {
122
param ([int[]]$SuccessCodes = @(0), [scriptblock]$CleanupScript=$null)
133

144
if ($SuccessCodes -notcontains $LastExitCode) {
15-
$msg = "EXE RETURNED EXIT CODE $LastExitCode"
16-
throw $msg
5+
throw "Executable returned exit code $LastExitCode"
176
}
187
}
198

@@ -65,7 +54,9 @@ function RunCleanupCode {
6554

6655
function ReportCodeCoverage {
6756
if ($env:APPVEYOR) {
68-
dotnet codecov -f "**\coverage.cobertura.xml"
57+
if ($IsWindows) {
58+
dotnet codecov -f "**\coverage.cobertura.xml"
59+
}
6960
}
7061
else {
7162
dotnet reportgenerator -reports:**\coverage.cobertura.xml -targetdir:artifacts\coverage
@@ -74,8 +65,34 @@ function ReportCodeCoverage {
7465
CheckLastExitCode
7566
}
7667

77-
$revision = @{ $true = $env:APPVEYOR_BUILD_NUMBER; $false = 1 }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
78-
$revision = "{0:D4}" -f [convert]::ToInt32($revision, 10)
68+
function CreateNuGetPackage {
69+
if ($env:APPVEYOR_REPO_TAG -eq $true) {
70+
# Get the version suffix from the repo tag. Example: v1.0.0-preview1-final => preview1-final
71+
$tag = $env:APPVEYOR_REPO_TAG_NAME
72+
$segments = $tag -split "-"
73+
$suffixSegments = $segments[1..2]
74+
$versionSuffix = $suffixSegments -join "-"
75+
}
76+
else {
77+
# Get the version suffix from the auto-incrementing build number. Example: "123" => "pre-0123".
78+
if ($env:APPVEYOR_BUILD_NUMBER) {
79+
$revision = "{0:D4}" -f [convert]::ToInt32($env:APPVEYOR_BUILD_NUMBER, 10)
80+
$versionSuffix="pre-$revision"
81+
}
82+
else {
83+
$versionSuffix="pre-0001"
84+
}
85+
}
86+
87+
if ([string]::IsNullOrWhitespace($versionSuffix)) {
88+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
89+
}
90+
else {
91+
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$versionSuffix
92+
}
93+
94+
CheckLastExitCode
95+
}
7996

8097
dotnet tool restore
8198
CheckLastExitCode
@@ -91,27 +108,4 @@ CheckLastExitCode
91108

92109
ReportCodeCoverage
93110

94-
Write-Output "APPVEYOR_REPO_TAG: $env:APPVEYOR_REPO_TAG"
95-
96-
if ($env:APPVEYOR_REPO_TAG -eq $true) {
97-
$revision = Get-Version-Suffix-From-Tag
98-
Write-Output "VERSION-SUFFIX: $revision"
99-
100-
if ([string]::IsNullOrWhitespace($revision)) {
101-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
102-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts
103-
CheckLastExitCode
104-
}
105-
else {
106-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision"
107-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision
108-
CheckLastExitCode
109-
}
110-
}
111-
else {
112-
$packageVersionSuffix="pre-$revision"
113-
Write-Output "VERSION-SUFFIX: $packageVersionSuffix"
114-
Write-Output "RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$packageVersionSuffix"
115-
dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$packageVersionSuffix
116-
CheckLastExitCode
117-
}
111+
CreateNuGetPackage

appveyor.yml

Lines changed: 72 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,59 @@
1+
image:
2+
- Ubuntu
3+
- Visual Studio 2019
4+
15
version: '{build}'
2-
os: Visual Studio 2019
6+
7+
stack: postgresql
38

49
environment:
510
PGUSER: postgres
611
PGPASSWORD: Password12!
7-
ACCESS_TOKEN:
12+
GIT_ACCESS_TOKEN:
813
secure: g1T332Uarmdgtkftchpafa8tDP/7eM4O0BD6iu1wu+zR224IyH5R8pb4sTChr4Ia
914

10-
# REF: https://github.com/docascode/docfx-seed/blob/master/appveyor.yml
11-
before_build:
12-
- pwsh: |
15+
branches:
16+
only:
17+
- master
18+
- develop
19+
- unstable
20+
- /release\/.+/
21+
22+
pull_requests:
23+
do_not_increment_build_number: true
24+
25+
nuget:
26+
disable_publish_on_pr: true
27+
28+
matrix:
29+
fast_finish: true
30+
31+
for:
32+
-
33+
matrix:
34+
only:
35+
- image: Visual Studio 2019
36+
services:
37+
- postgresql101
38+
# REF: https://github.com/docascode/docfx-seed/blob/master/appveyor.yml
39+
before_build:
40+
- pwsh: |
1341
if (-Not $env:APPVEYOR_PULL_REQUEST_TITLE) {
1442
# https://dotnet.github.io/docfx/tutorial/docfx_getting_started.html
1543
git checkout $env:APPVEYOR_REPO_BRANCH -q
1644
}
1745
choco install docfx -y
18-
19-
after_build:
20-
- pwsh: |
46+
after_build:
47+
- pwsh: |
2148
CD ./docs
2249
& ./generate-examples.ps1
2350
& docfx docfx.json
2451
if ($lastexitcode -ne 0) {
25-
throw [System.Exception] "docfx build failed with exit code $lastexitcode."
52+
throw "docfx build failed with exit code $lastexitcode."
2653
}
27-
54+
2855
git config --global credential.helper store
29-
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:ACCESS_TOKEN):x-oauth-basic@github.com`n"
56+
Add-Content "$env:USERPROFILE\.git-credentials" "https://$($env:GIT_ACCESS_TOKEN):x-oauth-basic@github.com`n"
3057
git config --global user.email "jaredcnance@gmail.com"
3158
git config --global user.name "Jared Nance"
3259
git config --global core.autocrlf false
@@ -44,64 +71,43 @@ after_build:
4471
git push origin gh-pages -q
4572
echo "Documentation updated successfully."
4673
}
47-
48-
pull_requests:
49-
do_not_increment_build_number: true
50-
51-
branches:
52-
only:
53-
- master
54-
- develop
55-
- unstable
56-
- /release\/.+/
57-
58-
nuget:
59-
disable_publish_on_pr: true
60-
61-
services:
62-
- postgresql101
74+
artifacts:
75+
- path: .\**\artifacts\**\*.nupkg
76+
name: NuGet
77+
deploy:
78+
- provider: NuGet
79+
server: https://www.myget.org/F/research-institute/api/v2/package
80+
api_key:
81+
secure: 6CeYcZ4Ze+57gxfeuHzqP6ldbUkPtF6pfpVM1Gw/K2jExFrAz763gNAQ++tiacq3
82+
skip_symbols: false
83+
symbol_server: https://www.myget.org/F/research-institute/symbols/api/v2/package
84+
on:
85+
branch: develop
86+
- provider: NuGet
87+
server: https://www.myget.org/F/jadnc/api/v2/package
88+
api_key:
89+
secure: 6CeYcZ4Ze+57gxfeuHzqP6ldbUkPtF6pfpVM1Gw/K2jExFrAz763gNAQ++tiacq3
90+
skip_symbols: false
91+
on:
92+
branch: unstable
93+
- provider: NuGet
94+
name: production
95+
skip_symbols: false
96+
api_key:
97+
secure: SirU21S2S6F1OswSl8oiB4lYLLPchyyCIqtd2sWkTgHluelYfTa4PRaAfxlZP4fg
98+
on:
99+
branch: master
100+
appveyor_repo_tag: true
101+
- provider: NuGet
102+
skip_symbols: false
103+
api_key:
104+
secure: SirU21S2S6F1OswSl8oiB4lYLLPchyyCIqtd2sWkTgHluelYfTa4PRaAfxlZP4fg
105+
on:
106+
branch: /release\/.+/
107+
appveyor_repo_tag: true
63108

64109
build_script:
65110
- pwsh: dotnet --version
66111
- pwsh: .\Build.ps1
67112

68113
test: off
69-
70-
artifacts:
71-
- path: .\**\artifacts\**\*.nupkg
72-
name: NuGet
73-
74-
deploy:
75-
- provider: NuGet
76-
server: https://www.myget.org/F/research-institute/api/v2/package
77-
api_key:
78-
secure: 6CeYcZ4Ze+57gxfeuHzqP6ldbUkPtF6pfpVM1Gw/K2jExFrAz763gNAQ++tiacq3
79-
skip_symbols: false
80-
symbol_server: https://www.myget.org/F/research-institute/symbols/api/v2/package
81-
on:
82-
branch: develop
83-
84-
- provider: NuGet
85-
server: https://www.myget.org/F/jadnc/api/v2/package
86-
api_key:
87-
secure: 6CeYcZ4Ze+57gxfeuHzqP6ldbUkPtF6pfpVM1Gw/K2jExFrAz763gNAQ++tiacq3
88-
skip_symbols: false
89-
on:
90-
branch: unstable
91-
92-
- provider: NuGet
93-
name: production
94-
skip_symbols: false
95-
api_key:
96-
secure: SirU21S2S6F1OswSl8oiB4lYLLPchyyCIqtd2sWkTgHluelYfTa4PRaAfxlZP4fg
97-
on:
98-
branch: master
99-
appveyor_repo_tag: true
100-
101-
- provider: NuGet
102-
skip_symbols: false
103-
api_key:
104-
secure: SirU21S2S6F1OswSl8oiB4lYLLPchyyCIqtd2sWkTgHluelYfTa4PRaAfxlZP4fg
105-
on:
106-
branch: /release\/.+/
107-
appveyor_repo_tag: true

0 commit comments

Comments
 (0)