semantic-release-linear-app 0.6.0 → 0.7.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 +36 -0
- package/dist/lib/success.js +38 -5
- package/dist/types.d.ts +13 -0
- package/package.json +1 -1
- package/src/lib/success.ts +62 -5
- package/src/types.ts +14 -0
package/README.md
CHANGED
|
@@ -46,6 +46,7 @@ ENG-789
|
|
|
46
46
|
| `packageName` | `null` | Package name for monorepos (e.g., `"superdoc"` creates `superdoc-v1.0.0`) |
|
|
47
47
|
| `removeOldLabels` | `true` | Remove previous version labels |
|
|
48
48
|
| `addComment` | `false` | Add release comment to issues |
|
|
49
|
+
| `commentTemplate` | See below | Custom comment template with placeholders |
|
|
49
50
|
| `dryRun` | `false` | Preview without making changes |
|
|
50
51
|
|
|
51
52
|
### Monorepo Support
|
|
@@ -65,6 +66,41 @@ For monorepos with multiple packages, use the `packageName` option to create pac
|
|
|
65
66
|
|
|
66
67
|
This creates labels like `superdoc-v1.2.3` instead of just `v1.2.3`.
|
|
67
68
|
|
|
69
|
+
### Comment Templates
|
|
70
|
+
|
|
71
|
+
When `addComment` is enabled, you can customize the comment format using `commentTemplate`:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"plugins": [
|
|
76
|
+
["semantic-release-linear-app", {
|
|
77
|
+
"teamKeys": ["SD"],
|
|
78
|
+
"packageName": "cli",
|
|
79
|
+
"addComment": true,
|
|
80
|
+
"commentTemplate": "Released in {package} {releaseLink} {channel}"
|
|
81
|
+
}]
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**Available placeholders:**
|
|
87
|
+
|
|
88
|
+
| Placeholder | Example | Description |
|
|
89
|
+
|-------------|---------|-------------|
|
|
90
|
+
| `{version}` | `1.0.0` | Version number |
|
|
91
|
+
| `{channel}` | `(next channel)` | Release channel (empty for stable) |
|
|
92
|
+
| `{package}` | `**cli**` | Bold package name |
|
|
93
|
+
| `{packageName}` | `cli` | Raw package name |
|
|
94
|
+
| `{releaseUrl}` | `https://github.com/.../releases/tag/cli-v1.0.0` | GitHub release URL |
|
|
95
|
+
| `{releaseLink}` | `[1.0.0](https://...)` | Markdown link to release |
|
|
96
|
+
| `{gitTag}` | `cli-v1.0.0` | Git tag |
|
|
97
|
+
|
|
98
|
+
> **Note:** Placeholders are raw values. Add spaces in your template as needed—multiple spaces are automatically collapsed.
|
|
99
|
+
|
|
100
|
+
**Default template:** `Released in {package} v{releaseLink} {channel}`
|
|
101
|
+
|
|
102
|
+
**Example output:** `Released in **cli** v[1.0.0](https://github.com/org/repo/releases/tag/cli-v1.0.0) (next channel)`
|
|
103
|
+
|
|
68
104
|
## How it Works
|
|
69
105
|
|
|
70
106
|
```mermaid
|
package/dist/lib/success.js
CHANGED
|
@@ -43,7 +43,7 @@ export async function success(pluginConfig, context) {
|
|
|
43
43
|
logger.log('No commits found in release, skipping Linear updates');
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
|
-
const { removeOldLabels = true, addComment = false, dryRun = false } = pluginConfig;
|
|
46
|
+
const { removeOldLabels = true, addComment = false, dryRun = false, commentTemplate, } = pluginConfig;
|
|
47
47
|
// Check for GitHub token
|
|
48
48
|
if (!linear.githubToken) {
|
|
49
49
|
logger.log('No GITHUB_TOKEN found, skipping Linear updates');
|
|
@@ -100,10 +100,7 @@ export async function success(pluginConfig, context) {
|
|
|
100
100
|
await client.addLabelToIssue(issue.id, label.id);
|
|
101
101
|
// Add comment if configured
|
|
102
102
|
if (addComment) {
|
|
103
|
-
const
|
|
104
|
-
const channelText = channel ? ` (${channel} channel)` : '';
|
|
105
|
-
const packageText = linear.packageName ? `**${linear.packageName}** ` : '';
|
|
106
|
-
const comment = `${emoji} Released in ${packageText}version ${version}${channelText}`;
|
|
103
|
+
const comment = formatComment(commentTemplate, version, channel, linear.packageName, nextRelease.gitTag, repositoryUrl);
|
|
107
104
|
await client.addComment(issue.id, comment);
|
|
108
105
|
}
|
|
109
106
|
logger.log(`✓ Updated issue ${issueId}`);
|
|
@@ -136,3 +133,39 @@ function getLabelColor(releaseType) {
|
|
|
136
133
|
};
|
|
137
134
|
return colors[releaseType] || '#4752C4'; // Default blue
|
|
138
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Format comment with template placeholders
|
|
138
|
+
*/
|
|
139
|
+
function formatComment(template, version, channel, packageName, gitTag, repositoryUrl) {
|
|
140
|
+
// Raw values - no built-in spacing, template controls layout
|
|
141
|
+
const channelText = channel ? `(${channel} channel)` : '';
|
|
142
|
+
const packageText = packageName ? `**${packageName}**` : '';
|
|
143
|
+
const releaseUrl = buildReleaseUrl(repositoryUrl, gitTag);
|
|
144
|
+
const releaseLink = releaseUrl ? `[${version}](${releaseUrl})` : version;
|
|
145
|
+
// Default template with explicit spacing
|
|
146
|
+
const defaultTemplate = 'Released in {package} v{releaseLink} {channel}';
|
|
147
|
+
const tpl = template || defaultTemplate;
|
|
148
|
+
const result = tpl
|
|
149
|
+
.replace(/{version}/g, version)
|
|
150
|
+
.replace(/{channel}/g, channelText)
|
|
151
|
+
.replace(/{package}/g, packageText)
|
|
152
|
+
.replace(/{packageName}/g, packageName || '')
|
|
153
|
+
.replace(/{releaseUrl}/g, releaseUrl || '')
|
|
154
|
+
.replace(/{releaseLink}/g, releaseLink)
|
|
155
|
+
.replace(/{gitTag}/g, gitTag);
|
|
156
|
+
// Normalize whitespace: collapse multiple spaces, trim
|
|
157
|
+
return result.replace(/\s+/g, ' ').trim();
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Build GitHub release URL from repository URL and git tag
|
|
161
|
+
*/
|
|
162
|
+
function buildReleaseUrl(repositoryUrl, gitTag) {
|
|
163
|
+
if (!repositoryUrl || !gitTag)
|
|
164
|
+
return null;
|
|
165
|
+
// Parse GitHub URL (supports various formats)
|
|
166
|
+
const match = repositoryUrl.match(/github\.com[/:]([^/]+)\/([^/.]+)/);
|
|
167
|
+
if (!match)
|
|
168
|
+
return null;
|
|
169
|
+
const [, owner, repo] = match;
|
|
170
|
+
return `https://github.com/${owner}/${repo}/releases/tag/${gitTag}`;
|
|
171
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -9,6 +9,19 @@ export interface PluginConfig {
|
|
|
9
9
|
removeOldLabels?: boolean;
|
|
10
10
|
/** Add a comment to issues with release info (default: false) */
|
|
11
11
|
addComment?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Custom comment template with placeholders (default: "Released in {package} v{releaseLink} {channel}")
|
|
14
|
+
* Placeholders are raw values - add spaces as needed (multiple spaces are collapsed).
|
|
15
|
+
* Available placeholders:
|
|
16
|
+
* - {version} - Release version (e.g., "1.0.0")
|
|
17
|
+
* - {channel} - Release channel (e.g., "(next channel)" or "")
|
|
18
|
+
* - {package} - Package name bold (e.g., "**cli**" or "")
|
|
19
|
+
* - {packageName} - Raw package name (e.g., "cli" or "")
|
|
20
|
+
* - {releaseUrl} - GitHub release URL
|
|
21
|
+
* - {releaseLink} - Markdown link [version](url)
|
|
22
|
+
* - {gitTag} - Git tag (e.g., "cli-v1.0.0")
|
|
23
|
+
*/
|
|
24
|
+
commentTemplate?: string;
|
|
12
25
|
/** Preview changes without updating Linear (default: false) */
|
|
13
26
|
dryRun?: boolean;
|
|
14
27
|
/** Package name for label prefix in monorepos (e.g., "superdoc" creates "superdoc-v1.0.0") */
|
package/package.json
CHANGED
package/src/lib/success.ts
CHANGED
|
@@ -60,7 +60,12 @@ export async function success(pluginConfig: PluginConfig, context: SuccessContex
|
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
const {
|
|
63
|
+
const {
|
|
64
|
+
removeOldLabels = true,
|
|
65
|
+
addComment = false,
|
|
66
|
+
dryRun = false,
|
|
67
|
+
commentTemplate,
|
|
68
|
+
} = pluginConfig;
|
|
64
69
|
|
|
65
70
|
// Check for GitHub token
|
|
66
71
|
if (!linear.githubToken) {
|
|
@@ -140,10 +145,14 @@ export async function success(pluginConfig: PluginConfig, context: SuccessContex
|
|
|
140
145
|
|
|
141
146
|
// Add comment if configured
|
|
142
147
|
if (addComment) {
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
148
|
+
const comment = formatComment(
|
|
149
|
+
commentTemplate,
|
|
150
|
+
version,
|
|
151
|
+
channel,
|
|
152
|
+
linear.packageName,
|
|
153
|
+
nextRelease.gitTag,
|
|
154
|
+
repositoryUrl,
|
|
155
|
+
);
|
|
147
156
|
await client.addComment(issue.id, comment);
|
|
148
157
|
}
|
|
149
158
|
|
|
@@ -187,3 +196,51 @@ function getLabelColor(releaseType: ReleaseType): string {
|
|
|
187
196
|
|
|
188
197
|
return colors[releaseType] || '#4752C4'; // Default blue
|
|
189
198
|
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Format comment with template placeholders
|
|
202
|
+
*/
|
|
203
|
+
function formatComment(
|
|
204
|
+
template: string | undefined,
|
|
205
|
+
version: string,
|
|
206
|
+
channel: string | undefined,
|
|
207
|
+
packageName: string | null,
|
|
208
|
+
gitTag: string,
|
|
209
|
+
repositoryUrl: string | undefined,
|
|
210
|
+
): string {
|
|
211
|
+
// Raw values - no built-in spacing, template controls layout
|
|
212
|
+
const channelText = channel ? `(${channel} channel)` : '';
|
|
213
|
+
const packageText = packageName ? `**${packageName}**` : '';
|
|
214
|
+
const releaseUrl = buildReleaseUrl(repositoryUrl, gitTag);
|
|
215
|
+
const releaseLink = releaseUrl ? `[${version}](${releaseUrl})` : version;
|
|
216
|
+
|
|
217
|
+
// Default template with explicit spacing
|
|
218
|
+
const defaultTemplate = 'Released in {package} v{releaseLink} {channel}';
|
|
219
|
+
const tpl = template || defaultTemplate;
|
|
220
|
+
|
|
221
|
+
const result = tpl
|
|
222
|
+
.replace(/{version}/g, version)
|
|
223
|
+
.replace(/{channel}/g, channelText)
|
|
224
|
+
.replace(/{package}/g, packageText)
|
|
225
|
+
.replace(/{packageName}/g, packageName || '')
|
|
226
|
+
.replace(/{releaseUrl}/g, releaseUrl || '')
|
|
227
|
+
.replace(/{releaseLink}/g, releaseLink)
|
|
228
|
+
.replace(/{gitTag}/g, gitTag);
|
|
229
|
+
|
|
230
|
+
// Normalize whitespace: collapse multiple spaces, trim
|
|
231
|
+
return result.replace(/\s+/g, ' ').trim();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Build GitHub release URL from repository URL and git tag
|
|
236
|
+
*/
|
|
237
|
+
function buildReleaseUrl(repositoryUrl: string | undefined, gitTag: string): string | null {
|
|
238
|
+
if (!repositoryUrl || !gitTag) return null;
|
|
239
|
+
|
|
240
|
+
// Parse GitHub URL (supports various formats)
|
|
241
|
+
const match = repositoryUrl.match(/github\.com[/:]([^/]+)\/([^/.]+)/);
|
|
242
|
+
if (!match) return null;
|
|
243
|
+
|
|
244
|
+
const [, owner, repo] = match;
|
|
245
|
+
return `https://github.com/${owner}/${repo}/releases/tag/${gitTag}`;
|
|
246
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -14,6 +14,20 @@ export interface PluginConfig {
|
|
|
14
14
|
/** Add a comment to issues with release info (default: false) */
|
|
15
15
|
addComment?: boolean;
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Custom comment template with placeholders (default: "Released in {package} v{releaseLink} {channel}")
|
|
19
|
+
* Placeholders are raw values - add spaces as needed (multiple spaces are collapsed).
|
|
20
|
+
* Available placeholders:
|
|
21
|
+
* - {version} - Release version (e.g., "1.0.0")
|
|
22
|
+
* - {channel} - Release channel (e.g., "(next channel)" or "")
|
|
23
|
+
* - {package} - Package name bold (e.g., "**cli**" or "")
|
|
24
|
+
* - {packageName} - Raw package name (e.g., "cli" or "")
|
|
25
|
+
* - {releaseUrl} - GitHub release URL
|
|
26
|
+
* - {releaseLink} - Markdown link [version](url)
|
|
27
|
+
* - {gitTag} - Git tag (e.g., "cli-v1.0.0")
|
|
28
|
+
*/
|
|
29
|
+
commentTemplate?: string;
|
|
30
|
+
|
|
17
31
|
/** Preview changes without updating Linear (default: false) */
|
|
18
32
|
dryRun?: boolean;
|
|
19
33
|
|