Skip to content

Commit 493f088

Browse files
committed
Merge NumberExtensions version scripts into UnitsNet
Number extensions has always followed main nuget versioning, so simplifying the 99% usecase. Single commit when bumping instead of two commits. Still two tags for UnitsNet and UnitsNet.NumberExtensions.
1 parent 2f6dc63 commit 493f088

7 files changed

+26
-86
lines changed

Build/bump-version-UnitsNet.NumberExtensions-major.bat

Lines changed: 0 additions & 4 deletions
This file was deleted.

Build/bump-version-UnitsNet.NumberExtensions-minor.bat

Lines changed: 0 additions & 4 deletions
This file was deleted.

Build/bump-version-UnitsNet.NumberExtensions-patch.bat

Lines changed: 0 additions & 4 deletions
This file was deleted.

Build/bump-version-UnitsNet.NumberExtensions-suffix.bat

Lines changed: 0 additions & 4 deletions
This file was deleted.

Build/set-version-UnitsNet.NumberExtensions.ps1

Lines changed: 0 additions & 59 deletions
This file was deleted.

Build/set-version-UnitsNet.ps1

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,25 @@ Import-Module "$PSScriptRoot\set-version.psm1"
5151
$root = Resolve-Path "$PSScriptRoot\.."
5252
$paramSet = $PsCmdlet.ParameterSetName
5353
$projFile = "$root\UnitsNet\UnitsNet.csproj"
54+
$numberExtensionsProjFile = "$root\UnitsNet.NumberExtensions\UnitsNet.NumberExtensions.csproj"
5455
$winrtAssemblyInfoFile = "$root\UnitsNet.WindowsRuntimeComponent\Properties\AssemblyInfo.cs"
5556
$winrtNuspecFile = "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec"
56-
$versionFiles = @($projFile, $winrtAssemblyInfoFile, $winrtNuspecFile)
57-
$projectName = "UnitsNet"
57+
$versionFiles = @($projFile, $numberExtensionsProjFile, $winrtAssemblyInfoFile, $winrtNuspecFile)
5858

5959
# Use UnitsNet.Common.props version as base if bumping major/minor/patch
6060
$newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion
6161

62+
# # Update project files
6263
Set-ProjectVersion $projFile $newVersion
64+
Set-ProjectVersion $numberExtensionsProjFile $newVersion
65+
66+
# # Update AssemblyInfo.cs files
6367
Set-AssemblyInfoVersion $winrtAssemblyInfoFile $newVersion
68+
69+
# # Update .nuspec files
6470
Set-NuspecVersion $winrtNuspecFile $newVersion
65-
Invoke-CommitAndTagVersion $projectName $versionFiles $newVersion
71+
72+
# Git commit and tag
73+
Invoke-CommitVersionBump @("UnitsNet") $versionFiles $newVersion
74+
Invoke-TagVersionBump "UnitsNet" $newVersion
75+
Invoke-TagVersionBump "UnitsNet.NumberExtensions" $newVersion

Build/set-version.psm1

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function Get-NewProjectVersion(
1616
}
1717
}
1818

19-
function Invoke-CommitAndTagVersion(
20-
[string]$projectName,
19+
function Invoke-CommitVersionBump(
20+
[string[]]$projectNames,
2121
[string[]]$projectPaths,
2222
[string] $newSemVer) {
2323
try {
@@ -30,18 +30,23 @@ function Invoke-CommitAndTagVersion(
3030
git add $path
3131
}
3232

33-
Write-Host -Foreground Green "Committing new versions: $projectName/$newSemVer"
34-
git commit -m "${projectName}: $newSemVer"
35-
Write-Host -Foreground Green "Tagging version: $projectName/$newSemVer"
36-
git tag -a "$projectName/$newSemVer" -m "$projectName/$newSemVer" -m "TODO List changes here"
33+
$projectNamesConcat = [string]::Join(", ", $projectNames)
34+
Write-Host -Foreground Green "Committing new version: $newSemVer"
35+
git commit -m "${projectNamesConcat}: $newSemVer"
3736
}
3837
catch {
3938
$err = $PSItem.Exception
40-
Write-Error "ERROR: Failed to commit and tag version: `n---`n$err`n---`n$($PSItem.ScriptStackTrace)"
39+
Write-Error "ERROR: Failed to commit version: `n---`n$err`n---`n$($PSItem.ScriptStackTrace)"
4140
exit 1
4241
}
4342
}
4443

44+
function Invoke-TagVersionBump(
45+
[string] $projectName,
46+
[string] $newSemVer) {
47+
git tag -a "$projectName/$newSemVer" -m "$projectName/$newSemVer" -m "TODO List changes here"
48+
}
49+
4550
function Set-ProjectVersion([string] $file, [string] $version) {
4651
$assemblyVersion = $version -replace "(\d+)(?:\.\d+)+.*", '$1.0.0.0'
4752
Write-Host "$file -> $version (AssemblyVersion $assemblyVersion)"
@@ -154,4 +159,4 @@ function Resolve-Error ($ErrorRecord=$Error[0])
154159
}
155160
}
156161

157-
export-modulemember -function Get-NewProjectVersion, Set-ProjectVersion, Set-AssemblyInfoVersion, Invoke-CommitAndTagVersion, Set-NuspecVersion
162+
export-modulemember -function Get-NewProjectVersion, Invoke-CommitVersionBump, Invoke-TagVersionBump, Set-ProjectVersion, Set-AssemblyInfoVersion, Set-NuspecVersion

0 commit comments

Comments
 (0)