Skip to content
Merged
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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ The action can be configured using the following settings:
| `CreateMajorTag` | Control wether to create a tag for major releases. | `true` | false |
| `CreateMinorTag` | Control wether to create a tag for minor releases. | `true` | false |
| `DatePrereleaseFormat` | The format to use for the prerelease number using [.NET DateTime format strings](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings). | `''` | false |
| `IgnoreLabels` | A comma separated list of labels that do not trigger a release. | `NoRelease` | false |
| `IncrementalPrerelease` | Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch. | `true` | false |
| `MajorLabels` | The labels to use for major releases. | `major, breaking` | false |
| `MinorLabels` | The labels to use for minor releases. | `minor, feature, improvement` | false |
| `PatchLabels` | The labels to use for patch releases. | `patch, fix, bug` | false |
| `MajorLabels` | A comma separated list of labels that trigger a major release. | `major, breaking` | false |
| `MinorLabels` | A comma separated list of labels that trigger a minor release. | `minor, feature, improvement` | false |
| `PatchLabels` | A comma separated list of labels that trigger a patch release. | `patch, fix, bug` | false |
| `VersionPrefix` | The prefix to use for the version number. | `v` | false |
| `WhatIf` | Control wether to simulate the action. If enabled, the action will not create any releases. Used for testing. | `false` | false |

Expand Down
19 changes: 12 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,30 @@ inputs:
description: If specified, uses a date based prerelease scheme. The format should be a valid .NET format string like 'yyyyMMddHHmm'.
required: false
default: ''
IgnoreLabels:
description: A comma separated list of labels that do not trigger a release.
required: false
default: NoRelease
IncrementalPrerelease:
description: Control wether to automatically increment the prerelease number. If disabled, the action will ensure only one prerelease exists for a given branch.
required: false
default: 'true'
MajorLabels:
description: The labels to use for major releases.
description: A comma separated list of labels that trigger a major release.
required: false
default: 'major, breaking'
default: major, breaking
MinorLabels:
description: The labels to use for minor releases.
description: A comma separated list of labels that trigger a minor release.
required: false
default: 'minor, feature, improvement'
default: minor, feature, improvement
PatchLabels:
description: The labels to use for patch releases.
description: A comma separated list of labels that trigger a patch release.
required: false
default: 'patch, fix, bug'
default: patch, fix, bug
VersionPrefix:
description: The prefix to use for the version number.
required: false
default: 'v'
default: v
WhatIf:
description: If specified, the action will only log the changes it would make, but will not actually create or delete any releases or tags.
required: false
Expand All @@ -67,6 +71,7 @@ runs:
CreateMajorTag: ${{ inputs.CreateMajorTag }}
CreateMinorTag: ${{ inputs.CreateMinorTag }}
DatePrereleaseFormat: ${{ inputs.DatePrereleaseFormat }}
IgnoreLabels: ${{ inputs.IgnoreLabels }}
IncrementalPrerelease: ${{ inputs.IncrementalPrerelease }}
MajorLabels: ${{ inputs.MajorLabels }}
MinorLabels: ${{ inputs.MinorLabels }}
Expand Down
58 changes: 32 additions & 26 deletions scripts/main.ps1
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
Write-Output '::group::Install - Utilities'
Install-PSResource -Name Utilities -TrustRepository
Write-Output '-------------------------------------------------'
Get-PSResource -Name Utilities | Format-Table
Write-Output '-------------------------------------------------'
Write-Output 'Get commands'
Get-Command -Module Utilities | Format-Table
Write-Output '-------------------------------------------------'
Write-Output 'Get aliases'
Get-Alias | Where-Object Source -EQ 'Utilities' | Format-Table
Write-Output '-------------------------------------------------'
Write-Output '::endgroup::'
function Install-Dependency {
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string] $Name
)

foreach ($item in $Name) {
Write-Output "::group::Install - $item"
Install-PSResource -Name $item -TrustRepository
Write-Output '-------------------------------------------------'
Get-PSResource -Name $item | Format-Table
Write-Output '-------------------------------------------------'
Write-Output 'Get commands'
Get-Command -Module $item | Format-Table
Write-Output '-------------------------------------------------'
Write-Output 'Get aliases'
Get-Alias | Where-Object Source -EQ $item | Format-Table
Write-Output '-------------------------------------------------'
Write-Output '::endgroup::'
}
}

