Skip to content

Commit 3dbcb81

Browse files
committed
AI 更新经验
1 parent a27cad4 commit 3dbcb81

File tree

1 file changed

+79
-4
lines changed

1 file changed

+79
-4
lines changed

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

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515
- ✅ 支持三大平台:Windows (win-x64)、Linux (linux-x64)、macOS (osx-x64)
1616
- ✅ 使用 PublishAot=true 进行 AOT 编译
1717
- ✅ 自动重命名可执行文件为平台特定名称
18+
-**修复发布产物上传问题**: 解决了 .exe.zip 后缀和 404 链接问题
1819

1920
### 3. 自动化发布和版本管理
2021
- ✅ 集成了 dotnetCampus.TagToVersion 工具
2122
- ✅ 版本号自动从 Git Tag 提取并写入 Version.props
2223
- ✅ 支持预发布版本识别 (alpha/beta/rc)
2324
- ✅ 自动创建 GitHub Releases 并上传构建产物
25+
-**优化发布页面**: 统一英文描述,提升国际化标准
2426

2527
### 4. 代码质量检查和自动化测试集成
2628
- ✅ 创建了代码质量检查流水线 (`.github/workflows/code-quality.yml`)
@@ -55,13 +57,14 @@
5557
if: matrix.os != 'windows-latest'
5658
run: dotnet publish ./src/DotNetCampus.Terminal/ -p:PublishAot=true -r ${{ matrix.runtime }}
5759

58-
# 3. 条件执行和矩阵策略
60+
# 3. 条件执行和矩阵策略 (修正版)
5961
strategy:
6062
matrix:
6163
include:
6264
- os: windows-latest
6365
runtime: win-x64
64-
artifact-name: DotNetCampus.Terminal-win-x64.exe
66+
artifact-name: DotNetCampus.Terminal-win-x64 # 用于 zip 文件名
67+
executable-name: DotNetCampus.Terminal-win-x64.exe # 用于可执行文件名
6568
```
6669
6770
### 版本管理策略
@@ -94,7 +97,7 @@ strategy:
9497
if: matrix.os == 'windows-latest'
9598
run: |
9699
if (Test-Path ".\publish\${{ matrix.runtime }}\DotNetCampus.Terminal.exe") {
97-
Rename-Item ".\publish\${{ matrix.runtime }}\DotNetCampus.Terminal.exe" "${{ matrix.artifact-name }}"
100+
Rename-Item ".\publish\${{ matrix.runtime }}\DotNetCampus.Terminal.exe" "${{ matrix.executable-name }}"
98101
}
99102
shell: pwsh
100103
@@ -103,7 +106,7 @@ strategy:
103106
if: matrix.os != 'windows-latest'
104107
run: |
105108
if [ -f "./publish/${{ matrix.runtime }}/DotNetCampus.Terminal" ]; then
106-
mv "./publish/${{ matrix.runtime }}/DotNetCampus.Terminal" "./publish/${{ matrix.runtime }}/${{ matrix.artifact-name }}"
109+
mv "./publish/${{ matrix.runtime }}/DotNetCampus.Terminal" "./publish/${{ matrix.runtime }}/${{ matrix.executable-name }}"
107110
fi
108111
```
109112

@@ -120,6 +123,78 @@ strategy:
120123

121124
**经验教训**: 在多人协作项目中,代码格式标准化需要全团队讨论决定,不能单方面强制实施
122125

126+
### 5. GitHub Release 产物上传问题 ⭐⭐⭐
127+
**问题**: Release 页面只有 Windows 版本,其他平台缺失且文件链接 404
128+
**根本原因**:
129+
1. 只上传了单个可执行文件,没有上传完整的发布包
130+
2. 文件夹结构包含多余的外层目录
131+
3. artifacts 下载路径不正确
132+
4. **命名规范错误**: `DotNetCampus.Terminal-win-x64.exe` 作为 artifact-name 导致生成 `.exe.zip` 后缀
133+
134+
**解决方案**:
135+
```yaml
136+
# 1. 分离 artifact-name 和 executable-name
137+
matrix:
138+
include:
139+
- os: windows-latest
140+
runtime: win-x64
141+
artifact-name: DotNetCampus.Terminal-win-x64 # 用于 zip 文件名
142+
executable-name: DotNetCampus.Terminal-win-x64.exe # 用于可执行文件名
143+
144+
# 2. 创建完整的 zip 包,包含所有发布文件
145+
- name: Create release package (Windows)
146+
if: matrix.os == 'windows-latest'
147+
run: |
148+
# 创建临时文件夹,复制所有发布文件
149+
New-Item -ItemType Directory -Path ".\temp-release" -Force
150+
Copy-Item -Path ".\publish\${{ matrix.runtime }}\*" -Destination ".\temp-release\" -Recurse
151+
# 创建 zip 包,不包含外层文件夹
152+
Compress-Archive -Path ".\temp-release\*" -DestinationPath ".\${{ matrix.artifact-name }}.zip"
153+
154+
# 3. 上传 zip 文件而不是单个可执行文件
155+
- name: Upload artifacts
156+
uses: actions/upload-artifact@v4
157+
with:
158+
name: ${{ matrix.artifact-name }}
159+
path: ${{ matrix.artifact-name }}.zip
160+
161+
# 4. 正确的文件路径引用
162+
files: |
163+
./artifacts/DotNetCampus.Terminal-win-x64/DotNetCampus.Terminal-win-x64.zip
164+
./artifacts/DotNetCampus.Terminal-linux-x64/DotNetCampus.Terminal-linux-x64.zip
165+
./artifacts/DotNetCampus.Terminal-osx-x64/DotNetCampus.Terminal-osx-x64.zip
166+
```
167+
168+
**经验教训**:
169+
- AOT 发布的应用程序除了主程序外,还可能包含其他必要文件
170+
- 应该打包完整的发布目录而不是只上传可执行文件
171+
- GitHub Actions 的 artifacts 下载会创建以 artifact name 命名的文件夹
172+
- **命名规范很重要**: artifact-name 不应包含文件扩展名,否则会产生混乱的后缀
173+
174+
### 6. 跨平台 zip 创建兼容性问题
175+
**问题**: Windows 和 Unix 系统的压缩命令不同
176+
**解决方案**:
177+
```yaml
178+
# Windows: 使用 PowerShell 的 Compress-Archive
179+
Compress-Archive -Path ".\temp-release\*" -DestinationPath ".\${{ matrix.artifact-name }}.zip"
180+
181+
# Unix: 使用 zip 命令,注意工作目录
182+
cd temp-release && zip -r ../${{ matrix.artifact-name }}.zip * && cd ..
183+
```
184+
185+
**注意事项**:
186+
- zip 命令需要进入目录内部执行,避免包含外层文件夹
187+
- PowerShell 的 Compress-Archive 直接指定源路径和目标路径
188+
189+
### 7. Release 页面国际化标准 ⭐
190+
**问题**: 发布页面中英文混杂,不符合国际开源项目标准
191+
**解决方案**:
192+
- 统一使用英文描述,提升项目专业性
193+
- 保持表格格式清晰,便于用户快速定位下载链接
194+
- 提供详细的安装指南,覆盖各个平台
195+
196+
**经验教训**: 开源项目的发布页面应该保持国际化标准,使用英文可以让更多开发者理解和使用
197+
123198
## 📋 待实现功能
124199

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

0 commit comments

Comments
 (0)