lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject lucenenet git commit: build\build.ps1: Fixed version updating logic so it works globally for the script
Date Wed, 19 Apr 2017 22:56:50 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/api-work 5be649a2d -> a593dcb8e


build\build.ps1: Fixed version updating logic so it works globally for the script


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/a593dcb8
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/a593dcb8
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/a593dcb8

Branch: refs/heads/api-work
Commit: a593dcb8ebf0f761a71e4129b9f33457d0b6eae3
Parents: 5be649a
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Thu Apr 20 05:55:58 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Thu Apr 20 05:55:58 2017 +0700

----------------------------------------------------------------------
 build/build.ps1 | 97 ++++++++++++++++++++++++++++------------------------
 1 file changed, 52 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/a593dcb8/build/build.ps1
----------------------------------------------------------------------
diff --git a/build/build.ps1 b/build/build.ps1
index 71ea307..1081903 100644
--- a/build/build.ps1
+++ b/build/build.ps1
@@ -7,10 +7,10 @@
 	[string]$test_results_directory = "$release_directory\TestResults"
 
 	[string]$buildCounter     = ""
-	[string]$packageVersion   = "0.0.0"
+	[string]$packageVersion   = Get-Package-Version
 	[string]$version          = "0.0.0"
 	[string]$configuration    = "Release"
-	[bool]$backup_files        = $true
+	[bool]$backup_files       = $true
 
 	[string]$common_assembly_info = "$base_directory\src\CommonAssemblyInfo.cs"
 	[string]$copyright_year = [DateTime]::Today.Year.ToString() #Get the current year from the
system
@@ -38,54 +38,12 @@ task Init -description "This task makes sure the build environment is
correctly
 		Write-Error "Could not find dotnet CLI in PATH. Please install the .NET Core 1.1 SDK."
 	}
 
-	#If $packageVersion is not passed in, get it from Version.proj
-	if ([string]::IsNullOrEmpty($packageVersion) -or $packageVersion -eq "0.0.0" -or ![string]::IsNullOrWhiteSpace($env:BuildCounter))
{
-		#Get the version info
-		$versionFile = "$base_directory\Version.proj"
-		$xml = [xml](Get-Content $versionFile)
-
-		$versionPrefix = $xml.Project.PropertyGroup.VersionPrefix
-		$versionSuffix = $xml.Project.PropertyGroup.VersionSuffix
-		Write-Host "VersionPrefix: $versionPrefix" -ForegroundColor Yellow
-		Write-Host "VersionSuffix: $versionSuffix" -ForegroundColor Yellow
-		
-		if ([string]::IsNullOrEmpty($buildCounter)) {
-			#attempt to get MyGet (or TeamCity) build counter environment variable
-			$buildCounter = "$env:BuildCounter"
-		}
-		Write-Host "buildCounter: $buildCounter"
-
-
-		if ([string]::IsNullOrWhiteSpace($versionSuffix)) {
-			# this is a production release - use 4 segment version number 0.0.0.0
-			if ([string]::IsNullOrEmpty($buildCounter)) {
-				$buildCounter = "0"
-			}
-
-			$packageVersion = "$versionPrefix.$buildCounter"
-		} else {
-			# this is a pre-release - use 3 segment version number with (optional) zero-padded pre-release
tag
-			if (![string]::IsNullOrEmpty($buildCounter)) {
-				$buildCounter = ([Int32]$buildCounter).ToString("00000")
-			}
-
-			$packageVersion = "$versionPrefix-$versionSuffix$buildCounter"
-		}
-	}
+	$version = Get-Version $packageVersion
 
 	#Update TeamCity or MyGet with packageVersion
 	Write-Output "##teamcity[buildNumber '$packageVersion']"
 	Write-Output "##myget[buildNumber '$packageVersion']"
 
-	#If $version is not passed in, parse it from $packageVersion
-	if ([string]::IsNullOrEmpty($version) -or $version -eq "0.0.0") {
-		$version = $packageVersion
-		if ($version.Contains("-") -eq $true) {
-			$version = $version.SubString(0, $version.IndexOf("-"))
-		}
-		Write-Host "Updated version to: $version"
-	}
-
 	& dotnet.exe --version
 	Write-Host "Base Directory: $base_directory"
 	Write-Host "Release Directory: $release_directory"
@@ -194,8 +152,57 @@ task Test -description "This task runs the tests" {
 	}
 }
 
+function Get-Package-Version() {
+	#If $packageVersion is not passed in, get it from Version.proj
+
+	#Get the version info
+	$versionFile = "$base_directory\Version.proj"
+	$xml = [xml](Get-Content $versionFile)
+
+	$versionPrefix = $xml.Project.PropertyGroup.VersionPrefix
+	$versionSuffix = $xml.Project.PropertyGroup.VersionSuffix
+	Write-Host "VersionPrefix: $versionPrefix" -ForegroundColor Yellow
+	Write-Host "VersionSuffix: $versionSuffix" -ForegroundColor Yellow
+		
+	if ([string]::IsNullOrWhiteSpace($buildCounter)) {
+		#attempt to get MyGet (or TeamCity) build counter environment variable
+		$buildCounter = "$env:BuildCounter"
+	}
+	Write-Host "buildCounter: $buildCounter"
+
+	if ([string]::IsNullOrWhiteSpace($versionSuffix)) {
+		# this is a production release - use 4 segment version number 0.0.0.0
+		if ([string]::IsNullOrWhiteSpace($buildCounter)) {
+			$buildCounter = "0"
+		}
+
+		$packageVersion = "$versionPrefix.$buildCounter"
+	} else {
+		# this is a pre-release - use 3 segment version number with (optional) zero-padded pre-release
tag
+		if (![string]::IsNullOrWhiteSpace($buildCounter)) {
+			$buildCounter = ([Int32]$buildCounter).ToString("00000")
+		}
+
+		$packageVersion = "$versionPrefix-$versionSuffix$buildCounter"
+	}
+	return $packageVersion
+}
+
+function Get-Version([string]$packageVersion) {
+	#If $version is not passed in, parse it from $packageVersion
+	if ([string]::IsNullOrWhiteSpace($version) -or $version -eq "0.0.0") {
+		$version = $packageVersion
+		if ($version.Contains("-") -eq $true) {
+			$version = $version.SubString(0, $version.IndexOf("-"))
+		}
+	}
+	return $version
+}
+
 function Prepare-For-Build([string[]]$projects) {
 	Backup-File $common_assembly_info 
+	
+	$version = Get-Version $packageVersion
 		
 	Generate-Assembly-Info `
 		-product $product_name `


Mime
View raw message