Skip to content

Commit

Permalink
🪲[Fix] Fix label comparison with version labels (#22)
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
MariusStorhaug authored Feb 17, 2024
1 parent 758e65c commit ff914ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -88,23 +88,23 @@ $pull_request | Format-List
Write-Output '::endgroup::'

Write-Output '::group::Pull request - Labels'
$labels = @('...')
$labels = @()
$labels += $pull_request.labels.name
$labels | Format-List
Write-Output '::endgroup::'

$majorTags = @('major', 'breaking')
$minorTags = @('minor', 'feature', 'improvement')
$patchTags = @('patch', 'fix', 'bug')
$majorLabels = @('major', 'breaking')
$minorLabels = @('minor', 'feature', 'improvement')
$patchLabels = @('patch', 'fix', 'bug')

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

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

Write-Output '-------------------------------------------------'
Write-Output "Create a release: [$createRelease]"
Expand Down

0 comments on commit ff914ef

Please sign in to comment.