Skip to content

Commit b388260

Browse files
committed
AI 优化打出的包
1 parent 3dbcb81 commit b388260

File tree

2 files changed

+88
-38
lines changed

2 files changed

+88
-38
lines changed

.github/knowledge/AI协作经验/角色经验总结/DevOps自动化专家-核心经验总结.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
- ✅ 支持预发布版本识别 (alpha/beta/rc)
2424
- ✅ 自动创建 GitHub Releases 并上传构建产物
2525
-**优化发布页面**: 统一英文描述,提升国际化标准
26+
-**修复发布产物命名问题**:
27+
- 产物文件夹内保持原始 exe 文件名 (DotNetCampus.Terminal.exe)
28+
- 仅 zip 包使用规范化命名 (DotNetCampus.Terminal.win-x64.1.0.0.zip)
29+
- 过滤 .pdb/.dbg/.dsym 调试文件以减小包体积
30+
- zip 包命名规范:使用 `.` 分割,版本号不带 `v` 前缀
2631

2732
### 4. 代码质量检查和自动化测试集成
2833
- ✅ 创建了代码质量检查流水线 (`.github/workflows/code-quality.yml`)
@@ -195,6 +200,39 @@ cd temp-release && zip -r ../${{ matrix.artifact-name }}.zip * && cd ..
195200

196201
**经验教训**: 开源项目的发布页面应该保持国际化标准,使用英文可以让更多开发者理解和使用
197202

203+
### 8. 发布产物命名规范优化 ⭐⭐
204+
**问题**: 初期的命名规范存在以下问题:
205+
1. **exe 文件重命名**: 擅自修改产物文件夹内的 exe 文件名,造成混乱
206+
2. **调试文件冗余**: .pdb/.dbg/.dsym 文件大幅增加包体积
207+
3. **命名格式不统一**: 使用连字符分割,版本号带 `v` 前缀
208+
209+
**最终解决方案**:
210+
```yaml
211+
# 1. 保持产物文件夹内原始文件名
212+
# 删除所有重命名 exe 文件的步骤
213+
214+
# 2. 过滤调试文件
215+
# Windows: 排除 .pdb, .dbg 文件
216+
Get-ChildItem -Path ".\publish\${{ matrix.runtime }}" -Recurse |
217+
Where-Object { $_.Extension -notin @('.pdb', '.dbg') }
218+
219+
# Unix: 排除 .pdb, .dbg, .dsym 文件
220+
find ./publish/${{ matrix.runtime }} -type f ! -name "*.pdb" ! -name "*.dbg" ! -path "*.dsym*"
221+
222+
# 3. 统一命名规范:使用 . 分割,版本号不带 v
223+
$zipName = "DotNetCampus.Terminal.${{ matrix.runtime }}.${{ steps.get_version.outputs.version }}.zip"
224+
```
225+
226+
**最终命名格式**:
227+
- `DotNetCampus.Terminal.win-x64.1.0.0.zip`
228+
- `DotNetCampus.Terminal.linux-x64.1.0.0.zip`
229+
- `DotNetCampus.Terminal.osx-x64.1.0.0.zip`
230+
231+
**经验教训**:
232+
- **产物内容不变原则**: 发布产物文件夹内的文件应保持原始名称,只有打包文件名需要规范化
233+
- **体积优化**: 生产环境不需要调试符号文件,过滤可显著减小包体积
234+
- **命名一致性**: 统一的命名规范有助于用户识别和自动化脚本处理
235+
198236
## 📋 待实现功能
199237

200238
### 高级特性 (未来考虑)

.github/workflows/release.yml

Lines changed: 50 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,14 @@ jobs:
1414
- os: windows-latest
1515
runtime: win-x64
1616
artifact-name: DotNetCampus.Terminal-win-x64
17-
executable-name: DotNetCampus.Terminal-win-x64.exe
1817
path-separator: '\'
1918
- os: ubuntu-latest
2019
runtime: linux-x64
2120
artifact-name: DotNetCampus.Terminal-linux-x64
22-
executable-name: DotNetCampus.Terminal-linux-x64
2321
path-separator: '/'
2422
- os: macos-latest
2523
runtime: osx-x64
2624
artifact-name: DotNetCampus.Terminal-osx-x64
27-
executable-name: DotNetCampus.Terminal-osx-x64
2825
path-separator: '/'
2926

