diff --git a/.github/conventional_commits_labels.json b/.github/conventional_commits_labels.json new file mode 100644 index 00000000..059df552 --- /dev/null +++ b/.github/conventional_commits_labels.json @@ -0,0 +1,14 @@ +{ + "!": "breaking-change", + "chore": "dependency-update", + "docs": "docs", + "style": "none", + "ci": "build", + "build": "build", + "feat": "new-feature", + "test": "none", + "refactor": "none", + "revert": "none", + "perf": "enhancement", + "fix": "bug" +} \ No newline at end of file diff --git a/DubUrl.sln b/DubUrl.sln index b84bf58b..6269513e 100644 --- a/DubUrl.sln +++ b/DubUrl.sln @@ -8,10 +8,14 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DubUrl.Testing", "DubUrl.Testing\DubUrl.Testing.csproj", "{A0CDC412-D16C-4508-96FC-6F0BB383E962}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C923A152-4091-48BE-A984-686FF5E4ACCC}" + ProjectSection(SolutionItems) = preProject + conventional_commits_labels.yml = conventional_commits_labels.yml + EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{95E83BA6-B535-4D56-B06A-D00249A4EF00}" ProjectSection(SolutionItems) = preProject appveyor.yml = appveyor.yml + .github\conventional_commits_labels.json = .github\conventional_commits_labels.json Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets github.ps1 = github.ps1 diff --git a/appveyor.yml b/appveyor.yml index 45ad02f9..f06022dd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -34,7 +34,7 @@ before_build: SecretToken = $env:github_access_token } $context.Id = $context | Get-Commit-Associated-Pull-Requests - $context | Set-Pull-Request-Expected-Labels + $context | Set-Pull-Request-Expected-Labels -Config '.github\conventional_commits_labels.json' } else { Write-Host 'Not a merge on main built on appveyor. Skipping mapping conventional commits and labels.' } diff --git a/github.ps1 b/github.ps1 index 24bbaffb..5e8bb594 100644 --- a/github.ps1 +++ b/github.ps1 @@ -194,22 +194,28 @@ function Set-Pull-Request-Expected-Labels { [CmdletBinding()] Param( [Parameter(Mandatory=$true, ValueFromPipeline = $true)] - [object] $context + [object] $context, + [string] $config ) - $mapping = @{} - $mapping.Add('!', 'breaking-change') - $mapping.Add('build', 'build') - $mapping.Add('ci', 'build') - $mapping.Add('chore', 'dependency-update') - $mapping.Add('docs', 'docs') - $mapping.Add('feat', 'new-feature') - $mapping.Add('fix', 'bug') - $mapping.Add('perf', 'enhancement') - $mapping.Add('refactor', 'none') - $mapping.Add('revert', 'none') - $mapping.Add('style', 'none') - $mapping.Add('test', 'none') + if ($config) { + WRite-Host "Reading mapping from $config" + $mapping = (Get-Content $config | ConvertFrom-Json) + } else { + $mapping = @{} + $mapping.Add('!', 'breaking-change') + $mapping.Add('build', 'build') + $mapping.Add('ci', 'build') + $mapping.Add('chore', 'dependency-update') + $mapping.Add('docs', 'docs') + $mapping.Add('feat', 'new-feature') + $mapping.Add('fix', 'bug') + $mapping.Add('perf', 'enhancement') + $mapping.Add('refactor', 'none') + $mapping.Add('revert', 'none') + $mapping.Add('style', 'none') + $mapping.Add('test', 'none') + } $title = $context | Get-Pull-Request-Title $existing = $context | Get-Pull-Request-Labels @@ -226,4 +232,4 @@ function Set-Pull-Request-Expected-Labels { } else { Write-Host "Labels already up-to-date." } -} +} \ No newline at end of file