Skip to content

Commit ff914ef

Browse files
🪲[Fix] Fix label comparison with version labels (#22)
- Fix an issue where the release script would fail with a null comparison for a PR without labels. This PR changes the way comparison is done to avoid the null content issue.
1 parent 758e65c commit ff914ef

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

scripts/main.ps1

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,23 @@ $pull_request | Format-List
8888
Write-Output '::endgroup::'
8989

9090
Write-Output '::group::Pull request - Labels'
91-
$labels = @('...')
91+
$labels = @()
9292
$labels += $pull_request.labels.name
9393
$labels | Format-List
9494
Write-Output '::endgroup::'
9595

96-
$majorTags = @('major', 'breaking')
97-
$minorTags = @('minor', 'feature', 'improvement')
98-
$patchTags = @('patch', 'fix', 'bug')
96+
$majorLabels = @('major', 'breaking')
97+
$minorLabels = @('minor', 'feature', 'improvement')
98+
$patchLabels = @('patch', 'fix', 'bug')
9999

100100
$createRelease = $pull_request.base.ref -eq 'main' -and ($pull_request.merged).ToString() -eq 'True'
101101
$closedPullRequest = $pull_request.state -eq 'closed' -and ($pull_request.merged).ToString() -eq 'False'
102102
$preRelease = $labels -Contains 'prerelease'
103103
$createPrerelease = $preRelease -and -not $createRelease -and -not $closedPullRequest
104104

105-
$majorRelease = (Compare-Object -ReferenceObject $labels -DifferenceObject $majorTags -IncludeEqual -ExcludeDifferent).Count -gt 0
106-
$minorRelease = (Compare-Object -ReferenceObject $labels -DifferenceObject $minorTags -IncludeEqual -ExcludeDifferent).Count -gt 0 -and -not $majorRelease
107-
$patchRelease = (Compare-Object -ReferenceObject $labels -DifferenceObject $patchTags -IncludeEqual -ExcludeDifferent).Count -gt 0 -and -not $majorRelease -and -not $minorRelease
105+
$majorRelease = ($labels | Where-Object { $majorLabels -contains $_ }).Count -gt 0
106+
$minorRelease = ($labels | Where-Object { $minorLabels -contains $_ }).Count -gt 0 -and -not $majorRelease
107+
$patchRelease = ($labels | Where-Object { $patchLabels -contains $_ }).Count -gt 0 -and -not $majorRelease -and -not $minorRelease
108108

109109
Write-Output '-------------------------------------------------'
110110
Write-Output "Create a release: [$createRelease]"

0 commit comments

Comments
 (0)