Write-Output '::group::Install - powershell-yaml'
Install-PSResource -Name powershell-yaml -TrustRepository
Write-Output '-------------------------------------------------'
Get-PSResource -Name powershell-yaml | Format-Table
Write-Output '-------------------------------------------------'
Write-Output 'Get commands'
Get-Command -Module powershell-yaml | Format-Table
Write-Output '-------------------------------------------------'
Write-Output 'Get aliases'
Get-Alias | Where-Object Source -EQ 'powershell-yaml' | Format-Table
Write-Output '-------------------------------------------------'
Write-Output '::endgroup::'
Install-Dependency -Name 'Utilities', 'powershell-yaml'

Write-Output '::group::Environment variables'
Get-ChildItem -Path Env: | Select-Object Name, Value | Sort-Object Name | Format-Table -AutoSize
Expand All @@ -45,6 +44,7 @@ $incrementalPrerelease = ($configuration.IncrementalPrerelease | IsNotNullOrEmpt
$versionPrefix = ($configuration.VersionPrefix | IsNotNullOrEmpty) ? $configuration.VersionPrefix : $env:VersionPrefix
$whatIf = ($configuration.WhatIf | IsNotNullOrEmpty) ? $configuration.WhatIf -eq 'true' : $env:WhatIf -eq 'true'

$ignoreLabels = (($configuration.IgnoreLabels | IsNotNullOrEmpty) ? $configuration.IgnoreLabels : $env:IgnoreLabels) -split ',' | ForEach-Object { $_.Trim() }
$majorLabels = (($configuration.MajorLabels | IsNotNullOrEmpty) ? $configuration.MajorLabels : $env:MajorLabels) -split ',' | ForEach-Object { $_.Trim() }
$minorLabels = (($configuration.MinorLabels | IsNotNullOrEmpty) ? $configuration.MinorLabels : $env:MinorLabels) -split ',' | ForEach-Object { $_.Trim() }
$patchLabels = (($configuration.PatchLabels | IsNotNullOrEmpty) ? $configuration.PatchLabels : $env:PatchLabels) -split ',' | ForEach-Object { $_.Trim() }
Expand All @@ -59,13 +59,13 @@ Write-Output "Incremental prerelease enabled: [$incrementalPrerelease]"
Write-Output "Version prefix: [$versionPrefix]"
Write-Output "What if mode: [$whatIf]"
Write-Output ''
Write-Output "Ignore labels: [$($ignoreLabels -join ', ')]"
Write-Output "Major labels: [$($majorLabels -join ', ')]"
Write-Output "Minor labels: [$($minorLabels -join ', ')]"
Write-Output "Patch labels: [$($patchLabels -join ', ')]"
Write-Output '-------------------------------------------------'
Write-Output '::endgroup::'


Write-Output '::group::Event information - JSON'
$githubEventJson = Get-Content $env:GITHUB_EVENT_PATH
$githubEventJson | Format-List
Expand Down Expand Up @@ -108,10 +108,16 @@ $closedPullRequest = $pull_request.state -eq 'closed' -and ($pull_request.merged
$preRelease = $labels -Contains 'prerelease'
$createPrerelease = $preRelease -and -not $createRelease -and -not $closedPullRequest

$ignoreRelease = ($labels | Where-Object { $ignoreLabels -contains $_ }).Count -gt 0
$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

if($ignoreRelease) {
Write-Output 'Ignoring release creation.'
return
}

Write-Output '-------------------------------------------------'
Write-Output "Create a release: [$createRelease]"
Write-Output "Create a prerelease: [$createPrerelease]"
Expand Down Expand Up @@ -235,7 +241,7 @@ if ($createPrerelease -or $createRelease -or $whatIf) {
} else {
gh pr comment $pull_request.number -b "The release [$newVersion] has been created."
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to comment on the pull request."
Write-Error 'Failed to comment on the pull request.'
exit $LASTEXITCODE
}
}
Expand Down