3027
steps:
@@ -42,6 +39,16 @@ jobs:
4239
- name: Set tag to version
4340
run: dotnet TagToVersion -t ${{ github.ref }}
4441

42+
- name: Extract version from tag
43+
id: get_version
44+
run: |
45+
# Extract version from tag (remove 'v' prefix if present)
46+
VERSION="${{ github.ref_name }}"
47+
VERSION=${VERSION#v}
48+
echo "version=$VERSION" >> $GITHUB_OUTPUT
49+
echo "Extracted version: $VERSION"
50+
shell: bash
51+
4552
- name: Restore dependencies
4653
run: dotnet restore
4754

@@ -53,45 +60,40 @@ jobs:
5360
if: matrix.os != 'windows-latest'
5461
run: dotnet publish ./src/DotNetCampus.Terminal/ -p:PublishAot=true -r ${{ matrix.runtime }} --configuration Release --output ./publish/${{ matrix.runtime }}
5562

56-
- name: Rename executable (Windows)
63+
- name: Clean debug files and create release package (Windows)
5764
if: matrix.os == 'windows-latest'
5865
run: |
59-
if (Test-Path ".\publish\${{ matrix.runtime }}\DotNetCampus.Terminal.exe") {
60-
Rename-Item ".\publish\${{ matrix.runtime }}\DotNetCampus.Terminal.exe" "${{ matrix.executable-name }}"
61-
}
62-
shell: pwsh
63-
64-
- name: Rename executable (Unix)
65-
if: matrix.os != 'windows-latest'
66-
run: |
67-
if [ -f "./publish/${{ matrix.runtime }}/DotNetCampus.Terminal" ]; then
68-
mv "./publish/${{ matrix.runtime }}/DotNetCampus.Terminal" "./publish/${{ matrix.runtime }}/${{ matrix.executable-name }}"
69-
fi
70-
71-
- name: Create release package (Windows)
72-
if: matrix.os == 'windows-latest'
73-
run: |
74-
# 创建临时文件夹,复制所有发布文件
66+
# 创建临时文件夹
7567
New-Item -ItemType Directory -Path ".\temp-release" -Force
76-
Copy-Item -Path ".\publish\${{ matrix.runtime }}\*" -Destination ".\temp-release\" -Recurse
77-
# 创建 zip 包,不包含外层文件夹
78-
Compress-Archive -Path ".\temp-release\*" -DestinationPath ".\${{ matrix.artifact-name }}.zip"
68+
# 复制所有发布文件,排除调试文件
69+
Get-ChildItem -Path ".\publish\${{ matrix.runtime }}" -Recurse |
70+
Where-Object { $_.Extension -notin @('.pdb', '.dbg') } |
71+
Copy-Item -Destination { Join-Path ".\temp-release" $_.FullName.Substring("$((Get-Location).Path)\publish\${{ matrix.runtime }}".Length) } -Force
72+
# 创建带版本号的 zip 包 (使用 . 分割)
73+
$zipName = "DotNetCampus.Terminal.${{ matrix.runtime }}.${{ steps.get_version.outputs.version }}.zip"
74+
Compress-Archive -Path ".\temp-release\*" -DestinationPath ".\$zipName"
75+
echo "zip_name=$zipName" >> $env:GITHUB_OUTPUT
7976
shell: pwsh
77+
id: package_windows
8078

81-
- name: Create release package (Unix)
79+
- name: Clean debug files and create release package (Unix)
8280
if: matrix.os != 'windows-latest'
8381
run: |
84-
# 创建临时文件夹,复制所有发布文件
82+
# 创建临时文件夹
8583
mkdir -p ./temp-release
86-
cp -r ./publish/${{ matrix.runtime }}/* ./temp-release/
87-
# 创建 zip 包,不包含外层文件夹
88-
cd temp-release && zip -r ../${{ matrix.artifact-name }}.zip * && cd ..
84+
# 复制所有发布文件,排除调试文件(macOS 的 .dsym 文件夹也排除)
85+
find ./publish/${{ matrix.runtime }} -type f ! -name "*.pdb" ! -name "*.dbg" ! -path "*.dsym*" -exec cp {} ./temp-release/ \;
86+
# 创建带版本号的 zip 包 (使用 . 分割)
87+
zip_name="DotNetCampus.Terminal.${{ matrix.runtime }}.${{ steps.get_version.outputs.version }}.zip"
88+
cd temp-release && zip -r ../$zip_name * && cd ..
89+
echo "zip_name=$zip_name" >> $GITHUB_OUTPUT
90+
id: package_unix
8991

9092
- name: Upload artifacts
9193
uses: actions/upload-artifact@v4
9294
with:
9395
name: ${{ matrix.artifact-name }}
94-
path: ${{ matrix.artifact-name }}.zip
96+
path: ${{ steps.package_windows.outputs.zip_name || steps.package_unix.outputs.zip_name }}
9597
if-no-files-found: error
9698
retention-days: 7
9799

@@ -110,6 +112,16 @@ jobs:
110112
ls -la ./artifacts/
111113
find ./artifacts -type f -name "*.zip" | head -10
112114
115+
- name: Extract version from tag
116+
id: get_version
117+
run: |
118+
# Extract version from tag (remove 'v' prefix if present)
119+
VERSION="${{ github.ref_name }}"
120+
VERSION=${VERSION#v}
121+
echo "version=$VERSION" >> $GITHUB_OUTPUT
122+
echo "Extracted version: $VERSION"
123+
shell: bash
124+
113125
- name: Create GitHub Release
114126
uses: softprops/action-gh-release@v1
115127
with:
@@ -123,35 +135,35 @@ jobs:
123135
124136
| Platform | File | Description |
125137
|----------|------|-------------|
126-
| Windows (x64) | `DotNetCampus.Terminal-win-x64.zip` | Windows 64-bit version |
127-
| Linux (x64) | `DotNetCampus.Terminal-linux-x64.zip` | Linux 64-bit version |
128-
| macOS (x64) | `DotNetCampus.Terminal-osx-x64.zip` | macOS 64-bit version |
138+
| Windows (x64) | `DotNetCampus.Terminal.win-x64.${{ steps.get_version.outputs.version }}.zip` | Windows 64-bit version |
139+
| Linux (x64) | `DotNetCampus.Terminal.linux-x64.${{ steps.get_version.outputs.version }}.zip` | Linux 64-bit version |
140+
| macOS (x64) | `DotNetCampus.Terminal.osx-x64.${{ steps.get_version.outputs.version }}.zip` | macOS 64-bit version |
129141
130142
### 🔧 Installation
131143
132144
**Windows:**
133145
```bash
134146
# Extract the zip file
135-
# Double-click to run DotNetCampus.Terminal-win-x64.exe
147+
# Double-click to run DotNetCampus.Terminal.exe
136148
```
137149
138150
**Linux/macOS:**
139151
```bash
140152
# Extract the zip file
141153
unzip DotNetCampus.Terminal-*.zip
142154
# Make executable and run
143-
chmod +x DotNetCampus.Terminal-*
144-
./DotNetCampus.Terminal-*
155+
chmod +x DotNetCampus.Terminal
156+
./DotNetCampus.Terminal
145157
```
146158
147159
### 📝 What's Changed
148160
149161
See [CHANGELOG.md](https://github.com/dotnet-campus/DotNetCampus.Terminal/blob/main/CHANGELOG.md) for detailed changes.
150162
151163
files: |
152-
./artifacts/DotNetCampus.Terminal-win-x64/DotNetCampus.Terminal-win-x64.zip
153-
./artifacts/DotNetCampus.Terminal-linux-x64/DotNetCampus.Terminal-linux-x64.zip
154-
./artifacts/DotNetCampus.Terminal-osx-x64/DotNetCampus.Terminal-osx-x64.zip
164+
./artifacts/DotNetCampus.Terminal-win-x64/DotNetCampus.Terminal.win-x64.${{ steps.get_version.outputs.version }}.zip
165+
./artifacts/DotNetCampus.Terminal-linux-x64/DotNetCampus.Terminal.linux-x64.${{ steps.get_version.outputs.version }}.zip
166+
./artifacts/DotNetCampus.Terminal-osx-x64/DotNetCampus.Terminal.osx-x64.${{ steps.get_version.outputs.version }}.zip
155167
draft: false
156168
prerelease: ${{ contains(github.ref_name, 'alpha') || contains(github.ref_name, 'beta') || contains(github.ref_name, 'rc') }}
157169
env:

0 commit comments

Comments
 (0)