@ondrejbelza/semantic-release-jira 1.7.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/consts.d.ts +1 -1
- package/dist/consts.js +10 -1
- package/dist/success.js +40 -13
- package/dist/types.d.ts +9 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,11 +63,11 @@ interface Config {
|
|
|
63
63
|
jiraHost: string;
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
|
-
* A
|
|
66
|
+
* A list of prefixes to match when looking for tickets in commits.
|
|
67
67
|
*
|
|
68
|
-
* ie. 'TEST' would match `TEST-123` and `TEST-456`
|
|
68
|
+
* ie. ['TEST'] would match `TEST-123` and `TEST-456`
|
|
69
69
|
*/
|
|
70
|
-
|
|
70
|
+
ticketPrefixes: string[];
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
73
|
* The id or key for the project releases will be created in
|
package/dist/consts.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const DEFAULT_VERSION_TEMPLATE = "v${version}";
|
|
2
|
-
export declare const DEFAULT_RELEASE_DESCRIPTION_TEMPLATE = "# Release notes - {{version}}\n\n## Issues
|
|
2
|
+
export declare const DEFAULT_RELEASE_DESCRIPTION_TEMPLATE = "# Release notes - {{version}}\n\n\n## Issues:\n{{#each issues}}\n - [{{type}}] [{{ key }}]({{ link }}) {{ title }}\n - Short description: {{ description }}\n - Assigned to: {{ assignee }}\n\n{{/each}}\n\n\n## Commits not relevant to any Issue:\n{{#each commits}}\n - {{ message }}\n - Committed by: {{ author }}\n\n{{/each}}\n\nRelease notes were automatically generated";
|
package/dist/consts.js
CHANGED
|
@@ -4,7 +4,8 @@ exports.DEFAULT_RELEASE_DESCRIPTION_TEMPLATE = exports.DEFAULT_VERSION_TEMPLATE
|
|
|
4
4
|
exports.DEFAULT_VERSION_TEMPLATE = "v${version}";
|
|
5
5
|
exports.DEFAULT_RELEASE_DESCRIPTION_TEMPLATE = `# Release notes - {{version}}
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
## Issues:
|
|
8
9
|
{{#each issues}}
|
|
9
10
|
- [{{type}}] [{{ key }}]({{ link }}) {{ title }}
|
|
10
11
|
- Short description: {{ description }}
|
|
@@ -12,4 +13,12 @@ exports.DEFAULT_RELEASE_DESCRIPTION_TEMPLATE = `# Release notes - {{version}}
|
|
|
12
13
|
|
|
13
14
|
{{/each}}
|
|
14
15
|
|
|
16
|
+
|
|
17
|
+
## Commits not relevant to any Issue:
|
|
18
|
+
{{#each commits}}
|
|
19
|
+
- {{ message }}
|
|
20
|
+
- Committed by: {{ author }}
|
|
21
|
+
|
|
22
|
+
{{/each}}
|
|
23
|
+
|
|
15
24
|
Release notes were automatically generated`;
|
package/dist/success.js
CHANGED
|
@@ -58,20 +58,46 @@ async function getIssueMetadata(c, issueKey, jiraHost, logger) {
|
|
|
58
58
|
type: issue.fields.issuetype?.name || "unknown",
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
async function
|
|
61
|
+
async function getContributions(c, ticketPrefixes, jiraHost, commits, logger) {
|
|
62
62
|
const tickets = new Set();
|
|
63
|
-
const
|
|
63
|
+
const releaseCommits = new Set();
|
|
64
|
+
const patterns = [];
|
|
65
|
+
for (const prefix of ticketPrefixes) {
|
|
66
|
+
const pattern = new RegExp(`\\b${(0, utils_1.escapeRegExp)(prefix)}-(\\d+)\\b`, "giu");
|
|
67
|
+
patterns.push(pattern);
|
|
68
|
+
}
|
|
64
69
|
for (const commit of commits) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
var found = false;
|
|
71
|
+
for (const pattern of patterns) {
|
|
72
|
+
const matches = commit.message.match(pattern);
|
|
73
|
+
if (matches) {
|
|
74
|
+
found = true;
|
|
75
|
+
for (const match of matches) {
|
|
76
|
+
logger.info(`Found matching ticket it commit ${match} in ${commit.commit.short}`);
|
|
77
|
+
const issue = await getIssueMetadata(c, match, jiraHost, logger);
|
|
78
|
+
tickets.add(issue);
|
|
79
|
+
}
|
|
71
80
|
}
|
|
72
81
|
}
|
|
82
|
+
if (!found) {
|
|
83
|
+
releaseCommits.add({
|
|
84
|
+
author: commit.author.name,
|
|
85
|
+
message: commit.message,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
73
88
|
}
|
|
74
|
-
return
|
|
89
|
+
return {
|
|
90
|
+
commits: [...releaseCommits],
|
|
91
|
+
issues: [...tickets].sort((a, b) => {
|
|
92
|
+
if (a.type > b.type) {
|
|
93
|
+
return 1;
|
|
94
|
+
}
|
|
95
|
+
if (a.type < b.type) {
|
|
96
|
+
return -1;
|
|
97
|
+
}
|
|
98
|
+
return 0;
|
|
99
|
+
}),
|
|
100
|
+
};
|
|
75
101
|
}
|
|
76
102
|
async function findOrCreateVersion(c, projectIdOrKey, newVersionName, newVersionDescription, logger) {
|
|
77
103
|
const versions = await c.projectVersions.getProjectVersions({
|
|
@@ -145,15 +171,16 @@ async function editIssueFixVersions(c, ticket, versionId, logger) {
|
|
|
145
171
|
}
|
|
146
172
|
async function success(config, context) {
|
|
147
173
|
const { env, logger, commits, nextRelease } = context;
|
|
148
|
-
const { jiraHost, project: projectKey,
|
|
174
|
+
const { jiraHost, project: projectKey, ticketPrefixes, versionTemplate: definedVersionTemplate, } = config;
|
|
149
175
|
const c = (0, jira_client_1.CreateJiraClient)(logger, jiraHost, env.JIRA_EMAIL, env.JIRA_TOKEN);
|
|
150
|
-
const
|
|
176
|
+
const contributions = await getContributions(c, ticketPrefixes, jiraHost, commits, logger);
|
|
151
177
|
const versionTemplate = _.template(definedVersionTemplate || consts_1.DEFAULT_VERSION_TEMPLATE);
|
|
152
178
|
const descriptionTemplate = handlebars_1.default.compile(consts_1.DEFAULT_RELEASE_DESCRIPTION_TEMPLATE);
|
|
153
179
|
const newVersionName = versionTemplate({ version: nextRelease.version });
|
|
154
180
|
const newVersionDescription = descriptionTemplate({
|
|
155
181
|
version: newVersionName,
|
|
156
|
-
issues:
|
|
182
|
+
issues: contributions.issues,
|
|
183
|
+
commits: contributions.commits,
|
|
157
184
|
});
|
|
158
185
|
logger.info(`Using jira release '${newVersionName}'`);
|
|
159
186
|
logger.info(`using jira description '${consts_1.DEFAULT_RELEASE_DESCRIPTION_TEMPLATE}'`);
|
|
@@ -165,7 +192,7 @@ async function success(config, context) {
|
|
|
165
192
|
const version = await findOrCreateVersion(c, project.id, newVersionName, newVersionDescription, logger);
|
|
166
193
|
const concurrentLimit = (0, p_limit_1.default)(10);
|
|
167
194
|
const edits = [];
|
|
168
|
-
for (const ticket of
|
|
195
|
+
for (const ticket of contributions.issues) {
|
|
169
196
|
edits.push(concurrentLimit(() => editIssueFixVersions(c, ticket, version.id || "", logger)));
|
|
170
197
|
}
|
|
171
198
|
await Promise.all(edits);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export interface PluginConfig {
|
|
2
2
|
jiraHost: string;
|
|
3
3
|
project: string;
|
|
4
|
-
|
|
4
|
+
ticketPrefixes: string[];
|
|
5
5
|
versionTemplate: string;
|
|
6
6
|
}
|
|
7
|
+
export interface ReleaseCommit {
|
|
8
|
+
author: string;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
7
11
|
export interface JiraIssue {
|
|
8
12
|
title: string;
|
|
9
13
|
key: string;
|
|
@@ -12,3 +16,7 @@ export interface JiraIssue {
|
|
|
12
16
|
description: string;
|
|
13
17
|
link: string;
|
|
14
18
|
}
|
|
19
|
+
export interface ReleaseContributions {
|
|
20
|
+
commits: ReleaseCommit[];
|
|
21
|
+
issues: JiraIssue[];
|
|
22
|
+
}
|
package/package.json
CHANGED