Skip to content

Commit b918423

Browse files
🩹 [Patch]: Remove dependency on Utilities (#74)
## Description This pull request makes several changes to the `scripts/main.ps1` file to simplify the code and improve readability. The most important changes include removing unnecessary library loading, eliminating the logging of environment variables, and refining the configuration settings. - Fixes an issue where the dependency installation fails. Removing the dependency with issues to restore functionality. Code simplification and improvement: * Removed the loading of the 'Utilities' library from the `LogGroup 'Loading libraries'` section. (`scripts/main.ps1`) * Removed the `LogGroup 'Environment variables'` section entirely, which logged environment variables. (`scripts/main.ps1`) * Replaced the `IsNotNullOrEmpty` method with `[string]::IsNullOrEmpty` for checking configuration values and environment variables, which simplifies the code. (`scripts/main.ps1`) ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [x] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent af25757 commit b918423

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

scripts/main.ps1

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
param()
1010

1111
LogGroup 'Loading libraries' {
12-
'Utilities', 'powershell-yaml', 'PSSemVer' | ForEach-Object {
12+
'powershell-yaml', 'PSSemVer' | ForEach-Object {
1313
$name = $_
1414
$count = 5
1515
$delay = 10
@@ -28,10 +28,6 @@ LogGroup 'Loading libraries' {
2828
}
2929
}
3030

31-
LogGroup 'Environment variables' {
32-
Get-ChildItem -Path Env: | Select-Object Name, Value | Sort-Object Name | Format-Table -AutoSize | Out-String
33-
}
34-
3531
LogGroup 'Set configuration' {
3632
if (-not (Test-Path -Path $env:PSMODULE_AUTO_RELEASE_INPUT_ConfigurationFile -PathType Leaf)) {
3733
Write-Output "Configuration file not found at [$env:PSMODULE_AUTO_RELEASE_INPUT_ConfigurationFile]"
@@ -40,19 +36,19 @@ LogGroup 'Set configuration' {
4036
$configuration = ConvertFrom-Yaml -Yaml (Get-Content $env:PSMODULE_AUTO_RELEASE_INPUT_ConfigurationFile -Raw)
4137
}
4238

43-
$autoCleanup = ($configuration.AutoCleanup | IsNotNullOrEmpty) ? $configuration.AutoCleanup -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_AutoCleanup -eq 'true'
44-
$autoPatching = ($configuration.AutoPatching | IsNotNullOrEmpty) ? $configuration.AutoPatching -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_AutoPatching -eq 'true'
45-
$createMajorTag = ($configuration.CreateMajorTag | IsNotNullOrEmpty) ? $configuration.CreateMajorTag -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_CreateMajorTag -eq 'true'
46-
$createMinorTag = ($configuration.CreateMinorTag | IsNotNullOrEmpty) ? $configuration.CreateMinorTag -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_CreateMinorTag -eq 'true'
47-
$datePrereleaseFormat = ($configuration.DatePrereleaseFormat | IsNotNullOrEmpty) ? $configuration.DatePrereleaseFormat : $env:PSMODULE_AUTO_RELEASE_INPUT_DatePrereleaseFormat
48-
$incrementalPrerelease = ($configuration.IncrementalPrerelease | IsNotNullOrEmpty) ? $configuration.IncrementalPrerelease -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_IncrementalPrerelease -eq 'true'
49-
$versionPrefix = ($configuration.VersionPrefix | IsNotNullOrEmpty) ? $configuration.VersionPrefix : $env:PSMODULE_AUTO_RELEASE_INPUT_VersionPrefix
50-
$whatIf = ($configuration.WhatIf | IsNotNullOrEmpty) ? $configuration.WhatIf -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_WhatIf -eq 'true'
39+
$autoCleanup = [string]::IsNullOrEmpty($configuration.AutoCleanup) ? $configuration.AutoCleanup -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_AutoCleanup -eq 'true'
40+
$autoPatching = [string]::IsNullOrEmpty($configuration.AutoPatching) ? $configuration.AutoPatching -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_AutoPatching -eq 'true'
41+
$createMajorTag = [string]::IsNullOrEmpty($configuration.CreateMajorTag) ? $configuration.CreateMajorTag -EQ 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_CreateMajorTag -EQ 'true'
42+
$createMinorTag = [string]::IsNullOrEmpty($configuration.CreateMinorTag) ? $configuration.CreateMinorTag -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_CreateMinorTag -eq 'true'
43+
$datePrereleaseFormat = [string]::IsNullOrEmpty($configuration.DatePrereleaseFormat) ? $configuration.DatePrereleaseFormat : $env:PSMODULE_AUTO_RELEASE_INPUT_DatePrereleaseFormat
44+
$incrementalPrerelease = [string]::IsNullOrEmpty($configuration.IncrementalPrerelease) ? $configuration.IncrementalPrerelease -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_IncrementalPrerelease -eq 'true'
45+
$versionPrefix = [string]::IsNullOrEmpty($configuration.VersionPrefix) ? $configuration.VersionPrefix : $env:PSMODULE_AUTO_RELEASE_INPUT_VersionPrefix
46+
$whatIf = [string]::IsNullOrEmpty($configuration.WhatIf) ? $configuration.WhatIf -eq 'true' : $env:PSMODULE_AUTO_RELEASE_INPUT_WhatIf -eq 'true'
5147

52-
$ignoreLabels = (($configuration.IgnoreLabels | IsNotNullOrEmpty) ? $configuration.IgnoreLabels : $env:PSMODULE_AUTO_RELEASE_INPUT_IgnoreLabels) -split ',' | ForEach-Object { $_.Trim() }
53-
$majorLabels = (($configuration.MajorLabels | IsNotNullOrEmpty) ? $configuration.MajorLabels : $env:PSMODULE_AUTO_RELEASE_INPUT_MajorLabels) -split ',' | ForEach-Object { $_.Trim() }
54-
$minorLabels = (($configuration.MinorLabels | IsNotNullOrEmpty) ? $configuration.MinorLabels : $env:PSMODULE_AUTO_RELEASE_INPUT_MinorLabels) -split ',' | ForEach-Object { $_.Trim() }
55-
$patchLabels = (($configuration.PatchLabels | IsNotNullOrEmpty) ? $configuration.PatchLabels : $env:PSMODULE_AUTO_RELEASE_INPUT_PatchLabels) -split ',' | ForEach-Object { $_.Trim() }
48+
$ignoreLabels = ([string]::IsNullOrEmpty($configuration.IgnoreLabels) ? $configuration.IgnoreLabels : $env:PSMODULE_AUTO_RELEASE_INPUT_IgnoreLabels) -split ',' | ForEach-Object { $_.Trim() }
49+
$majorLabels = ([string]::IsNullOrEmpty($configuration.MajorLabels) ? $configuration.MajorLabels : $env:PSMODULE_AUTO_RELEASE_INPUT_MajorLabels) -split ',' | ForEach-Object { $_.Trim() }
50+
$minorLabels = ([string]::IsNullOrEmpty($configuration.MinorLabels) ? $configuration.MinorLabels : $env:PSMODULE_AUTO_RELEASE_INPUT_MinorLabels) -split ',' | ForEach-Object { $_.Trim() }
51+
$patchLabels = ([string]::IsNullOrEmpty($configuration.PatchLabels) ? $configuration.PatchLabels : $env:PSMODULE_AUTO_RELEASE_INPUT_PatchLabels) -split ',' | ForEach-Object { $_.Trim() }
5652

5753
Write-Output '-------------------------------------------------'
5854
Write-Output "Auto cleanup enabled: [$autoCleanup]"
@@ -157,7 +153,7 @@ LogGroup 'Get latest version' {
157153
$latestRelease = $releases | Where-Object { $_.isLatest -eq $true }
158154
$latestRelease | Format-List | Out-String
159155
$latestVersionString = $latestRelease.tagName
160-
if ($latestVersionString | IsNotNullOrEmpty) {
156+
if ([string]::IsNullOrEmpty($latestVersionString)) {
161157
$latestVersion = $latestVersionString | ConvertTo-PSSemVer
162158
Write-Output '-------------------------------------------------'
163159
Write-Output 'Latest version:'
@@ -196,7 +192,7 @@ if ($createPrerelease -or $createRelease -or $whatIf) {
196192
$newVersion.Prerelease = $prereleaseName
197193
Write-Output "Partial new version: [$newVersion]"
198194

199-
if ($datePrereleaseFormat | IsNotNullOrEmpty) {
195+
if ([string]::IsNullOrEmpty($datePrereleaseFormat)) {
200196
Write-Output "Using date-based prerelease: [$datePrereleaseFormat]."
201197
$newVersion.Prerelease += ".$(Get-Date -Format $datePrereleaseFormat)"
202198
Write-Output "Partial new version: [$newVersion]"

0 commit comments

Comments
 (0)