From e55bccd52eb0e337c98c2bc3872108f9786f042c Mon Sep 17 00:00:00 2001 From: Shane Lee Date: Thu, 11 Apr 2024 10:56:44 -0600 Subject: [PATCH] Add script version to powershell script --- .github/workflows/scripts/cut-release.py | 17 +++++++++++++++++ bootstrap-salt.ps1 | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scripts/cut-release.py b/.github/workflows/scripts/cut-release.py index 3b6eabf..96b76c2 100644 --- a/.github/workflows/scripts/cut-release.py +++ b/.github/workflows/scripts/cut-release.py @@ -188,6 +188,7 @@ def main(): + changelog_file.read_text() ) + # Update Script Version for the bash script bootstrap_script_path = REPO_ROOT / "bootstrap-salt.sh" print( f"* Updating {bootstrap_script_path.relative_to(REPO_ROOT)} ...", @@ -201,6 +202,22 @@ def main(): bootstrap_script_path.read_text(), ) ) + + # Update the Script Version for the powershell script + bootstrap_script_path = REPO_ROOT / "bootstrap-salt.ps1" + print( + f"* Updating {bootstrap_script_path.relative_to(REPO_ROOT)} ...", + file=sys.stderr, + flush=True, + ) + bootstrap_script_path.write_text( + re.sub( + r'\$__ScriptVersion = "(.*)"', + f'$__ScriptVersion = "{options.release_tag.lstrip("v")}"', + bootstrap_script_path.read_text(), + ) + ) + parser.exit(status=0, message="CHANGELOG.md and bootstrap-salt.sh updated\n") diff --git a/bootstrap-salt.ps1 b/bootstrap-salt.ps1 index 6481ae6..451c0c0 100644 --- a/bootstrap-salt.ps1 +++ b/bootstrap-salt.ps1 @@ -94,7 +94,12 @@ param( [Parameter(Mandatory=$false)] [Alias("h")] # Displays help for this script. - [Switch] $Help + [Switch] $Help, + + [Parameter(Mandatory=$false)] + [Alias("e")] + # Displays the Version for this script. + [Switch] $ScriptVersion ) # We'll check for help first because it really has no requirements @@ -105,6 +110,15 @@ if ($help) { exit 0 } +$__ScriptVersion = "2024.04.03" +$ScriptName = $myInvocation.MyCommand.Name + +# We'll check for the Version next, because it also has no requirements +if ($ScriptVersion) { + Write-Host $__ScriptVersion + exit 0 +} + #=============================================================================== # Script Preferences #=============================================================================== @@ -303,6 +317,8 @@ if ( [Uri]($RepoUrl).AbsoluteUri -eq $defaultUrl ) { #=============================================================================== # Verify Parameters #=============================================================================== +Write-Verbose "Running Script: $ScriptName" +Write-Verbose "Script Version: $__ScriptVersion" Write-Verbose "Parameters passed in:" Write-Verbose "version: $Version" Write-Verbose "runservice: $RunService"