release-it-gitea 1.4.1 → 1.6.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.en.md +10 -8
- package/README.md +10 -8
- package/lib/global.d.d.ts +4 -3
- package/lib/index.d.ts +7 -0
- package/lib/index.js +31 -8
- package/package.json +1 -1
package/README.en.md
CHANGED
|
@@ -92,7 +92,7 @@ npx release-it
|
|
|
92
92
|
"README.md",
|
|
93
93
|
{
|
|
94
94
|
"path": "dist/**/*",
|
|
95
|
-
"name": "distribution
|
|
95
|
+
"name": "distribution-file.zip",
|
|
96
96
|
"type": "zip",
|
|
97
97
|
"label": "Distribution Files"
|
|
98
98
|
}
|
|
@@ -138,7 +138,7 @@ Use object format for more detailed configuration:
|
|
|
138
138
|
},
|
|
139
139
|
{
|
|
140
140
|
"path": "src",
|
|
141
|
-
"name": "source-code
|
|
141
|
+
"name": "source-code-file.zip",
|
|
142
142
|
"type": "zip",
|
|
143
143
|
"label": "Source Code"
|
|
144
144
|
}
|
|
@@ -177,7 +177,7 @@ Use object format for more detailed configuration:
|
|
|
177
177
|
"assets": [
|
|
178
178
|
{
|
|
179
179
|
"path": "src/**/*",
|
|
180
|
-
"name": "source-
|
|
180
|
+
"name": "source-vfile.zip",
|
|
181
181
|
"type": "zip",
|
|
182
182
|
"label": "Source Code"
|
|
183
183
|
}
|
|
@@ -213,13 +213,13 @@ Use object format for more detailed configuration:
|
|
|
213
213
|
"assets": [
|
|
214
214
|
{
|
|
215
215
|
"path": "dist/prod/**/*",
|
|
216
|
-
"name": "production-build
|
|
216
|
+
"name": "production-build-file.zip",
|
|
217
217
|
"type": "zip",
|
|
218
218
|
"label": "Production Build"
|
|
219
219
|
},
|
|
220
220
|
{
|
|
221
221
|
"path": "dist/dev/**/*",
|
|
222
|
-
"name": "development-build
|
|
222
|
+
"name": "development-build-file.zip",
|
|
223
223
|
"type": "zip",
|
|
224
224
|
"label": "Development Build"
|
|
225
225
|
}
|
|
@@ -249,7 +249,7 @@ export MY_GITEA_TOKEN=your_gitea_api_token
|
|
|
249
249
|
|
|
250
250
|
## Template Variables
|
|
251
251
|
|
|
252
|
-
The following variables can be used in `releaseTitle
|
|
252
|
+
The following variables can be used in `releaseTitle` and `releaseNotes`:
|
|
253
253
|
|
|
254
254
|
| Variable | Description | Example |
|
|
255
255
|
| -------------------- | ---------------- | -------------------- |
|
|
@@ -270,14 +270,16 @@ The following variables can be used in `releaseTitle`, `releaseNotes`, and asset
|
|
|
270
270
|
"assets": [
|
|
271
271
|
{
|
|
272
272
|
"path": "dist/**/*",
|
|
273
|
-
"name": "
|
|
273
|
+
"name": "distribution-files.zip",
|
|
274
274
|
"type": "zip",
|
|
275
|
-
"label": "
|
|
275
|
+
"label": "Distribution Files"
|
|
276
276
|
}
|
|
277
277
|
]
|
|
278
278
|
}
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
+
> **Note**: The `name` and `label` fields in asset configuration do not support template variable substitution and require static strings.
|
|
282
|
+
|
|
281
283
|
## Troubleshooting
|
|
282
284
|
|
|
283
285
|
### Common Issues and Solutions
|
package/README.md
CHANGED
|
@@ -92,7 +92,7 @@ npx release-it
|
|
|
92
92
|
"README.md",
|
|
93
93
|
{
|
|
94
94
|
"path": "dist/**/*",
|
|
95
|
-
"name": "distribution
|
|
95
|
+
"name": "distribution-file.zip",
|
|
96
96
|
"type": "zip",
|
|
97
97
|
"label": "Distribution Files"
|
|
98
98
|
}
|
|
@@ -138,7 +138,7 @@ npx release-it
|
|
|
138
138
|
},
|
|
139
139
|
{
|
|
140
140
|
"path": "src",
|
|
141
|
-
"name": "source-code
|
|
141
|
+
"name": "source-code-file.zip",
|
|
142
142
|
"type": "zip",
|
|
143
143
|
"label": "Source Code"
|
|
144
144
|
}
|
|
@@ -177,7 +177,7 @@ npx release-it
|
|
|
177
177
|
"assets": [
|
|
178
178
|
{
|
|
179
179
|
"path": "src/**/*",
|
|
180
|
-
"name": "source-
|
|
180
|
+
"name": "source-vfile.zip",
|
|
181
181
|
"type": "zip",
|
|
182
182
|
"label": "Source Code"
|
|
183
183
|
}
|
|
@@ -213,13 +213,13 @@ npx release-it
|
|
|
213
213
|
"assets": [
|
|
214
214
|
{
|
|
215
215
|
"path": "dist/prod/**/*",
|
|
216
|
-
"name": "production-build
|
|
216
|
+
"name": "production-build-file.zip",
|
|
217
217
|
"type": "zip",
|
|
218
218
|
"label": "Production Build"
|
|
219
219
|
},
|
|
220
220
|
{
|
|
221
221
|
"path": "dist/dev/**/*",
|
|
222
|
-
"name": "development-build
|
|
222
|
+
"name": "development-build-file.zip",
|
|
223
223
|
"type": "zip",
|
|
224
224
|
"label": "Development Build"
|
|
225
225
|
}
|
|
@@ -249,7 +249,7 @@ export MY_GITEA_TOKEN=your_gitea_api_token
|
|
|
249
249
|
|
|
250
250
|
## 模板变量
|
|
251
251
|
|
|
252
|
-
在 `releaseTitle
|
|
252
|
+
在 `releaseTitle` 和 `releaseNotes` 中可以使用以下变量:
|
|
253
253
|
|
|
254
254
|
| 变量 | 描述 | 示例 |
|
|
255
255
|
| -------------------- | ------------ | -------------------- |
|
|
@@ -270,14 +270,16 @@ export MY_GITEA_TOKEN=your_gitea_api_token
|
|
|
270
270
|
"assets": [
|
|
271
271
|
{
|
|
272
272
|
"path": "dist/**/*",
|
|
273
|
-
"name": "
|
|
273
|
+
"name": "distribution-files.zip",
|
|
274
274
|
"type": "zip",
|
|
275
|
-
"label": "
|
|
275
|
+
"label": "Distribution Files"
|
|
276
276
|
}
|
|
277
277
|
]
|
|
278
278
|
}
|
|
279
279
|
```
|
|
280
280
|
|
|
281
|
+
> **注意**: 附件配置中的 `name` 和 `label` 字段不支持模板变量替换,需要使用静态字符串。
|
|
282
|
+
|
|
281
283
|
## 故障排除
|
|
282
284
|
|
|
283
285
|
### 常见问题及解决方案
|
package/lib/global.d.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare module "release-it" {
|
|
2
2
|
interface Config {
|
|
3
|
-
getContext(
|
|
3
|
+
getContext(): Context;
|
|
4
|
+
getContext(path: string): unknown;
|
|
4
5
|
setContext(path: string, value: unknown): void;
|
|
5
6
|
}
|
|
6
7
|
|
|
@@ -83,10 +84,10 @@ interface GiteaConfig {
|
|
|
83
84
|
release?: boolean;
|
|
84
85
|
|
|
85
86
|
/** 发布标题的模板字符串,支持变量替换 */
|
|
86
|
-
releaseTitle?: string;
|
|
87
|
+
releaseTitle?: ((context: Context) => string) | string;
|
|
87
88
|
|
|
88
89
|
/** 发布说明的模板字符串,支持变量替换 */
|
|
89
|
-
releaseNotes?: string;
|
|
90
|
+
releaseNotes?: ((context: Context) => string) | string;
|
|
90
91
|
|
|
91
92
|
/** 是否标记为预发布版本 */
|
|
92
93
|
prerelease?: boolean;
|
package/lib/index.d.ts
CHANGED
|
@@ -98,6 +98,13 @@ declare class GiteaPlugin extends Plugin {
|
|
|
98
98
|
* @param config 附件配置
|
|
99
99
|
*/
|
|
100
100
|
private processAsset;
|
|
101
|
+
/**
|
|
102
|
+
* 处理单个附件配置
|
|
103
|
+
* @param releaseId 发布 ID
|
|
104
|
+
* @param config 附件配置
|
|
105
|
+
*/
|
|
106
|
+
private getReleaseNotes;
|
|
107
|
+
private getReleaseTitle;
|
|
101
108
|
/**
|
|
102
109
|
* 执行发布操作,创建或更新 Gitea 发布.
|
|
103
110
|
* @throws 当发布创建失败时抛出错误
|
package/lib/index.js
CHANGED
|
@@ -228,7 +228,7 @@ class GiteaPlugin extends Plugin {
|
|
|
228
228
|
for (const file of files) {
|
|
229
229
|
const stats = statSync(file);
|
|
230
230
|
if (stats.isFile()) {
|
|
231
|
-
const relativePath = basePath ?
|
|
231
|
+
const relativePath = basePath ? join(basePath, file.split(basePath)[1]) : basename(file);
|
|
232
232
|
archive.file(file, { name: relativePath });
|
|
233
233
|
}
|
|
234
234
|
}
|
|
@@ -324,7 +324,11 @@ class GiteaPlugin extends Plugin {
|
|
|
324
324
|
mkdirSync(dirname(tempZipPath), { recursive: true });
|
|
325
325
|
} catch (error) {
|
|
326
326
|
}
|
|
327
|
-
await this.createZipArchive(
|
|
327
|
+
await this.createZipArchive(
|
|
328
|
+
files,
|
|
329
|
+
tempZipPath,
|
|
330
|
+
dirname(config.path).replace(/\*/g, "")
|
|
331
|
+
);
|
|
328
332
|
await this.uploadAsset(releaseId, tempZipPath, zipName, config.label);
|
|
329
333
|
const { unlinkSync } = await import("fs");
|
|
330
334
|
try {
|
|
@@ -339,6 +343,29 @@ class GiteaPlugin extends Plugin {
|
|
|
339
343
|
}
|
|
340
344
|
}
|
|
341
345
|
}
|
|
346
|
+
/**
|
|
347
|
+
* 处理单个附件配置
|
|
348
|
+
* @param releaseId 发布 ID
|
|
349
|
+
* @param config 附件配置
|
|
350
|
+
*/
|
|
351
|
+
getReleaseNotes() {
|
|
352
|
+
const releaseNotes = this.giteaConfig.releaseNotes;
|
|
353
|
+
if (typeof releaseNotes === "string") {
|
|
354
|
+
return this.interpolate(releaseNotes);
|
|
355
|
+
} else if (typeof releaseNotes === "function") {
|
|
356
|
+
return releaseNotes(this.config.getContext());
|
|
357
|
+
}
|
|
358
|
+
return this.config.getContext("changelog");
|
|
359
|
+
}
|
|
360
|
+
getReleaseTitle() {
|
|
361
|
+
const releaseTitle = this.giteaConfig.releaseTitle;
|
|
362
|
+
if (typeof releaseTitle === "string") {
|
|
363
|
+
return this.interpolate(releaseTitle);
|
|
364
|
+
} else if (typeof releaseTitle === "function") {
|
|
365
|
+
return releaseTitle(this.config.getContext());
|
|
366
|
+
}
|
|
367
|
+
return this.config.getContext("version");
|
|
368
|
+
}
|
|
342
369
|
/**
|
|
343
370
|
* 执行发布操作,创建或更新 Gitea 发布.
|
|
344
371
|
* @throws 当发布创建失败时抛出错误
|
|
@@ -349,12 +376,8 @@ class GiteaPlugin extends Plugin {
|
|
|
349
376
|
return;
|
|
350
377
|
}
|
|
351
378
|
const tagName = this.config.getContext("tagName");
|
|
352
|
-
const releaseTitle = this.
|
|
353
|
-
|
|
354
|
-
);
|
|
355
|
-
const releaseNotes = this.interpolate(
|
|
356
|
-
this.giteaConfig.releaseNotes ?? "${changelog}"
|
|
357
|
-
);
|
|
379
|
+
const releaseTitle = this.getReleaseTitle();
|
|
380
|
+
const releaseNotes = this.getReleaseNotes();
|
|
358
381
|
this.log.info(`\u51C6\u5907\u521B\u5EFA Gitea \u53D1\u5E03: ${releaseTitle}`);
|
|
359
382
|
const releaseData = {
|
|
360
383
|
body: releaseNotes,
|