Skip to content

Commit

Permalink
#60 Add list-contributors and bump-version scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
colinangusmackay committed Jan 9, 2021
1 parent eda8f73 commit 5ae507b
Show file tree
Hide file tree
Showing 2 changed files with 442 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Bump-Version.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[CmdletBinding()]
param (
[Switch]
$BumpMajor,

[Switch]
$BumpMinor,

[Switch]
$BumpPatch
)

$VersionFile = "$PSScriptRoot/version.txt";
$currentVersion = Get-Content $VersionFile -ErrorAction Stop
if ($null -eq $currentVersion)
{
Write-Error "The $VersionFile file is empty"
Exit 1
}
if ($currentVersion.GetType().BaseType.Name -eq "Array")
{
$currentVersion = $currentVersion[0]
Write-Warning "$VersionFile contains more than one line of text. Using the first line."
}
if ($currentVersion -notmatch "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")
{
Write-Error "The contents of $VersionFile (`"$nextVersion`") not recognised as a valid version number."
Exit 2
}

$parts = $currentVersion.Split('.');
[int]$major = $parts[0]
[int]$minor = $parts[1]
[int]$patch = $parts[2]

if ($BumpMajor)
{
$major += 1;
}

if ($BumpMinor)
{
$minor += 1;
}

if ($BumpPatch)
{
$patch += 1;
}

$newVersion = "$major.$minor.$patch";

Set-Content $VersionFile $newVersion -Encoding UTF8 -Force
Loading

0 comments on commit 5ae507b

Please sign in to comment.