-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Changed set-output * Support beta releases (#26)
- Loading branch information
1 parent
7d60855
commit 465f056
Showing
5 changed files
with
82 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Verify it is a proper version | ||
param( | ||
[Parameter(Mandatory=$false)] | ||
[string] | ||
$Version | ||
) | ||
|
||
Set-StrictMode -Version 3 | ||
|
||
# RegEx from https://semver.org/ | ||
[string]$semanticRegEx = '^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$' | ||
|
||
if (-not ($Version -match $semanticRegEx)) { | ||
throw "The version must follow semantic versioning, see https://semver.org/." + ` | ||
" For instance 4.3.22-beta." | ||
} | ||
|
||
$parts = $Version -split {$_ -eq '-' -or $_ -eq '+'} | ||
|
||
return $parts[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,44 @@ | ||
param( | ||
[Parameter(Mandatory)] | ||
[Parameter(Mandatory)] | ||
[string] | ||
$FileName, | ||
$FileName, | ||
|
||
[Parameter(Mandatory)] | ||
[string] | ||
$PropertyName, | ||
[Parameter(Mandatory)] | ||
[string] | ||
$PropertyName, | ||
|
||
[Parameter(Mandatory)] | ||
[Parameter(Mandatory, | ||
ParameterSetName = 'Version')] | ||
[Version] | ||
$Version | ||
$Version, | ||
|
||
[Parameter(Mandatory, | ||
ParameterSetName = 'VersionString')] | ||
[string] | ||
$VersionString | ||
) | ||
|
||
Set-StrictMode -Version 2 | ||
|
||
$pattern = "^\[assembly: $PropertyName\(""(.*)""\)\]$" | ||
$found = $false | ||
|
||
if ($Version) { | ||
$VersionString = $Version | ||
} | ||
|
||
$content = (Get-Content $fileName -Encoding UTF8) | ForEach-Object { | ||
if ($_ -match $pattern) | ||
{ | ||
"[assembly: $PropertyName(""{0}"")]" -f $Version | ||
$found = $true | ||
if ($_ -match $pattern) { | ||
"[assembly: $PropertyName(""{0}"")]" -f $VersionString | ||
$found = $true | ||
} | ||
else | ||
{ | ||
else { | ||
$_ | ||
} | ||
} | ||
|
||
if (-not $found) { | ||
$content += "[assembly: $PropertyName(""{0}"")]" -f $Version | ||
$content += "[assembly: $PropertyName(""{0}"")]" -f $VersionString | ||
} | ||
|
||
$content | Set-Content $fileName -Encoding UTF8 |