diff --git a/.expeditor/build_gems.ps1 b/.expeditor/build_gems.ps1 index 8cd62f79..4fd53cb3 100644 --- a/.expeditor/build_gems.ps1 +++ b/.expeditor/build_gems.ps1 @@ -98,7 +98,8 @@ Write-Output "`r" Write-Output "--- :muscle: cleanup, cleanup, everybody, everywhere: Deleting existing DLL's in the chef-powershell Directory and copying the newly compiled ones down" -$x64_bin_path = $("$project_root\chef-powershell\bin\ruby_bin_folder\AMD64") +$arch = if ($env:PROCESSOR_ARCHITECTURE) { $env:PROCESSOR_ARCHITECTURE } else { "AMD64" } +$x64_bin_path = $("$project_root\chef-powershell\bin\ruby_bin_folder\$arch") if (Test-Path -PathType Container $x64_bin_path) { Write-Output "My 64-bit path WAS found here : $x64_bin_path" diff --git a/.expeditor/manual_gem_release.ps1 b/.expeditor/manual_gem_release.ps1 index 9f9088dd..096bfd99 100644 --- a/.expeditor/manual_gem_release.ps1 +++ b/.expeditor/manual_gem_release.ps1 @@ -105,7 +105,8 @@ if (-not $?) { throw "unable to install this build" } Write-Output "`r" Write-Output "--- :cleanup, cleanup, everybody, everywhere: Deleting existing DLL's in the chef-powershell Directory and copying the newly compiled ones down" -$x64_bin_path = $("$project_root/chef-powershell/bin/ruby_bin_folder/AMD64") +$arch = if ($env:PROCESSOR_ARCHITECTURE) { $env:PROCESSOR_ARCHITECTURE } else { "AMD64" } +$x64_bin_path = $("$project_root/chef-powershell/bin/ruby_bin_folder/$arch") if (Test-Path -PathType Container $x64_bin_path) { Get-ChildItem -Path $x64_bin_path -Recurse | Foreach-object { Remove-item -Recurse -path $_.FullName -Force } diff --git a/.expeditor/update_version.ps1 b/.expeditor/update_version.ps1 index 05868245..8d7ad53a 100644 --- a/.expeditor/update_version.ps1 +++ b/.expeditor/update_version.ps1 @@ -8,13 +8,29 @@ $ErrorActionPreference = "Stop" -# get the contents of the gem version file +# Get the project root directory using git +$project_root = git rev-parse --show-toplevel +if ($LASTEXITCODE -ne 0) { + Write-Error "Failed to determine git repository root. Are you in a git repository?" + exit 1 +} + +# Convert Unix-style path to Windows path if necessary +$project_root = $project_root -replace '/', '\' + +# Get the contents of the gem version file +$version_file = Join-Path $project_root "chef-powershell\lib\chef-powershell\version.rb" +if (-not (Test-Path $version_file)) { + Write-Error "Version file not found at: $version_file" + exit 1 +} + try { - $project_root = Get-ChildItem -Path C:\ -Recurse | Where-Object { $_.PSIsContainer -eq $True -and $_.Name -like "*chef-powershell-shim*" } | % { $_.fullname } | select-object -First 1 - $file = (Get-Content $("$project_root\chef-powershell\lib\chef-powershell\version.rb")) + $file = Get-Content $version_file } catch { - Write-Error "Failed to Get the Version from version.rb" + Write-Error "Failed to read the Version from version.rb: $_" + exit 1 } # Use RegEx to get the Version Number and set it as a version datatype @@ -48,10 +64,10 @@ else { # Replace Old Version Number with New Version number in the file try { - (Get-Content .\chef-powershell\lib\chef-powershell\version.rb) -replace $version, $NewVersion | Out-File .\chef-powershell\lib\chef-powershell\version.rb + (Get-Content $version_file) -replace $version, $NewVersion | Set-Content $version_file -Encoding UTF8 Write-Output "Updated Module Version from $Version to $NewVersion" } catch { - $_ - Write-Error "failed to set file" + Write-Error "Failed to update version file: $_" + exit 1 } \ No newline at end of file