Merge pull request #454 from mikepenz/develop

dev -> main
This commit is contained in:
Mike Penz
2021-08-26 17:28:21 +02:00
committed by GitHub
9 changed files with 494 additions and 1431 deletions
+3 -1
View File
@@ -82,6 +82,7 @@ A full set list of possible output values for this action.
| `outputs.fromTag` | Defines the `fromTag` which describes the lower bound to process pull requests for | | `outputs.fromTag` | Defines the `fromTag` which describes the lower bound to process pull requests for |
| `outputs.toTag` | Defines the `toTag` which describes the upper bound to process pull request for | | `outputs.toTag` | Defines the `toTag` which describes the upper bound to process pull request for |
| `outputs.failed` | Defines if there was an issue with the action run, and the changelog may not have been generated correctly. [true, false] | | `outputs.failed` | Defines if there was an issue with the action run, and the changelog may not have been generated correctly. [true, false] |
| `outputs.pull_requests` | Defines a `,` joined array with all PR IDs associated with the generated changelog. |
## Full Sample 🖥️ ## Full Sample 🖥️
@@ -296,8 +297,9 @@ Table of descriptions for the `configuration.json` options to configure the resu
| empty_template | Template to pick if no changes are detected. See [Template placeholders](#template-placeholders) for possible values | | empty_template | Template to pick if no changes are detected. See [Template placeholders](#template-placeholders) for possible values |
| label_extractor | An array of `transform` specifications, offering a flexible API to extract additinal labels from a PR (Default: `body`, Default in commit mode: `commit message`). | | label_extractor | An array of `transform` specifications, offering a flexible API to extract additinal labels from a PR (Default: `body`, Default in commit mode: `commit message`). |
| label_extractor.pattern | A `regex` pattern, extracting values of the change message. | | label_extractor.pattern | A `regex` pattern, extracting values of the change message. |
| label_extractor.target | The result pattern. The result text will be used as label. If empty, no label is created. | | label_extractor.target | The result pattern. The result text will be used as label. If empty, no label is created. (Unused for `match` method) |
| label_extractor.on_property | The property to retrieve the text from. This is optional. Defaults to: `body`. Alternative values: `title`, `author`, `milestone`. | | label_extractor.on_property | The property to retrieve the text from. This is optional. Defaults to: `body`. Alternative values: `title`, `author`, `milestone`. |
| label_extractor.method | The extraction method used. Defaults to: `replace`. Alternative value: `match`. The method specified references the JavaScript String method. |
| label_extractor.flags | Defines the regex flags specified for the pattern. Default: `gu` | | label_extractor.flags | Defines the regex flags specified for the pattern. Default: `gu` |
| transformers | An array of `transform` specifications, offering a flexible API to modify the text per pull request. This is applied on the change text created with `pr_template`. `transformers` are executed per change, in the order specified | | transformers | An array of `transform` specifications, offering a flexible API to modify the text per pull request. This is applied on the change text created with `pr_template`. `transformers` are executed per change, in the order specified |
| transformer.pattern | A `regex` pattern, extracting values of the change message. | | transformer.pattern | A `regex` pattern, extracting values of the change message. |
+191
View File
@@ -0,0 +1,191 @@
import {buildChangelog} from '../src/transform'
import { PullRequestInfo } from '../src/pullRequests'
import moment from 'moment'
import { DefaultConfiguration } from '../src/configuration';
jest.setTimeout(180000)
let configuration = DefaultConfiguration
configuration.categories = [
{
"title": "## 🚀 Features",
"labels": ["[Feature]"]
},
{
"title": "## 🐛 Fixes",
"labels": ["[Bug]", "[Issue]"]
},
{
"title": "## 🧪 Tests",
"labels": ["[Test]"]
}
]
let mergedPullRequests: PullRequestInfo[] = []
mergedPullRequests.push({
number: 1,
title: "[Feature][AB-1234] - this is a PR 1 title message",
htmlURL: "",
baseBranch: "",
mergedAt: moment(),
mergeCommitSha: "sha1",
author: "Mike",
repoName: "test-repo",
labels: new Set<string>(),
milestone: "",
body: "no magic body for this matter",
assignees: [],
requestedReviewers: []
}, {
number: 2,
title: "[Issue][AB-4321] - this is a PR 2 title message",
htmlURL: "",
baseBranch: "",
mergedAt: moment(),
mergeCommitSha: "sha1",
author: "Mike",
repoName: "test-repo",
labels: new Set<string>(),
milestone: "",
body: "no magic body for this matter",
assignees: [],
requestedReviewers: []
}, {
number: 3,
title: "[Issue][Feature][AB-1234321] - this is a PR 3 title message",
htmlURL: "",
baseBranch: "",
mergedAt: moment(),
mergeCommitSha: "sha1",
author: "Mike",
repoName: "test-repo",
labels: new Set<string>(),
milestone: "",
body: "no magic body for this matter",
assignees: [],
requestedReviewers: []
}, {
number: 4,
title: "[AB-404] - not found label",
htmlURL: "",
baseBranch: "",
mergedAt: moment(),
mergeCommitSha: "sha1",
author: "Mike",
repoName: "test-repo",
labels: new Set<string>(),
milestone: "",
body: "no magic body for this matter",
assignees: [],
requestedReviewers: []
})
it('Extract label from title, combined regex', async () => {
configuration.label_extractor = [
{
"pattern": ".*(\\[Feature\\]|\\[Issue\\]).*",
"target": "$1",
"on_property": "title"
}
]
const resultChangelog = buildChangelog(
mergedPullRequests,
{
owner: "mikepenz",
repo: "test-repo",
fromTag: "1.0.0",
toTag: "2.0.0",
failOnError: false,
commitMode: false,
configuration: configuration
}
)
expect(resultChangelog).toStrictEqual(`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n\n`)
})
it('Extract label from title, split regex', async () => {
configuration.label_extractor = [
{
"pattern": ".*(\\[Feature\\]).*",
"target": "$1",
"on_property": "title"
},
{
"pattern": ".*(\\[Issue\\]).*",
"target": "$1",
"on_property": "title"
}
]
const resultChangelog = buildChangelog(
mergedPullRequests,
{
owner: "mikepenz",
repo: "test-repo",
fromTag: "1.0.0",
toTag: "2.0.0",
failOnError: false,
commitMode: false,
configuration: configuration
}
)
expect(resultChangelog).toStrictEqual(`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n`)
})
it('Extract label from title, match', async () => {
configuration.label_extractor = [
{
"pattern": "\\[Feature\\]",
"on_property": "title",
"method": "match"
},
{
"pattern": "\\[Issue\\]",
"on_property": "title",
"method": "match"
}
]
const resultChangelog = buildChangelog(
mergedPullRequests,
{
owner: "mikepenz",
repo: "test-repo",
fromTag: "1.0.0",
toTag: "2.0.0",
failOnError: false,
commitMode: false,
configuration: configuration
}
)
expect(resultChangelog).toStrictEqual(`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n`)
})
it('Extract label from title, match multiple', async () => {
configuration.label_extractor = [
{
"pattern": "\\[Feature\\]|\\[Issue\\]",
"on_property": "title",
"method": "match"
}
]
const resultChangelog = buildChangelog(
mergedPullRequests,
{
owner: "mikepenz",
repo: "test-repo",
fromTag: "1.0.0",
toTag: "2.0.0",
failOnError: false,
commitMode: false,
configuration: configuration
}
)
expect(resultChangelog).toStrictEqual(`## 🚀 Features\n\n- [Feature][AB-1234] - this is a PR 1 title message\n - PR: #1\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n## 🐛 Fixes\n\n- [Issue][AB-4321] - this is a PR 2 title message\n - PR: #2\n- [Issue][Feature][AB-1234321] - this is a PR 3 title message\n - PR: #3\n\n`)
})
Generated Vendored
+68 -1289
View File
File diff suppressed because it is too large Load Diff
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+175 -103
View File
@@ -9,20 +9,20 @@
"version": "v1.0.0", "version": "v1.0.0",
"license": "Apache 2.0", "license": "Apache 2.0",
"dependencies": { "dependencies": {
"@actions/core": "^1.4.0", "@actions/core": "^1.5.0",
"@actions/exec": "^1.1.0", "@actions/exec": "^1.1.0",
"@actions/github": "^5.0.0", "@actions/github": "^5.0.0",
"@octokit/rest": "^18.9.0", "@octokit/rest": "^18.9.1",
"@types/semver": "^7.3.8", "@types/semver": "^7.3.8",
"moment": "^2.29.1", "moment": "^2.29.1",
"semver": "^7.3.5", "semver": "^7.3.5",
"webpack": "^5.50.0" "webpack": "^5.51.1"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^27.0.1", "@types/jest": "^27.0.1",
"@types/node": "^16.6.1", "@types/node": "^16.7.2",
"@typescript-eslint/parser": "^4.29.1", "@typescript-eslint/parser": "^4.29.3",
"@vercel/ncc": "^0.29.1", "@vercel/ncc": "^0.29.2",
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-plugin-github": "^4.2.0", "eslint-plugin-github": "^4.2.0",
"eslint-plugin-jest": "^24.4.0", "eslint-plugin-jest": "^24.4.0",
@@ -30,14 +30,14 @@
"jest-circus": "^27.0.6", "jest-circus": "^27.0.6",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"prettier": "2.3.2", "prettier": "2.3.2",
"ts-jest": "^27.0.4", "ts-jest": "^27.0.5",
"typescript": "^4.3.5" "typescript": "^4.3.5"
} }
}, },
"node_modules/@actions/core": { "node_modules/@actions/core": {
"version": "1.4.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.4.0.tgz", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.5.0.tgz",
"integrity": "sha512-CGx2ilGq5i7zSLgiiGUtBCxhRRxibJYU6Fim0Q1Wg2aQL2LTnF27zbqZOrxfvFQ55eSBW0L8uVStgtKMpa0Qlg==" "integrity": "sha512-eDOLH1Nq9zh+PJlYLqEMkS/jLQxhksPNmUGNBHfa4G+tQmnIhzpctxmchETtVGyBOvXgOVVpYuE40+eS4cUnwQ=="
}, },
"node_modules/@actions/exec": { "node_modules/@actions/exec": {
"version": "1.1.0", "version": "1.1.0",
@@ -1282,26 +1282,14 @@
} }
}, },
"node_modules/@octokit/rest": { "node_modules/@octokit/rest": {
"version": "18.9.0", "version": "18.9.1",
"resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.9.0.tgz", "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.9.1.tgz",
"integrity": "sha512-VrmrE8gjpuOoDAGjrQq2j9ZhOE6LxaqxaQg0yMrrEnnQZy2ZcAnr5qbVfKsMF0up/48PRV/VFS/2GSMhA7nTdA==", "integrity": "sha512-idZ3e5PqXVWOhtZYUa546IDHTHjkGZbj3tcJsN0uhCy984KD865e8GB2WbYDc2ZxFuJRiyd0AftpL2uPNhF+UA==",
"dependencies": { "dependencies": {
"@octokit/core": "^3.5.0", "@octokit/core": "^3.5.0",
"@octokit/plugin-paginate-rest": "^2.6.2", "@octokit/plugin-paginate-rest": "^2.6.2",
"@octokit/plugin-request-log": "^1.0.2", "@octokit/plugin-request-log": "^1.0.2",
"@octokit/plugin-rest-endpoint-methods": "5.7.0" "@octokit/plugin-rest-endpoint-methods": "5.8.0"
}
},
"node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods": {
"version": "5.7.0",
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.7.0.tgz",
"integrity": "sha512-G7sgccWRYQMwcHJXkDY/sDxbXeKiZkFQqUtzBCwmrzCNj2GQf3VygQ4T/BFL2crLVpIbenkE/c0ErhYOte2MPw==",
"dependencies": {
"@octokit/types": "^6.24.0",
"deprecation": "^2.3.1"
},
"peerDependencies": {
"@octokit/core": ">=3"
} }
}, },
"node_modules/@octokit/types": { "node_modules/@octokit/types": {
@@ -1452,9 +1440,9 @@
"integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==" "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ=="
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "16.6.1", "version": "16.7.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.6.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.2.tgz",
"integrity": "sha512-Sr7BhXEAer9xyGuCN3Ek9eg9xPviCF2gfu9kTfuU2HkTVAMYSDeX40fvpmo72n5nansg3nsBjuQBrsS28r+NUw==" "integrity": "sha512-TbG4TOx9hng8FKxaVrCisdaxKxqEwJ3zwHoCWXZ0Jw6mnvTInpaB99/2Cy4+XxpXtjNv9/TgfGSvZFyfV/t8Fw=="
}, },
"node_modules/@types/prettier": { "node_modules/@types/prettier": {
"version": "2.3.2", "version": "2.3.2",
@@ -1562,14 +1550,14 @@
} }
}, },
"node_modules/@typescript-eslint/parser": { "node_modules/@typescript-eslint/parser": {
"version": "4.29.1", "version": "4.29.3",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.3.tgz",
"integrity": "sha512-3fL5iN20hzX3Q4OkG7QEPFjZV2qsVGiDhEwwh+EkmE/w7oteiOvUNzmpu5eSwGJX/anCryONltJ3WDmAzAoCMg==", "integrity": "sha512-jrHOV5g2u8ROghmspKoW7pN8T/qUzk0+DITun0MELptvngtMrwUJ1tv5zMI04CYVEUsSrN4jV7AKSv+I0y0EfQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@typescript-eslint/scope-manager": "4.29.1", "@typescript-eslint/scope-manager": "4.29.3",
"@typescript-eslint/types": "4.29.1", "@typescript-eslint/types": "4.29.3",
"@typescript-eslint/typescript-estree": "4.29.1", "@typescript-eslint/typescript-estree": "4.29.3",
"debug": "^4.3.1" "debug": "^4.3.1"
}, },
"engines": { "engines": {
@@ -1588,6 +1576,80 @@
} }
} }
}, },
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": {
"version": "4.29.3",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.3.tgz",
"integrity": "sha512-x+w8BLXO7iWPkG5mEy9bA1iFRnk36p/goVlYobVWHyDw69YmaH9q6eA+Fgl7kYHmFvWlebUTUfhtIg4zbbl8PA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "4.29.3",
"@typescript-eslint/visitor-keys": "4.29.3"
},
"engines": {
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": {
"version": "4.29.3",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.3.tgz",
"integrity": "sha512-s1eV1lKNgoIYLAl1JUba8NhULmf+jOmmeFO1G5MN/RBCyyzg4TIOfIOICVNC06lor+Xmy4FypIIhFiJXOknhIg==",
"dev": true,
"engines": {
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": {
"version": "4.29.3",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.3.tgz",
"integrity": "sha512-45oQJA0bxna4O5TMwz55/TpgjX1YrAPOI/rb6kPgmdnemRZx/dB0rsx+Ku8jpDvqTxcE1C/qEbVHbS3h0hflag==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "4.29.3",
"@typescript-eslint/visitor-keys": "4.29.3",
"debug": "^4.3.1",
"globby": "^11.0.3",
"is-glob": "^4.0.1",
"semver": "^7.3.5",
"tsutils": "^3.21.0"
},
"engines": {
"node": "^10.12.0 || >=12.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependenciesMeta": {
"typescript": {
"optional": true
}
}
},
"node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": {
"version": "4.29.3",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.3.tgz",
"integrity": "sha512-MGGfJvXT4asUTeVs0Q2m+sY63UsfnA+C/FDgBKV3itLBmM9H0u+URcneePtkd0at1YELmZK6HSolCqM4Fzs6yA==",
"dev": true,
"dependencies": {
"@typescript-eslint/types": "4.29.3",
"eslint-visitor-keys": "^2.0.0"
},
"engines": {
"node": "^8.10.0 || ^10.13.0 || >=11.10.1"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/scope-manager": { "node_modules/@typescript-eslint/scope-manager": {
"version": "4.29.1", "version": "4.29.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.1.tgz",
@@ -1663,9 +1725,9 @@
} }
}, },
"node_modules/@vercel/ncc": { "node_modules/@vercel/ncc": {
"version": "0.29.1", "version": "0.29.2",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.29.1.tgz", "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.29.2.tgz",
"integrity": "sha512-92d2AApJtkpampMqKgfqWbYkuFvqRFs8kPkKLTbesSB9RVwWfiI3i6mgBxtZgMV9iRuLPVZ+OBNocKHXZSRj6Q==", "integrity": "sha512-eUxibZD92k+rY0oZJFZooGqdVpGkDrrHlUhj9UAWrtoyXCGmNOWC1Kcr2KPrZoHRSlWwHOcRnkn2nGT+aHY2KA==",
"dev": true, "dev": true,
"bin": { "bin": {
"ncc": "dist/ncc/cli.js" "ncc": "dist/ncc/cli.js"
@@ -5213,18 +5275,6 @@
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true "dev": true
}, },
"node_modules/mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"dev": true,
"bin": {
"mkdirp": "bin/cmd.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/moment": { "node_modules/moment": {
"version": "2.29.1", "version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
@@ -6435,19 +6485,17 @@
} }
}, },
"node_modules/ts-jest": { "node_modules/ts-jest": {
"version": "27.0.4", "version": "27.0.5",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-27.0.4.tgz", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-27.0.5.tgz",
"integrity": "sha512-c4E1ECy9Xz2WGfTMyHbSaArlIva7Wi2p43QOMmCqjSSjHP06KXv+aT+eSY+yZMuqsMi3k7pyGsGj2q5oSl5WfQ==", "integrity": "sha512-lIJApzfTaSSbtlksfFNHkWOzLJuuSm4faFAfo5kvzOiRAuoN4/eKxVJ2zEAho8aecE04qX6K1pAzfH5QHL1/8w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"bs-logger": "0.x", "bs-logger": "0.x",
"buffer-from": "1.x",
"fast-json-stable-stringify": "2.x", "fast-json-stable-stringify": "2.x",
"jest-util": "^27.0.0", "jest-util": "^27.0.0",
"json5": "2.x", "json5": "2.x",
"lodash": "4.x", "lodash": "4.x",
"make-error": "1.x", "make-error": "1.x",
"mkdirp": "1.x",
"semver": "7.x", "semver": "7.x",
"yargs-parser": "20.x" "yargs-parser": "20.x"
}, },
@@ -6459,7 +6507,7 @@
}, },
"peerDependencies": { "peerDependencies": {
"@babel/core": ">=7.0.0-beta.0 <8", "@babel/core": ">=7.0.0-beta.0 <8",
"@types/jest": "^26.0.0", "@types/jest": "^27.0.0",
"babel-jest": ">=27.0.0 <28", "babel-jest": ">=27.0.0 <28",
"jest": "^27.0.0", "jest": "^27.0.0",
"typescript": ">=3.8 <5.0" "typescript": ">=3.8 <5.0"
@@ -6708,9 +6756,9 @@
} }
}, },
"node_modules/webpack": { "node_modules/webpack": {
"version": "5.50.0", "version": "5.51.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.50.0.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.51.1.tgz",
"integrity": "sha512-hqxI7t/KVygs0WRv/kTgUW8Kl3YC81uyWQSo/7WUs5LsuRw0htH/fCwbVBGCuiX/t4s7qzjXFcf41O8Reiypag==", "integrity": "sha512-xsn3lwqEKoFvqn4JQggPSRxE4dhsRcysWTqYABAZlmavcoTmwlOb9b1N36Inbt/eIispSkuHa80/FJkDTPos1A==",
"dependencies": { "dependencies": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",
"@types/estree": "^0.0.50", "@types/estree": "^0.0.50",
@@ -6971,9 +7019,9 @@
}, },
"dependencies": { "dependencies": {
"@actions/core": { "@actions/core": {
"version": "1.4.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.4.0.tgz", "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.5.0.tgz",
"integrity": "sha512-CGx2ilGq5i7zSLgiiGUtBCxhRRxibJYU6Fim0Q1Wg2aQL2LTnF27zbqZOrxfvFQ55eSBW0L8uVStgtKMpa0Qlg==" "integrity": "sha512-eDOLH1Nq9zh+PJlYLqEMkS/jLQxhksPNmUGNBHfa4G+tQmnIhzpctxmchETtVGyBOvXgOVVpYuE40+eS4cUnwQ=="
}, },
"@actions/exec": { "@actions/exec": {
"version": "1.1.0", "version": "1.1.0",
@@ -7963,25 +8011,14 @@
} }
}, },
"@octokit/rest": { "@octokit/rest": {
"version": "18.9.0", "version": "18.9.1",
"resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.9.0.tgz", "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-18.9.1.tgz",
"integrity": "sha512-VrmrE8gjpuOoDAGjrQq2j9ZhOE6LxaqxaQg0yMrrEnnQZy2ZcAnr5qbVfKsMF0up/48PRV/VFS/2GSMhA7nTdA==", "integrity": "sha512-idZ3e5PqXVWOhtZYUa546IDHTHjkGZbj3tcJsN0uhCy984KD865e8GB2WbYDc2ZxFuJRiyd0AftpL2uPNhF+UA==",
"requires": { "requires": {
"@octokit/core": "^3.5.0", "@octokit/core": "^3.5.0",
"@octokit/plugin-paginate-rest": "^2.6.2", "@octokit/plugin-paginate-rest": "^2.6.2",
"@octokit/plugin-request-log": "^1.0.2", "@octokit/plugin-request-log": "^1.0.2",
"@octokit/plugin-rest-endpoint-methods": "5.7.0" "@octokit/plugin-rest-endpoint-methods": "5.8.0"
},
"dependencies": {
"@octokit/plugin-rest-endpoint-methods": {
"version": "5.7.0",
"resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.7.0.tgz",
"integrity": "sha512-G7sgccWRYQMwcHJXkDY/sDxbXeKiZkFQqUtzBCwmrzCNj2GQf3VygQ4T/BFL2crLVpIbenkE/c0ErhYOte2MPw==",
"requires": {
"@octokit/types": "^6.24.0",
"deprecation": "^2.3.1"
}
}
} }
}, },
"@octokit/types": { "@octokit/types": {
@@ -8129,9 +8166,9 @@
"integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ==" "integrity": "sha512-qcUXuemtEu+E5wZSJHNxUXeCZhAfXKQ41D+duX+VYPde7xyEVZci+/oXKJL13tnRs9lR2pr4fod59GT6/X1/yQ=="
}, },
"@types/node": { "@types/node": {
"version": "16.6.1", "version": "16.7.2",
"resolved": "https://registry.npmjs.org/@types/node/-/node-16.6.1.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.2.tgz",
"integrity": "sha512-Sr7BhXEAer9xyGuCN3Ek9eg9xPviCF2gfu9kTfuU2HkTVAMYSDeX40fvpmo72n5nansg3nsBjuQBrsS28r+NUw==" "integrity": "sha512-TbG4TOx9hng8FKxaVrCisdaxKxqEwJ3zwHoCWXZ0Jw6mnvTInpaB99/2Cy4+XxpXtjNv9/TgfGSvZFyfV/t8Fw=="
}, },
"@types/prettier": { "@types/prettier": {
"version": "2.3.2", "version": "2.3.2",
@@ -8206,15 +8243,58 @@
} }
}, },
"@typescript-eslint/parser": { "@typescript-eslint/parser": {
"version": "4.29.1", "version": "4.29.3",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.1.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-4.29.3.tgz",
"integrity": "sha512-3fL5iN20hzX3Q4OkG7QEPFjZV2qsVGiDhEwwh+EkmE/w7oteiOvUNzmpu5eSwGJX/anCryONltJ3WDmAzAoCMg==", "integrity": "sha512-jrHOV5g2u8ROghmspKoW7pN8T/qUzk0+DITun0MELptvngtMrwUJ1tv5zMI04CYVEUsSrN4jV7AKSv+I0y0EfQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@typescript-eslint/scope-manager": "4.29.1", "@typescript-eslint/scope-manager": "4.29.3",
"@typescript-eslint/types": "4.29.1", "@typescript-eslint/types": "4.29.3",
"@typescript-eslint/typescript-estree": "4.29.1", "@typescript-eslint/typescript-estree": "4.29.3",
"debug": "^4.3.1" "debug": "^4.3.1"
},
"dependencies": {
"@typescript-eslint/scope-manager": {
"version": "4.29.3",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-4.29.3.tgz",
"integrity": "sha512-x+w8BLXO7iWPkG5mEy9bA1iFRnk36p/goVlYobVWHyDw69YmaH9q6eA+Fgl7kYHmFvWlebUTUfhtIg4zbbl8PA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.29.3",
"@typescript-eslint/visitor-keys": "4.29.3"
}
},
"@typescript-eslint/types": {
"version": "4.29.3",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-4.29.3.tgz",
"integrity": "sha512-s1eV1lKNgoIYLAl1JUba8NhULmf+jOmmeFO1G5MN/RBCyyzg4TIOfIOICVNC06lor+Xmy4FypIIhFiJXOknhIg==",
"dev": true
},
"@typescript-eslint/typescript-estree": {
"version": "4.29.3",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-4.29.3.tgz",
"integrity": "sha512-45oQJA0bxna4O5TMwz55/TpgjX1YrAPOI/rb6kPgmdnemRZx/dB0rsx+Ku8jpDvqTxcE1C/qEbVHbS3h0hflag==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.29.3",
"@typescript-eslint/visitor-keys": "4.29.3",
"debug": "^4.3.1",
"globby": "^11.0.3",
"is-glob": "^4.0.1",
"semver": "^7.3.5",
"tsutils": "^3.21.0"
}
},
"@typescript-eslint/visitor-keys": {
"version": "4.29.3",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-4.29.3.tgz",
"integrity": "sha512-MGGfJvXT4asUTeVs0Q2m+sY63UsfnA+C/FDgBKV3itLBmM9H0u+URcneePtkd0at1YELmZK6HSolCqM4Fzs6yA==",
"dev": true,
"requires": {
"@typescript-eslint/types": "4.29.3",
"eslint-visitor-keys": "^2.0.0"
}
}
} }
}, },
"@typescript-eslint/scope-manager": { "@typescript-eslint/scope-manager": {
@@ -8259,9 +8339,9 @@
} }
}, },
"@vercel/ncc": { "@vercel/ncc": {
"version": "0.29.1", "version": "0.29.2",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.29.1.tgz", "resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.29.2.tgz",
"integrity": "sha512-92d2AApJtkpampMqKgfqWbYkuFvqRFs8kPkKLTbesSB9RVwWfiI3i6mgBxtZgMV9iRuLPVZ+OBNocKHXZSRj6Q==", "integrity": "sha512-eUxibZD92k+rY0oZJFZooGqdVpGkDrrHlUhj9UAWrtoyXCGmNOWC1Kcr2KPrZoHRSlWwHOcRnkn2nGT+aHY2KA==",
"dev": true "dev": true
}, },
"@webassemblyjs/ast": { "@webassemblyjs/ast": {
@@ -10991,12 +11071,6 @@
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true "dev": true
}, },
"mkdirp": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz",
"integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==",
"dev": true
},
"moment": { "moment": {
"version": "2.29.1", "version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz", "resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
@@ -11890,19 +11964,17 @@
} }
}, },
"ts-jest": { "ts-jest": {
"version": "27.0.4", "version": "27.0.5",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-27.0.4.tgz", "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-27.0.5.tgz",
"integrity": "sha512-c4E1ECy9Xz2WGfTMyHbSaArlIva7Wi2p43QOMmCqjSSjHP06KXv+aT+eSY+yZMuqsMi3k7pyGsGj2q5oSl5WfQ==", "integrity": "sha512-lIJApzfTaSSbtlksfFNHkWOzLJuuSm4faFAfo5kvzOiRAuoN4/eKxVJ2zEAho8aecE04qX6K1pAzfH5QHL1/8w==",
"dev": true, "dev": true,
"requires": { "requires": {
"bs-logger": "0.x", "bs-logger": "0.x",
"buffer-from": "1.x",
"fast-json-stable-stringify": "2.x", "fast-json-stable-stringify": "2.x",
"jest-util": "^27.0.0", "jest-util": "^27.0.0",
"json5": "2.x", "json5": "2.x",
"lodash": "4.x", "lodash": "4.x",
"make-error": "1.x", "make-error": "1.x",
"mkdirp": "1.x",
"semver": "7.x", "semver": "7.x",
"yargs-parser": "20.x" "yargs-parser": "20.x"
} }
@@ -12091,9 +12163,9 @@
"dev": true "dev": true
}, },
"webpack": { "webpack": {
"version": "5.50.0", "version": "5.51.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.50.0.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.51.1.tgz",
"integrity": "sha512-hqxI7t/KVygs0WRv/kTgUW8Kl3YC81uyWQSo/7WUs5LsuRw0htH/fCwbVBGCuiX/t4s7qzjXFcf41O8Reiypag==", "integrity": "sha512-xsn3lwqEKoFvqn4JQggPSRxE4dhsRcysWTqYABAZlmavcoTmwlOb9b1N36Inbt/eIispSkuHa80/FJkDTPos1A==",
"requires": { "requires": {
"@types/eslint-scope": "^3.7.0", "@types/eslint-scope": "^3.7.0",
"@types/estree": "^0.0.50", "@types/estree": "^0.0.50",
+7 -7
View File
@@ -32,20 +32,20 @@
"author": "Mike Penz", "author": "Mike Penz",
"license": "Apache 2.0", "license": "Apache 2.0",
"dependencies": { "dependencies": {
"@actions/core": "^1.4.0", "@actions/core": "^1.5.0",
"@actions/exec": "^1.1.0", "@actions/exec": "^1.1.0",
"@actions/github": "^5.0.0", "@actions/github": "^5.0.0",
"@octokit/rest": "^18.9.0", "@octokit/rest": "^18.9.1",
"@types/semver": "^7.3.8", "@types/semver": "^7.3.8",
"moment": "^2.29.1", "moment": "^2.29.1",
"semver": "^7.3.5", "semver": "^7.3.5",
"webpack": "^5.50.0" "webpack": "^5.51.1"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^27.0.1", "@types/jest": "^27.0.1",
"@types/node": "^16.6.1", "@types/node": "^16.7.2",
"@typescript-eslint/parser": "^4.29.1", "@typescript-eslint/parser": "^4.29.3",
"@vercel/ncc": "^0.29.1", "@vercel/ncc": "^0.29.2",
"eslint": "^7.32.0", "eslint": "^7.32.0",
"eslint-plugin-github": "^4.2.0", "eslint-plugin-github": "^4.2.0",
"eslint-plugin-jest": "^24.4.0", "eslint-plugin-jest": "^24.4.0",
@@ -53,7 +53,7 @@
"jest-circus": "^27.0.6", "jest-circus": "^27.0.6",
"js-yaml": "^4.1.0", "js-yaml": "^4.1.0",
"prettier": "2.3.2", "prettier": "2.3.2",
"ts-jest": "^27.0.4", "ts-jest": "^27.0.5",
"typescript": "^4.3.5" "typescript": "^4.3.5"
} }
} }
+4 -3
View File
@@ -22,12 +22,13 @@ export interface Category {
export interface Transformer { export interface Transformer {
pattern: string pattern: string
target: string target?: string
flags?: string flags?: string // the regex flag to use for RegExp
} }
export interface Extractor extends Transformer { export interface Extractor extends Transformer {
on_property: 'title' | 'author' | 'milestone' | 'body' | undefined on_property?: 'title' | 'author' | 'milestone' | 'body' | undefined // retrieve the property to extract the value from
method?: 'replace' | 'match' | undefined // the method to use to extract the value
} }
export interface TagResolver { export interface TagResolver {
+12 -7
View File
@@ -20,12 +20,21 @@ export class ReleaseNotes {
constructor(private octokit: Octokit, private options: ReleaseNotesOptions) {} constructor(private octokit: Octokit, private options: ReleaseNotesOptions) {}
async pull(): Promise<string | null> { async pull(): Promise<string | null> {
const {configuration} = this.options
let mergedPullRequests: PullRequestInfo[] let mergedPullRequests: PullRequestInfo[]
if (!this.options.commitMode) { if (!this.options.commitMode) {
core.startGroup(`🚀 Load pull requests`) core.startGroup(`🚀 Load pull requests`)
mergedPullRequests = await this.getMergedPullRequests(this.octokit) mergedPullRequests = await this.getMergedPullRequests(this.octokit)
// define the included PRs within this release as output
core.setOutput(
'pull_requests',
mergedPullRequests
.map(pr => {
return pr.number
})
.join(',')
)
core.endGroup() core.endGroup()
} else { } else {
core.startGroup(`🚀 Load commit history`) core.startGroup(`🚀 Load commit history`)
@@ -40,11 +49,7 @@ export class ReleaseNotes {
} }
core.startGroup('📦 Build changelog') core.startGroup('📦 Build changelog')
const resultChangelog = buildChangelog( const resultChangelog = buildChangelog(mergedPullRequests, this.options)
mergedPullRequests,
configuration,
this.options
)
core.endGroup() core.endGroup()
return resultChangelog return resultChangelog
} }
+23 -10
View File
@@ -1,7 +1,6 @@
import * as core from '@actions/core' import * as core from '@actions/core'
import { import {
Category, Category,
Configuration,
DefaultConfiguration, DefaultConfiguration,
Extractor, Extractor,
Transformer Transformer
@@ -11,10 +10,10 @@ import {ReleaseNotesOptions} from './releaseNotes'
export function buildChangelog( export function buildChangelog(
prs: PullRequestInfo[], prs: PullRequestInfo[],
config: Configuration,
options: ReleaseNotesOptions options: ReleaseNotesOptions
): string { ): string {
// sort to target order // sort to target order
const config = options.configuration
const sort = config.sort || DefaultConfiguration.sort const sort = config.sort || DefaultConfiguration.sort
const sortAsc = sort.toUpperCase() === 'ASC' const sortAsc = sort.toUpperCase() === 'ASC'
prs = sortPullRequests(prs, sortAsc) prs = sortPullRequests(prs, sortAsc)
@@ -25,7 +24,7 @@ export function buildChangelog(
for (const extractor of labelExtractors) { for (const extractor of labelExtractors) {
if (extractor.pattern != null) { if (extractor.pattern != null) {
for (const pr of prs) { for (const pr of prs) {
let label let onValue
if (extractor.onProperty !== undefined) { if (extractor.onProperty !== undefined) {
let value: string = pr[extractor.onProperty] let value: string = pr[extractor.onProperty]
if (value === undefined) { if (value === undefined) {
@@ -34,16 +33,27 @@ export function buildChangelog(
) )
value = pr['body'] value = pr['body']
} }
label = value.replace(extractor.pattern, extractor.target) onValue = value
} else { } else {
label = pr.body.replace(extractor.pattern, extractor.target) onValue = pr.body
} }
if (extractor.method === 'match') {
const lables = onValue.match(extractor.pattern)
if (lables !== null) {
for (const label of lables) {
pr.labels.add(label.toLocaleLowerCase())
}
}
} else {
const label = onValue.replace(extractor.pattern, extractor.target)
if (label !== '') { if (label !== '') {
pr.labels.add(label.toLocaleLowerCase()) pr.labels.add(label.toLocaleLowerCase())
} }
} }
} }
} }
}
const validatedTransformers = validateTransformers(config.transformers) const validatedTransformers = validateTransformers(config.transformers)
const transformedMap = new Map<PullRequestInfo, string>() const transformedMap = new Map<PullRequestInfo, string>()
@@ -252,8 +262,10 @@ function validateTransformers(
.map(transformer => { .map(transformer => {
try { try {
let onProperty = undefined let onProperty = undefined
let method = undefined
if (transformer.hasOwnProperty('on_property')) { if (transformer.hasOwnProperty('on_property')) {
onProperty = (transformer as Extractor).on_property onProperty = (transformer as Extractor).on_property
method = (transformer as Extractor).method
} }
return { return {
@@ -261,15 +273,15 @@ function validateTransformers(
transformer.pattern.replace('\\\\', '\\'), transformer.pattern.replace('\\\\', '\\'),
transformer.flags ?? 'gu' transformer.flags ?? 'gu'
), ),
target: transformer.target, target: transformer.target || '',
onProperty onProperty,
method
} }
} catch (e) { } catch (e) {
core.warning(`⚠️ Bad replacer regex: ${transformer.pattern}`) core.warning(`⚠️ Bad replacer regex: ${transformer.pattern}`)
return { return {
pattern: null, pattern: null,
target: '', target: ''
onProperty: undefined
} }
} }
}) })
@@ -279,5 +291,6 @@ function validateTransformers(
interface RegexTransformer { interface RegexTransformer {
pattern: RegExp | null pattern: RegExp | null
target: string target: string
onProperty: 'title' | 'author' | 'milestone' | 'body' | undefined onProperty?: 'title' | 'author' | 'milestone' | 'body' | undefined
method?: 'replace' | 'match' | undefined
} }