release-it-gitea 1.4.0 → 1.5.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 ADDED
@@ -0,0 +1,402 @@
1
+ # Release It! Gitea Plugin
2
+
3
+ English | [中文](README.md)
4
+
5
+ A [release-it](https://github.com/release-it/release-it) plugin for Gitea that supports automatic Gitea release creation and asset uploads.
6
+
7
+ ## Features
8
+
9
+ - ✅ Automatically create and update Gitea releases
10
+ - ✅ Support template variable substitution (version, changelog, etc.)
11
+ - ✅ Support draft and prerelease versions
12
+ - ✅ **Support file and folder asset uploads**
13
+ - ✅ **Support automatic folder packaging to ZIP**
14
+ - ✅ **Support wildcard file matching**
15
+
16
+ ## Quick Start
17
+
18
+ ### 1. Install Plugin
19
+
20
+ ```bash
21
+ npm install --save-dev release-it-gitea
22
+ # or
23
+ pnpm add -D release-it-gitea
24
+ # or
25
+ yarn add -D release-it-gitea
26
+ ```
27
+
28
+ ### 2. Set Environment Variables
29
+
30
+ ```bash
31
+ export GITEA_TOKEN="your-gitea-api-token"
32
+ ```
33
+
34
+ ### 3. Basic Configuration
35
+
36
+ Add to `.release-it.json`:
37
+
38
+ ```json
39
+ {
40
+ "plugins": {
41
+ "release-it-gitea": {
42
+ "host": "https://gitea.example.com",
43
+ "owner": "your-username",
44
+ "repository": "your-repo"
45
+ }
46
+ }
47
+ }
48
+ ```
49
+
50
+ ### 4. Run Release
51
+
52
+ ```bash
53
+ npx release-it
54
+ ```
55
+
56
+ ## Detailed Configuration
57
+
58
+ ### Basic Configuration Options
59
+
60
+ | Option | Type | Default | Description |
61
+ | -------------- | ------- | --------------------------- | ------------------------------ |
62
+ | `host` | string | Current repository host | Gitea server URL |
63
+ | `owner` | string | Auto-detect from git remote | Repository owner |
64
+ | `repository` | string | Auto-detect from git remote | Repository name |
65
+ | `release` | boolean | `true` | Whether to create release |
66
+ | `releaseTitle` | string | `"v${version}"` | Release title template |
67
+ | `releaseNotes` | string | `"${changelog}"` | Release notes template |
68
+ | `prerelease` | boolean | `false` | Whether it's a prerelease |
69
+ | `draft` | boolean | `false` | Whether it's a draft |
70
+ | `tokenRef` | string | `"GITEA_TOKEN"` | API token environment variable |
71
+ | `timeout` | number | `30000` | Request timeout (milliseconds) |
72
+ | `assets` | array | `[]` | Additional asset files |
73
+
74
+ ### Complete Configuration Example
75
+
76
+ ```json
77
+ {
78
+ "plugins": {
79
+ "release-it-gitea": {
80
+ "host": "https://gitea.example.com",
81
+ "owner": "your-username",
82
+ "repository": "your-repo",
83
+ "release": true,
84
+ "releaseTitle": "Release ${version}",
85
+ "releaseNotes": "## What's New\n\n${changelog}",
86
+ "prerelease": false,
87
+ "draft": false,
88
+ "tokenRef": "GITEA_TOKEN",
89
+ "timeout": 30000,
90
+ "assets": [
91
+ "dist/app.js",
92
+ "README.md",
93
+ {
94
+ "path": "dist/**/*",
95
+ "name": "distribution-${version}.zip",
96
+ "type": "zip",
97
+ "label": "Distribution Files"
98
+ }
99
+ ]
100
+ }
101
+ }
102
+ }
103
+ ```
104
+
105
+ ## Asset Upload Features
106
+
107
+ ### Basic Usage
108
+
109
+ Supports multiple asset configuration formats:
110
+
111
+ ```json
112
+ {
113
+ "assets": [
114
+ "dist/app.js", // Single file
115
+ "dist/**/*.min.js", // Wildcard matching
116
+ "*.md" // Multiple matching files
117
+ ]
118
+ }
119
+ ```
120
+
121
+ ### Advanced Configuration
122
+
123
+ Use object format for more detailed configuration:
124
+
125
+ ```json
126
+ {
127
+ "assets": [
128
+ {
129
+ "path": "dist/**/*",
130
+ "name": "distribution-files.zip",
131
+ "type": "zip",
132
+ "label": "Distribution Files"
133
+ },
134
+ {
135
+ "path": "docs/*.md",
136
+ "type": "file",
137
+ "label": "Documentation"
138
+ },
139
+ {
140
+ "path": "src",
141
+ "name": "source-code-${version}.zip",
142
+ "type": "zip",
143
+ "label": "Source Code"
144
+ }
145
+ ]
146
+ }
147
+ ```
148
+
149
+ ### Asset Configuration Parameters
150
+
151
+ | Property | Type | Required | Description |
152
+ | -------- | --------------- | -------- | -------------------------------------------------------- |
153
+ | `path` | string | ✅ | File or folder path, supports wildcards |
154
+ | `name` | string | ❌ | Upload filename, uses original filename if not specified |
155
+ | `type` | 'file' \| 'zip' | ❌ | File type, defaults to 'file' |
156
+ | `label` | string | ❌ | File label for identifying file purpose |
157
+
158
+ ### File Type Description
159
+
160
+ - **`file`**: Directly upload matched files
161
+ - **`zip`**: Package matched files into ZIP before upload
162
+
163
+ ## Usage Examples
164
+
165
+ ### Example 1: Upload Build Artifacts
166
+
167
+ ```json
168
+ {
169
+ "assets": ["dist/bundle.js", "dist/bundle.css", "dist/assets/**/*"]
170
+ }
171
+ ```
172
+
173
+ ### Example 2: Package Source Code Release
174
+
175
+ ```json
176
+ {
177
+ "assets": [
178
+ {
179
+ "path": "src/**/*",
180
+ "name": "source-v${version}.zip",
181
+ "type": "zip",
182
+ "label": "Source Code"
183
+ }
184
+ ]
185
+ }
186
+ ```
187
+
188
+ ### Example 3: Multiple File Type Combination
189
+
190
+ ```json
191
+ {
192
+ "assets": [
193
+ "README.md",
194
+ "CHANGELOG.md",
195
+ {
196
+ "path": "dist",
197
+ "name": "build-output.zip",
198
+ "type": "zip"
199
+ },
200
+ {
201
+ "path": "docs/**/*.pdf",
202
+ "type": "file",
203
+ "label": "Documentation"
204
+ }
205
+ ]
206
+ }
207
+ ```
208
+
209
+ ### Example 4: Different Environment Configurations
210
+
211
+ ```json
212
+ {
213
+ "assets": [
214
+ {
215
+ "path": "dist/prod/**/*",
216
+ "name": "production-build-${version}.zip",
217
+ "type": "zip",
218
+ "label": "Production Build"
219
+ },
220
+ {
221
+ "path": "dist/dev/**/*",
222
+ "name": "development-build-${version}.zip",
223
+ "type": "zip",
224
+ "label": "Development Build"
225
+ }
226
+ ]
227
+ }
228
+ ```
229
+
230
+ ## Environment Variable Configuration
231
+
232
+ ### Default Token Configuration
233
+
234
+ ```bash
235
+ export GITEA_TOKEN=your_gitea_api_token
236
+ ```
237
+
238
+ ### Custom Token Configuration
239
+
240
+ ```json
241
+ {
242
+ "tokenRef": "MY_GITEA_TOKEN"
243
+ }
244
+ ```
245
+
246
+ ```bash
247
+ export MY_GITEA_TOKEN=your_gitea_api_token
248
+ ```
249
+
250
+ ## Template Variables
251
+
252
+ The following variables can be used in `releaseTitle`, `releaseNotes`, and asset `name`:
253
+
254
+ | Variable | Description | Example |
255
+ | -------------------- | ---------------- | -------------------- |
256
+ | `${version}` | Current version | `1.2.3` |
257
+ | `${latestVersion}` | Previous version | `1.2.2` |
258
+ | `${changelog}` | Changelog | `- Fixed some bug` |
259
+ | `${name}` | Project name | `my-awesome-project` |
260
+ | `${repo.owner}` | Repository owner | `username` |
261
+ | `${repo.repository}` | Repository name | `my-repo` |
262
+ | `${branchName}` | Branch name | `main` |
263
+
264
+ ### Template Usage Example
265
+
266
+ ```json
267
+ {
268
+ "releaseTitle": "🚀 ${name} v${version}",
269
+ "releaseNotes": "## 📋 What's New\n\n${changelog}\n\n## 📦 Download\n\nPlease download the appropriate file for your platform",
270
+ "assets": [
271
+ {
272
+ "path": "dist/**/*",
273
+ "name": "${name}-${version}-dist.zip",
274
+ "type": "zip",
275
+ "label": "${name} v${version} Distribution"
276
+ }
277
+ ]
278
+ }
279
+ ```
280
+
281
+ ## Troubleshooting
282
+
283
+ ### Common Issues and Solutions
284
+
285
+ #### 1. Asset Upload Failed
286
+
287
+ **Symptoms:**
288
+
289
+ - Error occurs during asset upload
290
+ - File not found
291
+
292
+ **Solutions:**
293
+
294
+ - Check if file paths are correct
295
+ - Ensure files exist and are readable
296
+ - Check if Gitea API Token has asset upload permissions
297
+
298
+ #### 2. ZIP File Creation Failed
299
+
300
+ **Symptoms:**
301
+
302
+ - Error occurs during ZIP file creation
303
+ - Insufficient disk space error
304
+
305
+ **Solutions:**
306
+
307
+ - Ensure sufficient disk space is available
308
+ - Check temporary directory permissions
309
+ - Verify that files to be packaged exist
310
+
311
+ #### 3. Wildcard Matching No Files
312
+
313
+ **Symptoms:**
314
+
315
+ - Wildcard pattern matches no files
316
+ - Asset list is empty
317
+
318
+ **Solutions:**
319
+
320
+ - Verify wildcard pattern is correct
321
+ - Check current working directory
322
+ - Test with absolute or relative paths
323
+
324
+ #### 4. API Request Failed
325
+
326
+ **Symptoms:**
327
+
328
+ - 401 Unauthorized error
329
+ - 404 Repository not found error
330
+ - Network timeout
331
+
332
+ **Solutions:**
333
+
334
+ - Check if Gitea server address is correct
335
+ - Verify API Token is valid and not expired
336
+ - Confirm repository owner and name are correct
337
+ - Check network connection and firewall settings
338
+
339
+ ### Debugging Tips
340
+
341
+ #### Enable Verbose Logging
342
+
343
+ ```bash
344
+ npx release-it --verbose
345
+ ```
346
+
347
+ #### Use Dry Run Mode
348
+
349
+ ```bash
350
+ npx release-it --dry-run
351
+ ```
352
+
353
+ #### Check Configuration
354
+
355
+ ```bash
356
+ npx release-it --config --verbose
357
+ ```
358
+
359
+ ## Development Guide
360
+
361
+ ### Development Environment Setup
362
+
363
+ ```bash
364
+ # Clone repository
365
+ git clone https://github.com/lib-pack/release-it-gitea.git
366
+ cd release-it-gitea
367
+
368
+ # Install dependencies
369
+ pnpm install
370
+
371
+ # Build project
372
+ pnpm build
373
+
374
+ # Run tests
375
+ pnpm test
376
+
377
+ # Code linting
378
+ pnpm lint
379
+
380
+ # Format code
381
+ pnpm format
382
+ ```
383
+
384
+ ### Contributing Guide
385
+
386
+ 1. Fork the project
387
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
388
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
389
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
390
+ 5. Create a Pull Request
391
+
392
+ ## License
393
+
394
+ This project is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.
395
+
396
+ ## Acknowledgments
397
+
398
+ Thanks to all developers who have contributed to this project!
399
+
400
+ ---
401
+
402
+ If you find this project helpful, please give us a ⭐️!
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Release It! Gitea Plugin
2
2
 
3
+ [English](README.en.md) | 中文
4
+
3
5
  一个用于 [release-it](https://github.com/release-it/release-it) 的 Gitea 插件,支持自动创建 Gitea 发布并上传附件。
4
6
 
5
7
  ## 功能特性
@@ -7,11 +9,13 @@
7
9
  - ✅ 自动创建和更新 Gitea 发布
8
10
  - ✅ 支持模板变量替换(版本号、变更日志等)
9
11
  - ✅ 支持草稿和预发布版本
10
- - ✅ **新功能:支持文件和文件夹附件上传**
11
- - ✅ **新功能:支持自动打包文件夹为 ZIP**
12
- - ✅ **新功能:支持通配符文件匹配**
12
+ - ✅ **支持文件和文件夹附件上传**
13
+ - ✅ **支持自动打包文件夹为 ZIP**
14
+ - ✅ **支持通配符文件匹配**
15
+
16
+ ## 快速开始
13
17
 
14
- ## 安装
18
+ ### 1. 安装插件
15
19
 
16
20
  ```bash
17
21
  npm install --save-dev release-it-gitea
@@ -21,19 +25,15 @@ pnpm add -D release-it-gitea
21
25
  yarn add -D release-it-gitea
22
26
  ```
23
27
 
24
- ## 配置
25
-
26
- ### 1. 设置环境变量
27
-
28
- 首先,你需要设置 Gitea API token:
28
+ ### 2. 设置环境变量
29
29
 
30
30
  ```bash
31
31
  export GITEA_TOKEN="your-gitea-api-token"
32
32
  ```
33
33
 
34
- ### 2. 配置 release-it
34
+ ### 3. 基础配置
35
35
 
36
- 在你的 `.release-it.json` 文件中添加插件配置:
36
+ `.release-it.json` 中添加:
37
37
 
38
38
  ```json
39
39
  {
@@ -41,69 +41,37 @@ export GITEA_TOKEN="your-gitea-api-token"
41
41
  "release-it-gitea": {
42
42
  "host": "https://gitea.example.com",
43
43
  "owner": "your-username",
44
- "repository": "your-repo",
45
- "release": true,
46
- "releaseTitle": "v${version}",
47
- "releaseNotes": "${changelog}",
48
- "prerelease": false,
49
- "draft": false,
50
- "tokenRef": "GITEA_TOKEN"
44
+ "repository": "your-repo"
51
45
  }
52
46
  }
53
47
  }
54
48
  ```
55
49
 
56
- 或者在 `package.json` 中:
50
+ ### 4. 运行发布
57
51
 
58
- ```json
59
- {
60
- "release-it": {
61
- "plugins": {
62
- "release-it-gitea": {
63
- "host": "https://gitea.example.com",
64
- "owner": "your-username",
65
- "repository": "your-repo",
66
- "release": true
67
- }
68
- }
69
- }
70
- }
52
+ ```bash
53
+ npx release-it
71
54
  ```
72
55
 
73
- ## 配置选项
56
+ ## 详细配置
74
57
 
75
- | 选项 | 类型 | 默认值 | 描述 |
76
- | -------------- | ---------------------- | ---------------------- | -------------------- |
77
- | `host` | `string` | 当前仓库的 host | Gitea 服务器 URL |
78
- | `owner` | `string` | 从 git remote 自动检测 | 仓库所有者 |
79
- | `repository` | `string` | 从 git remote 自动检测 | 仓库名称 |
80
- | `release` | `boolean` | `true` | 是否创建发布 |
81
- | `releaseTitle` | `string` | `"v${version}"` | 发布标题模板 |
82
- | `releaseNotes` | `string` | `"${changelog}"` | 发布说明模板 |
83
- | `prerelease` | `boolean` | `false` | 是否为预发布 |
84
- | `draft` | `boolean` | `false` | 是否为草稿 |
85
- | `tokenRef` | `string` | `"GITEA_TOKEN"` | API token 环境变量名 |
86
- | `timeout` | `number` | `30000` | 请求超时时间(毫秒) |
87
- | `assets` | `(string \| object)[]` | `` | 附加的资源文件 |
58
+ ### 基本配置选项
88
59
 
89
- ## 附件上传配置
90
-
91
- ### 基本附件配置
92
-
93
- ```json
94
- {
95
- "plugins": {
96
- "release-it-gitea": {
97
- "host": "https://gitea.example.com",
98
- "owner": "your-username",
99
- "repository": "your-repo",
100
- "assets": ["dist/app.js", "README.md", "dist/**/*.min.js"]
101
- }
102
- }
103
- }
104
- ```
60
+ | 选项 | 类型 | 默认值 | 描述 |
61
+ | -------------- | ------- | ---------------------- | -------------------- |
62
+ | `host` | string | 当前仓库的 host | Gitea 服务器 URL |
63
+ | `owner` | string | 从 git remote 自动检测 | 仓库所有者 |
64
+ | `repository` | string | 从 git remote 自动检测 | 仓库名称 |
65
+ | `release` | boolean | `true` | 是否创建发布 |
66
+ | `releaseTitle` | string | `"v${version}"` | 发布标题模板 |
67
+ | `releaseNotes` | string | `"${changelog}"` | 发布说明模板 |
68
+ | `prerelease` | boolean | `false` | 是否为预发布 |
69
+ | `draft` | boolean | `false` | 是否为草稿 |
70
+ | `tokenRef` | string | `"GITEA_TOKEN"` | API token 环境变量名 |
71
+ | `timeout` | number | `30000` | 请求超时时间(毫秒) |
72
+ | `assets` | array | `[]` | 附加的资源文件 |
105
73
 
106
- ### 高级附件配置
74
+ ### 完整配置示例
107
75
 
108
76
  ```json
109
77
  {
@@ -112,23 +80,21 @@ export GITEA_TOKEN="your-gitea-api-token"
112
80
  "host": "https://gitea.example.com",
113
81
  "owner": "your-username",
114
82
  "repository": "your-repo",
83
+ "release": true,
84
+ "releaseTitle": "Release ${version}",
85
+ "releaseNotes": "## 更新内容\n\n${changelog}",
86
+ "prerelease": false,
87
+ "draft": false,
88
+ "tokenRef": "GITEA_TOKEN",
89
+ "timeout": 30000,
115
90
  "assets": [
91
+ "dist/app.js",
92
+ "README.md",
116
93
  {
117
94
  "path": "dist/**/*",
118
- "name": "distribution-files.zip",
95
+ "name": "distribution-${version}.zip",
119
96
  "type": "zip",
120
97
  "label": "Distribution Files"
121
- },
122
- {
123
- "path": "docs/*.md",
124
- "type": "file",
125
- "label": "Documentation"
126
- },
127
- {
128
- "path": "src",
129
- "name": "source-code.zip",
130
- "type": "zip",
131
- "label": "Source Code"
132
98
  }
133
99
  ]
134
100
  }
@@ -136,23 +102,51 @@ export GITEA_TOKEN="your-gitea-api-token"
136
102
  }
137
103
  ```
138
104
 
139
- ## 附件配置选项
105
+ ## 附件上传功能
140
106
 
141
- ### 字符串格式
107
+ ### 基本用法
142
108
 
143
- 直接指定文件路径,支持通配符:
109
+ 支持多种格式的附件配置:
144
110
 
145
111
  ```json
146
- "assets": [
147
- "dist/app.js",
148
- "build/**/*.min.js",
149
- "*.md"
150
- ]
112
+ {
113
+ "assets": [
114
+ "dist/app.js", // 单个文件
115
+ "dist/**/*.min.js", // 通配符匹配
116
+ "*.md" // 多个匹配文件
117
+ ]
118
+ }
151
119
  ```
152
120
 
153
- ### 对象格式
121
+ ### 高级配置
122
+
123
+ 使用对象格式进行更详细的配置:
124
+
125
+ ```json
126
+ {
127
+ "assets": [
128
+ {
129
+ "path": "dist/**/*",
130
+ "name": "distribution-files.zip",
131
+ "type": "zip",
132
+ "label": "Distribution Files"
133
+ },
134
+ {
135
+ "path": "docs/*.md",
136
+ "type": "file",
137
+ "label": "Documentation"
138
+ },
139
+ {
140
+ "path": "src",
141
+ "name": "source-code-${version}.zip",
142
+ "type": "zip",
143
+ "label": "Source Code"
144
+ }
145
+ ]
146
+ }
147
+ ```
154
148
 
155
- 更详细的配置选项:
149
+ ### 附件配置参数
156
150
 
157
151
  | 属性 | 类型 | 必需 | 描述 |
158
152
  | ------- | --------------- | ---- | ------------------------------------ |
@@ -166,9 +160,9 @@ export GITEA_TOKEN="your-gitea-api-token"
166
160
  - **`file`**: 直接上传匹配到的文件
167
161
  - **`zip`**: 将匹配到的文件打包成 ZIP 文件后上传
168
162
 
169
- ## 使用示例
163
+ ## 使用场景示例
170
164
 
171
- ### 示例 1:上传构建产物
165
+ ### 场景 1:上传构建产物
172
166
 
173
167
  ```json
174
168
  {
@@ -176,7 +170,7 @@ export GITEA_TOKEN="your-gitea-api-token"
176
170
  }
177
171
  ```
178
172
 
179
- ### 示例 2:打包源代码
173
+ ### 场景 2:打包源代码发布
180
174
 
181
175
  ```json
182
176
  {
@@ -191,7 +185,7 @@ export GITEA_TOKEN="your-gitea-api-token"
191
185
  }
192
186
  ```
193
187
 
194
- ### 示例 3:多种文件类型
188
+ ### 场景 3:多种文件类型组合
195
189
 
196
190
  ```json
197
191
  {
@@ -212,31 +206,36 @@ export GITEA_TOKEN="your-gitea-api-token"
212
206
  }
213
207
  ```
214
208
 
215
- ## 完整配置选项
209
+ ### 场景 4:不同环境的配置
216
210
 
217
- | 选项 | 类型 | 默认值 | 描述 |
218
- | -------------- | ------- | ---------------- | -------------------- |
219
- | `host` | string | - | Gitea 服务器地址 |
220
- | `owner` | string | - | 仓库所有者 |
221
- | `repository` | string | - | 仓库名称 |
222
- | `release` | boolean | `true` | 是否启用发布功能 |
223
- | `releaseTitle` | string | `"v${version}"` | 发布标题模板 |
224
- | `releaseNotes` | string | `"${changelog}"` | 发布说明模板 |
225
- | `prerelease` | boolean | `false` | 是否为预发布版本 |
226
- | `draft` | boolean | `false` | 是否创建为草稿 |
227
- | `tokenRef` | string | `"GITEA_TOKEN"` | API Token 环境变量名 |
228
- | `timeout` | number | `30000` | 请求超时时间(毫秒) |
229
- | `assets` | array | `[]` | 附件配置列表 |
211
+ ```json
212
+ {
213
+ "assets": [
214
+ {
215
+ "path": "dist/prod/**/*",
216
+ "name": "production-build-${version}.zip",
217
+ "type": "zip",
218
+ "label": "Production Build"
219
+ },
220
+ {
221
+ "path": "dist/dev/**/*",
222
+ "name": "development-build-${version}.zip",
223
+ "type": "zip",
224
+ "label": "Development Build"
225
+ }
226
+ ]
227
+ }
228
+ ```
230
229
 
231
- ## 环境变量
230
+ ## 环境变量配置
232
231
 
233
- 设置 Gitea API Token:
232
+ ### 默认 Token 配置
234
233
 
235
234
  ```bash
236
235
  export GITEA_TOKEN=your_gitea_api_token
237
236
  ```
238
237
 
239
- 或者使用自定义环境变量名:
238
+ ### 自定义 Token 配置
240
239
 
241
240
  ```json
242
241
  {
@@ -250,50 +249,116 @@ export MY_GITEA_TOKEN=your_gitea_api_token
250
249
 
251
250
  ## 模板变量
252
251
 
253
- 在 `releaseTitle` `releaseNotes` 中可以使用以下变量:
252
+ 在 `releaseTitle`、`releaseNotes` 和附件 `name` 中可以使用以下变量:
253
+
254
+ | 变量 | 描述 | 示例 |
255
+ | -------------------- | ------------ | -------------------- |
256
+ | `${version}` | 当前版本号 | `1.2.3` |
257
+ | `${latestVersion}` | 上一个版本号 | `1.2.2` |
258
+ | `${changelog}` | 变更日志 | `- 修复了某个bug` |
259
+ | `${name}` | 项目名称 | `my-awesome-project` |
260
+ | `${repo.owner}` | 仓库所有者 | `username` |
261
+ | `${repo.repository}` | 仓库名称 | `my-repo` |
262
+ | `${branchName}` | 分支名称 | `main` |
254
263
 
255
- - `${version}`: 当前版本号
256
- - `${latestVersion}`: 上一个版本号
257
- - `${changelog}`: 变更日志
258
- - `${name}`: 项目名称
259
- - `${repo.owner}`: 仓库所有者
260
- - `${repo.repository}`: 仓库名称
261
- - `${branchName}`: 分支名称
264
+ ### 模板使用示例
265
+
266
+ ```json
267
+ {
268
+ "releaseTitle": "🚀 ${name} v${version}",
269
+ "releaseNotes": "## 📋 更新内容\n\n${changelog}\n\n## 📦 下载\n\n请下载对应平台的文件",
270
+ "assets": [
271
+ {
272
+ "path": "dist/**/*",
273
+ "name": "${name}-${version}-dist.zip",
274
+ "type": "zip",
275
+ "label": "${name} v${version} Distribution"
276
+ }
277
+ ]
278
+ }
279
+ ```
262
280
 
263
281
  ## 故障排除
264
282
 
265
- ### 常见问题
283
+ ### 常见问题及解决方案
284
+
285
+ #### 1. 附件上传失败
266
286
 
267
- 1. **附件上传失败**
287
+ **问题症状:**
268
288
 
269
- - 检查文件路径是否正确
270
- - 确保文件存在且可读
271
- - 检查 Gitea API Token 权限
289
+ - 附件上传时出现错误
290
+ - 文件找不到
272
291
 
273
- 2. **ZIP 文件创建失败**
292
+ **解决方案:**
274
293
 
275
- - 确保有足够的磁盘空间
276
- - 检查临时目录权限
294
+ - 检查文件路径是否正确
295
+ - 确保文件存在且可读
296
+ - 检查 Gitea API Token 权限是否包含附件上传权限
277
297
 
278
- 3. **通配符匹配无文件**
298
+ #### 2. ZIP 文件创建失败
279
299
 
280
- - 验证通配符模式是否正确
281
- - 检查当前工作目录
300
+ **问题症状:**
282
301
 
283
- 4. **API 请求失败**
284
- - 检查 Gitea 服务器地址是否正确
285
- - 验证 API Token 是否有效
286
- - 确认仓库所有者和名称正确
302
+ - ZIP 文件创建时出错
303
+ - 磁盘空间不足错误
287
304
 
288
- ### 调试模式
305
+ **解决方案:**
289
306
 
290
- 使用 `--verbose` 参数查看详细日志:
307
+ - 确保有足够的磁盘空间
308
+ - 检查临时目录权限
309
+ - 验证要打包的文件是否存在
310
+
311
+ #### 3. 通配符匹配无文件
312
+
313
+ **问题症状:**
314
+
315
+ - 通配符模式没有匹配到任何文件
316
+ - 附件列表为空
317
+
318
+ **解决方案:**
319
+
320
+ - 验证通配符模式是否正确
321
+ - 检查当前工作目录
322
+ - 使用绝对路径或相对路径进行测试
323
+
324
+ #### 4. API 请求失败
325
+
326
+ **问题症状:**
327
+
328
+ - 401 未授权错误
329
+ - 404 仓库不存在错误
330
+ - 网络超时
331
+
332
+ **解决方案:**
333
+
334
+ - 检查 Gitea 服务器地址是否正确
335
+ - 验证 API Token 是否有效且未过期
336
+ - 确认仓库所有者和名称正确
337
+ - 检查网络连接和防火墙设置
338
+
339
+ ### 调试技巧
340
+
341
+ #### 启用详细日志
291
342
 
292
343
  ```bash
293
344
  npx release-it --verbose
294
345
  ```
295
346
 
296
- ## 开发
347
+ #### 使用干运行模式
348
+
349
+ ```bash
350
+ npx release-it --dry-run
351
+ ```
352
+
353
+ #### 检查配置
354
+
355
+ ```bash
356
+ npx release-it --config --verbose
357
+ ```
358
+
359
+ ## 开发指南
360
+
361
+ ### 开发环境搭建
297
362
 
298
363
  ```bash
299
364
  # 克隆仓库
@@ -303,7 +368,7 @@ cd release-it-gitea
303
368
  # 安装依赖
304
369
  pnpm install
305
370
 
306
- # 构建
371
+ # 构建项目
307
372
  pnpm build
308
373
 
309
374
  # 运行测试
@@ -311,12 +376,27 @@ pnpm test
311
376
 
312
377
  # 代码检查
313
378
  pnpm lint
379
+
380
+ # 格式化代码
381
+ pnpm format
314
382
  ```
315
383
 
384
+ ### 贡献指南
385
+
386
+ 1. Fork 项目
387
+ 2. 创建功能分支 (`git checkout -b feature/amazing-feature`)
388
+ 3. 提交更改 (`git commit -m 'Add amazing feature'`)
389
+ 4. 推送到分支 (`git push origin feature/amazing-feature`)
390
+ 5. 创建 Pull Request
391
+
316
392
  ## 许可证
317
393
 
318
- MIT
394
+ 本项目采用 MIT 许可证。详情请参阅 [LICENSE.md](LICENSE.md) 文件。
395
+
396
+ ## 致谢
397
+
398
+ 感谢所有为这个项目做出贡献的开发者!
319
399
 
320
- ## 贡献
400
+ ---
321
401
 
322
- 欢迎提交 Issue 和 Pull Request!
402
+ 如果您觉得这个项目对您有帮助,请给我们一个 ⭐️!
package/lib/index.js CHANGED
@@ -21,6 +21,7 @@ class GiteaPlugin extends Plugin {
21
21
  }
22
22
  const repo = this.config.getContext("repo");
23
23
  const config = {
24
+ assets: gitea.assets ?? [],
24
25
  draft: gitea.draft ?? false,
25
26
  host: gitea.host ?? repo.host,
26
27
  owner: gitea.owner ?? repo.owner,
@@ -227,7 +228,7 @@ class GiteaPlugin extends Plugin {
227
228
  for (const file of files) {
228
229
  const stats = statSync(file);
229
230
  if (stats.isFile()) {
230
- const relativePath = basePath ? file.replace(basePath, "").replace(/^\//, "") : basename(file);
231
+ const relativePath = basePath ? join(basePath, file.split(basePath)[1]) : basename(file);
231
232
  archive.file(file, { name: relativePath });
232
233
  }
233
234
  }
@@ -323,7 +324,11 @@ class GiteaPlugin extends Plugin {
323
324
  mkdirSync(dirname(tempZipPath), { recursive: true });
324
325
  } catch (error) {
325
326
  }
326
- await this.createZipArchive(files, tempZipPath, dirname(config.path));
327
+ await this.createZipArchive(
328
+ files,
329
+ tempZipPath,
330
+ dirname(config.path).replace(/\*/g, "")
331
+ );
327
332
  await this.uploadAsset(releaseId, tempZipPath, zipName, config.label);
328
333
  const { unlinkSync } = await import("fs");
329
334
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it-gitea",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "release-it gitea plugin",
5
5
  "keywords": [
6
6
  "gitea",