Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/Action-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,23 @@ jobs:
$failed = $true
}
if ($failed) { exit 1 }

Pester-Unit-Tests:
name: Pester Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false

- name: Install PSSemVer
shell: pwsh
run: |
Install-PSResource -Name PSSemVer -Repository PSGallery -TrustRepository

- name: Run Pester tests
uses: PSModule/Invoke-Pester@266d1cf2532f572470b7c4463fa1072f2bfe4455 # v4.2.5
with:
Run_Path: ./tests
Output_Verbosity: Detailed
28 changes: 11 additions & 17 deletions scripts/Helpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -222,23 +222,17 @@ function Resolve-ReleaseDecision {
$shouldPublish = $false
}

$majorRelease = $false
$minorRelease = $false
$patchRelease = $false
$hasVersionBump = $false

if ($shouldPublish) {
$majorRelease = ($labels | Where-Object { $Configuration.MajorLabels -contains $_ }).Count -gt 0
$minorRelease = ($labels | Where-Object { $Configuration.MinorLabels -contains $_ }).Count -gt 0 -and -not $majorRelease
$patchRelease = (
(($labels | Where-Object { $Configuration.PatchLabels -contains $_ }).Count -gt 0) -or $Configuration.AutoPatching
) -and -not $majorRelease -and -not $minorRelease

$hasVersionBump = $majorRelease -or $minorRelease -or $patchRelease
if (-not $hasVersionBump) {
Write-Host 'No version bump label found and AutoPatching is disabled. No release will be created.'
$shouldPublish = $false
}
$majorRelease = ($labels | Where-Object { $Configuration.MajorLabels -contains $_ }).Count -gt 0
$minorRelease = ($labels | Where-Object { $Configuration.MinorLabels -contains $_ }).Count -gt 0 -and -not $majorRelease
$patchRelease = (
(($labels | Where-Object { $Configuration.PatchLabels -contains $_ }).Count -gt 0) -or $Configuration.AutoPatching
) -and -not $majorRelease -and -not $minorRelease

$hasVersionBump = $majorRelease -or $minorRelease -or $patchRelease

if ($shouldPublish -and -not $hasVersionBump) {
Write-Host 'No version bump label found and AutoPatching is disabled. No release will be created.'
$shouldPublish = $false
}

Write-Host '-------------------------------------------------'
Expand Down
26 changes: 11 additions & 15 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,18 @@ $config = Get-PublishConfiguration -SettingsJson $actionInput.SettingsJson
$pullRequest = Get-GitHubPullRequest
$decision = Resolve-ReleaseDecision -Configuration $config -PullRequest $pullRequest

$newVersion = $null
$releases = Get-GitHubRelease
$ghVersion = Get-LatestGitHubVersion -Releases $releases
$psGalleryVersion = Get-LatestPSGalleryVersion -ModuleName $actionInput.Name
$latestVersion = Get-LatestPublishedVersion -GitHubVersion $ghVersion -PSGalleryVersion $psGalleryVersion

if ($decision.ShouldPublish) {
$releases = Get-GitHubRelease
$ghVersion = Get-LatestGitHubVersion -Releases $releases
$psGalleryVersion = Get-LatestPSGalleryVersion -ModuleName $actionInput.Name
$latestVersion = Get-LatestPublishedVersion -GitHubVersion $ghVersion -PSGalleryVersion $psGalleryVersion

$params = @{
LatestVersion = $latestVersion
Decision = $decision
Configuration = $config
ModuleName = $actionInput.Name
Releases = $releases
}
$newVersion = Get-NextModuleVersion @params
$params = @{
LatestVersion = $latestVersion
Decision = $decision
Configuration = $config
ModuleName = $actionInput.Name
Releases = $releases
}
$newVersion = Get-NextModuleVersion @params

Write-ActionOutput -Decision $decision -NewVersion $newVersion
Loading
Loading