Skip to content

Commit b5e3cbe

Browse files
authored
Merge PR #299: Update AppVeyor config for tagged versioning (#299)
* Update AppVeyor config for tagged versioning * Update install script and add local test script * Switch to using AV build number as assembly revision
1 parent 36784aa commit b5e3cbe

15 files changed

+94
-50
lines changed

appveyor.yml

Lines changed: 4 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,11 @@ dotnet_csproj:
88
file: '**\*.csproj'
99
version: $(VERSION)
1010
package_version: $(VERSION)
11-
assembly_version: 1.0.0.999
12-
file_version: 1.0.0.999
11+
assembly_version: $(BIN_VERSION)
12+
file_version: $(BIN_VERSION)
1313
informational_version: $(VERSION)
1414
install:
15-
- ps: |-
16-
$commit = $(git rev-parse --short HEAD)
17-
18-
$masterBranches = @("master");
19-
20-
if ($masterBranches -contains $env:APPVEYOR_REPO_BRANCH) {
21-
$branch = "";
22-
} else {
23-
$branch = "-$env:APPVEYOR_REPO_BRANCH";
24-
}
25-
26-
if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {
27-
$suffix = "-pr$env:APPVEYOR_PULL_REQUEST_NUMBER";
28-
} else {
29-
$suffix = "";
30-
}
31-
32-
$build = "_${env:APPVEYOR_BUILD_NUMBER}"
33-
34-
$version = "1.0-git$commit";
35-
36-
$av_version = "$version$branch$suffix$build";
37-
$env:APPVEYOR_BUILD_VERSION=$av_version;
38-
$env:VERSION=$version;
39-
40-
write-host -n "new version: ";
41-
write-host -f green $av_version;
42-
43-
appveyor UpdateBuild -Version $av_version
15+
- ps: tools/appveyor-install.ps1
4416
nuget:
4517
project_feed: true
4618
disable_publish_on_pr: true
@@ -52,22 +24,4 @@ build:
5224
publish_nuget_symbols: true
5325
verbosity: normal
5426
test_script:
55-
- ps: |-
56-
$proj = ".\test\ICSharpCode.SharpZipLib.TestBootstrapper\ICSharpCode.SharpZipLib.TestBootstrapper.csproj";
57-
$resxml = ".\docs\nunit3-test-results-debug.xml";
58-
59-
# Nuget 3 Console runner:
60-
#$tester = "nunit3-console .\test\ICSharpCode.SharpZipLib.Tests\bin\$($env:CONFIGURATION)\netcoreapp2.0\ICSharpCode.SharpZipLib.Tests.dll"
61-
62-
# Bootstrapper:
63-
$tester = "dotnet run -f netcoreapp2 -p $proj -c $env:CONFIGURATION";
64-
iex "$tester --explore=tests.xml";
65-
66-
[xml]$xml = Get-Content("tests.xml");
67-
$assembly = select-xml "/test-suite[@type='Assembly']" $xml | select -f 1 -exp Node;
68-
$testcases = select-xml "//test-case" $xml | % { Add-AppveyorTest -Name $_.Node.fullname -Framework NUnit -Filename $assembly.name };
69-
70-
iex "$tester --result=$resxml";
71-
72-
$wc = New-Object 'System.Net.WebClient';
73-
$wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit3/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $resxml));
27+
- ps: tools/appveyor-test.ps1

tools/appveyor-install.ps1

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Describe from the lastest tag matching 'vX.Y.Z', removing the initial 'v'
2+
$description = $(git describe --long --tags --match 'v[0-9]*.[0-9]*.[0-9]*').substring(1);
3+
4+
# Description is in the format of: TAG-COMMITS_SINCE_TAG-COMMIT_HASH
5+
$dparts = $description -split('-');
6+
$short_version = $dparts[0];
7+
$commits_since_tag = $dparts[1];
8+
$commit_hash = $dparts[2];
9+
10+
$masterBranches = @("master");
11+
12+
# If not in master branch, set branch variable
13+
$av_branch = $env:APPVEYOR_REPO_BRANCH;
14+
$branch = $(if ($masterBranches -contains $av_branch) { "" } else { "-$av_branch" });
15+
16+
# If this is a PR, add the PR suffix
17+
$suffix = $(if ($env:APPVEYOR_PULL_REQUEST_NUMBER) { "-pr$env:APPVEYOR_PULL_REQUEST_NUMBER" } else { "" });
18+
19+
# Main build is when we're in the master branch and not a PR
20+
$is_main_build = ($branch -eq "" -and $suffix -eq "")
21+
22+
# Use appveyor build number as the last version digit (x.x.x.B)
23+
$build = ${env:APPVEYOR_BUILD_NUMBER}
24+
25+
$is_release_build = ($commits_since_tag -eq 0 -and $is_main_build)
26+
27+
$version = $(if ($is_release_build) { $short_version } else { "$short_version-$commit_hash" })
28+
$bin_version = "$short_version.$build"
29+
30+
write-host -n "Release type: ";
31+
if ($is_release_build) {write-host -f green 'release'} else { write-host -f yellow 'pre-release'}
32+
33+
write-host -n "NuGet Package Version: ";
34+
write-host -f cyan $version;
35+
36+
write-host -n "Assembly Version: ";
37+
write-host -f cyan $bin_version;
38+
39+
$av_version = "$bin_version$branch$suffix";
40+
41+
$env:APPVEYOR_BUILD_VERSION=$av_version;
42+
$env:BIN_VERSION=$bin_version;
43+
$env:VERSION=$version;
44+
45+
write-host -n "AppVeyor Build Version: ";
46+
write-host -f green $av_version;
47+
48+
appveyor UpdateBuild -Version $av_version

tools/appveyor-test.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
$proj = ".\test\ICSharpCode.SharpZipLib.TestBootstrapper\ICSharpCode.SharpZipLib.TestBootstrapper.csproj";
2+
$resxml = ".\docs\nunit3-test-results-debug.xml";
3+
4+
# Nuget 3 Console runner:
5+
#$tester = "nunit3-console .\test\ICSharpCode.SharpZipLib.Tests\bin\$($env:CONFIGURATION)\netcoreapp2.0\ICSharpCode.SharpZipLib.Tests.dll"
6+
7+
# Bootstrapper:
8+
$tester = "dotnet run -f netcoreapp2 -p $proj -c $env:CONFIGURATION";
9+
iex "$tester --explore=tests.xml";
10+
11+
[xml]$xml = Get-Content("tests.xml");
12+
$assembly = select-xml "/test-suite[@type='Assembly']" $xml | select -f 1 -exp Node;
13+
$testcases = select-xml "//test-case" $xml | % { Add-AppveyorTest -Name $_.Node.fullname -Framework NUnit -Filename $assembly.name };
14+
15+
iex "$tester --result=$resxml";
16+
17+
$wc = New-Object 'System.Net.WebClient';
18+
$wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit3/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $resxml));
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)