55. SYNOPSIS
66 Updates the version of the UPM packages in the project with a release label, revision, and build number.
77. DESCRIPTION
8- The script will update the version of the package.json file with the new version label and revision number. This
8+ The script will update the version of the package.json file with the new version label and revision number. This
99 script will also update the AssemblyInfo.cs file with the new version number and build number. Finally, this
1010 script will update the CHANGELOG.md file with the new version number and release date.
1111. PARAMETER PackagesRoot
1212 The root folder containing the packages.
1313. PARAMETER PrereleaseTag
1414 The tag to append after the version (e.g. "build", "internal" or "prerelease"). Leave blank for a release build.
1515. PARAMETER Revision
16- The revision number for the build, to append after the release labal .
16+ The revision number for the build, to append after the release label .
1717. PARAMETER BuildNumber
1818 The fourth digit for the full version number for assembly versioning. This is the build number.
1919#>
@@ -44,7 +44,7 @@ if (-not [string]::IsNullOrEmpty($Revision)) {
4444}
4545
4646Write-Host " "
47- Write-Host - ForegroundColor Green " ======================================="
47+ Write-Host - ForegroundColor Green " ======================================="
4848Write-Host - ForegroundColor Green " Updating All Package Versions"
4949Write-Host - ForegroundColor Green " ======================================="
5050Write-Output " Project root: $PackagesRoot "
@@ -63,7 +63,7 @@ Get-ChildItem -Path $PackagesRoot -Filter "package.json" -Recurse | ForEach-Obje
6363
6464 # Test is package name starts with org.mixedrealitytoolkit to verify it's an MRTK package
6565 if ($packageName -notmatch " ^org\.mixedrealitytoolkit\.\w+(\.\w+)*" ) {
66- return
66+ return
6767 }
6868
6969 # Read the version value
@@ -73,24 +73,24 @@ Get-ChildItem -Path $PackagesRoot -Filter "package.json" -Recurse | ForEach-Obje
7373 $packagePath = $_.Directory
7474
7575 Write-Host " "
76- Write-Host - ForegroundColor Green " ======================================="
76+ Write-Host - ForegroundColor Green " ======================================="
7777 Write-Host - ForegroundColor Green " Updating Package Version"
78- Write-Host - ForegroundColor Green " ======================================="
78+ Write-Host - ForegroundColor Green " ======================================="
7979 Write-Output " Package name: $packageName "
8080
8181 # This regex will match the a valid version is the package.json file. Some examples of valid versions are:
8282 #
8383 # 1.0.0
8484 # 1.0.0-pre.1
8585 # 1.0.0-development.pre.1
86- # 1.0.0-development
86+ # 1.0.0-development
8787 #
88- # In these example "development" is the prerelease tag and "pre.1" is the meta tag.
88+ # In these example "development" is the prerelease tag and "pre.1" is the meta tag.
8989 $validVersion = $version -match ' (?<version>[0-9.]+)(-((?<prereleaseTag>[a-zA-Z0-9]*)?(?=(|\.[a-zA-Z]*\.[0-9]*)(\.[0-9]{6}\.[0-9]|$))|)((?(?<=-)|\.)(?<metaTag>[a-zA-Z][a-zA-Z0-9]*)\.(?<metaTagVersion>[1-9][0-9]*))?)?'
9090 if (-not $validVersion ) {
9191 throw " Failed to parse version out of the package.json file at $ ( $_.FullName ) "
9292 }
93-
93+
9494 # Get the version parts from the $Matches variable, and verify that the version key exists.
9595 $versionParts = $Matches
9696 if (-not $versionParts.ContainsKey (' version' )) {
@@ -102,14 +102,14 @@ Get-ChildItem -Path $PackagesRoot -Filter "package.json" -Recurse | ForEach-Obje
102102
103103 # Get all tag parts to append to the version
104104 $tagParts = @ ()
105-
105+
106106 # Add the new version label if it's not empty
107107 if (-not [string ]::IsNullOrEmpty($PrereleaseTag )) {
108108 $tagParts += $PrereleaseTag
109109 }
110110
111111 # Add the optional metatag tag and version if found in match
112- if ($versionParts.ContainsKey (' metaTag' ) -and $versionParts.ContainsKey (' metaTagVersion' )) {
112+ if ($versionParts.ContainsKey (' metaTag' ) -and $versionParts.ContainsKey (' metaTagVersion' )) {
113113 $tagParts += $versionParts [' metaTag' ]
114114 $tagParts += $versionParts [' metaTagVersion' ]
115115 }
@@ -125,7 +125,7 @@ Get-ChildItem -Path $PackagesRoot -Filter "package.json" -Recurse | ForEach-Obje
125125 $tag = " -" + $tag
126126 }
127127
128- # Update the version with the new tag
128+ # Update the version with the new tag
129129 $jsonContent.version = " $version$tag "
130130
131131 # Write json content back to the file
@@ -153,18 +153,18 @@ Get-ChildItem -Path $PackagesRoot -Filter "package.json" -Recurse | ForEach-Obje
153153 $assemblyInfo += " [assembly: AssemblyInformationalVersion(`" $version$tag `" )]`r`n "
154154 }
155155
156- Set-Content - Path $_ - Value $assemblyInfo - NoNewline
156+ Set-Content - Path $_ - Value $assemblyInfo - NoNewline
157157 }
158158
159159 # Update the CHANGELOG.md file with the new version and release date
160160 Write-Output " Patching CHANGELOG.md version to [$version$tag ] - $year -$month -$day "
161- Get-ChildItem - Path $packagePath / CHANGELOG.md - Recurse | ForEach-Object {
161+ Get-ChildItem - Path $packagePath / CHANGELOG.md - Recurse | ForEach-Object {
162162 (Get-Content - Path $_ - Raw) -Replace " ## \[$version (-[a-zA-Z0-9.]+)?\] - \b\d{4}\b-\b(0[1-9]|1[0-2])\b-\b(0[1-9]|[12][0-9]|3[01])\b" , " ## [$version$tag ] - $year -$month -$day " | Set-Content - Path $_ - NoNewline
163163 }
164164}
165165
166166Write-Host " "
167- Write-Host - ForegroundColor Green " ======================================="
167+ Write-Host - ForegroundColor Green " ======================================="
168168Write-Host - ForegroundColor Green " Successfully Updated Package Versions"
169169Write-Host - ForegroundColor Green " ======================================="
170170Write-Host " "
0 commit comments