Instantly share code, notes, and snippets.

anonymous /checkSemVer.ps1
Created Nov 23, 2017

What would you like to do?
$VersionNumbers = @()
$VersionNumbers = "1.0.0", "", "1.0.t", "1.0.0.t", "" ,"", "", "t.0.0.345", "1.rt.0.345"
$alphaRegex = "^(\d+\.)?(\d+\.)?(\*|\d+)$"
$ErrorActionPreference = "SilentlyContinue"
foreach ($semver in $VersionNumbers) {
Write-Host $semver -ForegroundColor Green
if (($semver -match $alphaRegex) -eq $false) {
$betaRegex = "^(\d+\.)?(\d+\.)?(\d+\.)?(\*|\d+)$"
if (($semver -match $betaRegex) -eq $false) {
Write-Error "New ModuleVersion Number not in correct format; Expected ##.##.##(.##) , actual $semver"
Write-Host $semver -ForegroundColor Black -BackgroundColor Red
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment