Skip to content

Commit

Permalink
Redesign steps
Browse files Browse the repository at this point in the history
  • Loading branch information
hugoalh committed Sep 12, 2023
1 parent 4db9c06 commit b302fef
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 29 deletions.
11 changes: 6 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ runs:
- name: "Main"
run: |
#Requires -PSEdition Core -Version 7.2
$Script:ErrorActionPreference = 'Stop'
Get-Alias -Scope 'Local' -ErrorAction 'SilentlyContinue' |
Remove-Alias -Scope 'Local' -Force -ErrorAction 'SilentlyContinue'
[Boolean]$OsIsLinux = $Env:RUNNER_OS -ieq 'Linux'
[Boolean]$OsIsMac = $Env:RUNNER_OS -ieq 'MacOS'
[Boolean]$OsIsWindows = $Env:RUNNER_OS -ieq 'Windows'
[String]$MainScriptPath = Join-Path -Path $Env:GITHUB_ACTION_PATH -ChildPath 'main.ps1'
[Boolean]$OsIsLinux = $Env:RUNNER_OS -ieq 'Linux' -or $IsLinux
[Boolean]$OsIsMac = $Env:RUNNER_OS -ieq 'MacOS' -or $IsMacOS
[Boolean]$OsIsWindows = $Env:RUNNER_OS -ieq 'Windows' -or $IsWindows
If (!$OsIsLinux -and !$OsIsMac -and !$OsIsWindows) {
Write-Host -Object '::error::Unknown operate system!'
Exit 1
}
If (Test-Path -LiteralPath $MainScriptPath -PathType 'Leaf') {
[String]$MainScriptPath = Join-Path -Path $Env:GITHUB_ACTION_PATH -ChildPath 'main.ps1'
If (!(Test-Path -LiteralPath $MainScriptPath -PathType 'Leaf')) {
Write-Host -Object '::error::Invalid script path!'
Exit 1
}
Expand Down
28 changes: 4 additions & 24 deletions main.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#Requires -PSEdition Core -Version 7.2
$Script:ErrorActionPreference = 'Stop'
Write-Host -Object 'Initialize.'
[Boolean]$IsDebugMode = $Env:RUNNER_DEBUG -iin @('1', 'True')
[RegEx]$SemVerModifierRegEx = '^(?:[<>]=?|=|\^|~) *'
Function Install-ModuleTargetVersion {
Expand Down Expand Up @@ -100,7 +99,10 @@ Function Test-SemVerModifier {
}
}
}
Write-Host -Object 'Import input.'
[Boolean]$InputAllowPreRelease = [Boolean]::Parse($Env:INPUT_ALLOWPRERELEASE)
[Boolean]$InputForce = [Boolean]::Parse($Env:INPUT_FORCE)
[Boolean]$InputKeepSetting = [Boolean]::Parse($Env:INPUT_KEEPSETTING)
[String]$InputScope = $Env:INPUT_SCOPE
Try {
[String]$InputVersionRaw = $Env:INPUT_VERSION
[Boolean]$InputVersionLatest = $InputVersionRaw -ieq 'Latest'
Expand All @@ -114,28 +116,6 @@ Catch {
Write-Host -Object '::error::Input `version` is not `"Latest"` or a SemVer!'
Exit 1
}
Try {
[Boolean]$InputAllowPreRelease = [Boolean]::Parse($Env:INPUT_ALLOWPRERELEASE)
}
Catch {
Write-Host -Object '::error::Input `allowprerelease` is not a boolean!'
Exit 1
}
Try {
[Boolean]$InputForce = [Boolean]::Parse($Env:INPUT_FORCE)
}
Catch {
Write-Host -Object '::error::Input `force` is not a boolean!'
Exit 1
}
[String]$InputScope = $Env:INPUT_SCOPE
Try {
[Boolean]$InputKeepSetting = [Boolean]::Parse($Env:INPUT_KEEPSETTING)
}
Catch {
Write-Host -Object '::error::Input `keepsetting` is not a boolean!'
Exit 1
}
$PSRepositoryPSGalleryMeta = Get-PSRepository -Name 'PSGallery'
If ($PSRepositoryPSGalleryMeta.InstallationPolicy -ine 'Trusted') {
Write-Host -Object 'Tweak PowerShell repository configuration.'
Expand Down

0 comments on commit b302fef

Please sign in to comment.