Closed sebastianrosch closed 1 month ago
Good day.
So before looking into the extractor itself, I'd like to point out that in your case you use the default configuration for categories, so chore
would not be recognized as a category.
The default categories are: https://github.com/mikepenz/release-changelog-builder-action/blob/v4.2.2/src/configuration.ts#L76-L93
That said you can probably use something like this instead: https://github.com/mikepenz/release-changelog-builder-action/issues/1172#issuecomment-1650493613 whichever is first in []
to be the label. that also scales better for the future.
Unless you already used that too?
Hi @mikepenz, thanks for the quick response.
I tried lots of different configurations and also defined them explicitly.
For example:
{
"template": "#{{CHANGELOG}}\n\n<details>\n<summary>Uncategorized</summary>\n\n#{{UNCATEGORIZED}}\n</details>",
"categories": [
{
"title": "## 🚀 Features",
"labels": [
"feat",
"feature"
]
},
{
"title": "## 🐛 Fixes",
"labels": [
"fix",
"bug"
]
},
{
"title": "## 🛠️ Chores",
"labels": [
"chore"
]
},
{
"title": "## 🛠️ Dependencies",
"labels": [
"deps"
]
}
],
"label_extractor": [
{
"method": "match",
"pattern": "^\\[(\\w*)\\]",
"target": "$1",
"on_property": "title"
}
]
}
In my understanding of the regex, it should match Chore
in the case of a PR titled [Chore] ....
. I also tried defining the labels in the categories as title case. I've played around with the regex in regex tools to see if that works, then escaped the \
. I still get all PRs as uncategorized. It seems like it reads the JSON correctly as the template looks different.
Am I not getting something regarding the escaping of the regex or the definition of the labels?
Thanks!
Is the repo you run those on open source? Would allow me to reproduce it more quickly
The repos I'm trying to do this for are not, but I was able to reproduce it in this public repo: https://github.com/sebastianrosch/changelog-test
That is super helpful. Using your demo repo. Here's an adjusted config which should handle your use-case:
{
"template": "#Changes: #{{CHANGELOG}}\n\n<details>\n<summary>Uncategorized</summary>\n\n#{{UNCATEGORIZED}}\n</details>",
"categories": [
{
"title": "## 🚀 Features",
"labels": [
"[feat]",
"[feature]",
"[Feature"
]
},
{
"title": "## 🐛 Fixes",
"labels": [
"[fix]",
"[bug]",
"[Fix]"
]
},
{
"title": "## 🛠️ Chores",
"labels": [
"[chore]",
"[Chore]"
]
},
{
"title": "## 🛠️ Dependencies",
"labels": [
"[deps]"
]
}
],
"label_extractor": [
{
"method": "match",
"pattern": "\\[.+?\\]",
"on_property": "title"
}
]
}
Key details:
#
was missing in front of CHANGELOG[]
bracket. note this will match including the bracket That said, v5 of the action actually contains a feature that makes such regex's much simpler, by offering a regex match logic similar to what regexr does.
So for @v5 the following will work:
{
"template": "#Changes: #{{CHANGELOG}}\n\n<details>\n<summary>Uncategorized</summary>\n\n#{{UNCATEGORIZED}}\n</details>",
"categories": [
{
"title": "## 🚀 Features",
"labels": [
"feat",
"feature",
"Feature"
]
},
{
"title": "## 🐛 Fixes",
"labels": [
"fix",
"bug",
"Fix"
]
},
{
"title": "## 🛠️ Chores",
"labels": [
"chore",
"Chore"
]
},
{
"title": "## 🛠️ Dependencies",
"labels": [
"deps"
]
}
],
"label_extractor": [
{
"method": "regexr",
"pattern": "\\[(.+?)\\].+",
"target": "$1",
"on_property": "title"
}
]
}
Awesome, thank you, that worked! I've tried the regexr
method before but didn't see that this was only supported in v5.
Thanks for the help!
I have tried lots of different configurations but can't figure out how to extract the label from the PR title. No matter what I do, I always get only uncategorized PRs.
The latest config I'm using looks like this:
I've looked at similar issues and found a reference to the test here: https://github.com/mikepenz/release-changelog-builder-action/blob/dffddcd83353ebb1c64f53b6cacfd6e24b707728/__tests__/transform.test.ts#L145
However, that's not working for me either.
Can you point out what I'm doing wrong?