Permalink
Browse files

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
  • Loading branch information...
piksel committed Dec 22, 2018
1 parent 36784aa commit b5e3cbe416dae126b903b50de736d864a9b52e01
@@ -8,39 +8,11 @@ dotnet_csproj:
file: '**\*.csproj'
version: $(VERSION)
package_version: $(VERSION)
assembly_version: 1.0.0.999
file_version: 1.0.0.999
assembly_version: $(BIN_VERSION)
file_version: $(BIN_VERSION)
informational_version: $(VERSION)
install:
- ps: |-
$commit = $(git rev-parse --short HEAD)
$masterBranches = @("master");
if ($masterBranches -contains $env:APPVEYOR_REPO_BRANCH) {
$branch = "";
} else {
$branch = "-$env:APPVEYOR_REPO_BRANCH";
}
if ($env:APPVEYOR_PULL_REQUEST_NUMBER) {
$suffix = "-pr$env:APPVEYOR_PULL_REQUEST_NUMBER";
} else {
$suffix = "";
}
$build = "_${env:APPVEYOR_BUILD_NUMBER}"
$version = "1.0-git$commit";
$av_version = "$version$branch$suffix$build";
$env:APPVEYOR_BUILD_VERSION=$av_version;
$env:VERSION=$version;
write-host -n "new version: ";
write-host -f green $av_version;
appveyor UpdateBuild -Version $av_version
- ps: tools/appveyor-install.ps1
nuget:
project_feed: true
disable_publish_on_pr: true
@@ -52,22 +24,4 @@ build:
publish_nuget_symbols: true
verbosity: normal
test_script:
- ps: |-
$proj = ".\test\ICSharpCode.SharpZipLib.TestBootstrapper\ICSharpCode.SharpZipLib.TestBootstrapper.csproj";
$resxml = ".\docs\nunit3-test-results-debug.xml";
# Nuget 3 Console runner:
#$tester = "nunit3-console .\test\ICSharpCode.SharpZipLib.Tests\bin\$($env:CONFIGURATION)\netcoreapp2.0\ICSharpCode.SharpZipLib.Tests.dll"
# Bootstrapper:
$tester = "dotnet run -f netcoreapp2 -p $proj -c $env:CONFIGURATION";
iex "$tester --explore=tests.xml";
[xml]$xml = Get-Content("tests.xml");
$assembly = select-xml "/test-suite[@type='Assembly']" $xml | select -f 1 -exp Node;
$testcases = select-xml "//test-case" $xml | % { Add-AppveyorTest -Name $_.Node.fullname -Framework NUnit -Filename $assembly.name };
iex "$tester --result=$resxml";
$wc = New-Object 'System.Net.WebClient';
$wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit3/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $resxml));
- ps: tools/appveyor-test.ps1
@@ -0,0 +1,48 @@
# Describe from the lastest tag matching 'vX.Y.Z', removing the initial 'v'
$description = $(git describe --long --tags --match 'v[0-9]*.[0-9]*.[0-9]*').substring(1);

# Description is in the format of: TAG-COMMITS_SINCE_TAG-COMMIT_HASH
$dparts = $description -split('-');
$short_version = $dparts[0];
$commits_since_tag = $dparts[1];
$commit_hash = $dparts[2];

$masterBranches = @("master");

# If not in master branch, set branch variable
$av_branch = $env:APPVEYOR_REPO_BRANCH;
$branch = $(if ($masterBranches -contains $av_branch) { "" } else { "-$av_branch" });

# If this is a PR, add the PR suffix
$suffix = $(if ($env:APPVEYOR_PULL_REQUEST_NUMBER) { "-pr$env:APPVEYOR_PULL_REQUEST_NUMBER" } else { "" });

# Main build is when we're in the master branch and not a PR
$is_main_build = ($branch -eq "" -and $suffix -eq "")

# Use appveyor build number as the last version digit (x.x.x.B)
$build = ${env:APPVEYOR_BUILD_NUMBER}

$is_release_build = ($commits_since_tag -eq 0 -and $is_main_build)

$version = $(if ($is_release_build) { $short_version } else { "$short_version-$commit_hash" })
$bin_version = "$short_version.$build"

write-host -n "Release type: ";
if ($is_release_build) {write-host -f green 'release'} else { write-host -f yellow 'pre-release'}

write-host -n "NuGet Package Version: ";
write-host -f cyan $version;

write-host -n "Assembly Version: ";
write-host -f cyan $bin_version;

$av_version = "$bin_version$branch$suffix";

$env:APPVEYOR_BUILD_VERSION=$av_version;
$env:BIN_VERSION=$bin_version;
$env:VERSION=$version;

write-host -n "AppVeyor Build Version: ";
write-host -f green $av_version;

appveyor UpdateBuild -Version $av_version
@@ -0,0 +1,18 @@
$proj = ".\test\ICSharpCode.SharpZipLib.TestBootstrapper\ICSharpCode.SharpZipLib.TestBootstrapper.csproj";
$resxml = ".\docs\nunit3-test-results-debug.xml";

# Nuget 3 Console runner:
#$tester = "nunit3-console .\test\ICSharpCode.SharpZipLib.Tests\bin\$($env:CONFIGURATION)\netcoreapp2.0\ICSharpCode.SharpZipLib.Tests.dll"

# Bootstrapper:
$tester = "dotnet run -f netcoreapp2 -p $proj -c $env:CONFIGURATION";
iex "$tester --explore=tests.xml";

[xml]$xml = Get-Content("tests.xml");
$assembly = select-xml "/test-suite[@type='Assembly']" $xml | select -f 1 -exp Node;
$testcases = select-xml "//test-case" $xml | % { Add-AppveyorTest -Name $_.Node.fullname -Framework NUnit -Filename $assembly.name };

iex "$tester --result=$resxml";

$wc = New-Object 'System.Net.WebClient';
$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.
@@ -0,0 +1,24 @@
$env:APPVEYOR_BUILD_NUMBER = 123;

function Test-Install {
param( [string]$PR, [string]$Branch )
Write-Host -n "-- Testing with PR "
if($PR -eq "") { Write-Host -n -f red "No" } else { Write-Host -n -f cyan "#$PR" }
Write-Host -n " and branch "
if($Branch -eq "master") { Write-Host -f green "master" } else { Write-Host -f cyan "$Branch" }
$env:APPVEYOR_PULL_REQUEST_NUMBER = $PR;
$env:APPVEYOR_REPO_BRANCH = $Branch;
.\appveyor-install.ps1
Write-Host "---------------------------------------------------------------------";
Write-Host;
}

function appveyor {
# Dummy function for compability with AV
}

Write-Host;
Test-Install "" "master"
Test-Install 42 "master"
Test-Install "" "misc-feature"
Test-Install 36 "other-branch"

0 comments on commit b5e3cbe

Please sign in to comment.