Skip to content

Commit 1f7df4f

Browse files
committed
[重构项目结构和文档,增强跨平台构建与部署能力]: 全面重构项目文档、优化打包脚本并统一开发环境配置
- **重构README文档**: 将简单的示例列表转换为结构化的项目文档,为每个示例添加详细的功能说明和视觉展示,提升项目的专业性和易用性 - **统一开发环境配置**: 用健壮的`Enter-VsDevShell.ps1`替换原有的`setVsDev.ps1`,增强Visual Studio开发环境检测和错误处理,支持多架构参数 - **优化打包工具链**: 重写macOS工具脚本`utils.sh`,增强错误处理和日志功能;重构Python上传工具`utils.py`,增加分块上传、进度显示和重试机制 - **增强跨平台支持**: 完善Windows、macOS和Ubuntu的打包说明,提供签名、公证和分发包制作的完整工作流指导 - **标准化脚本规范**: 为所有Shell脚本添加错误检查(`set -euo pipefail`)和日志功能,提高脚本的健壮性和可维护性
1 parent e632ed2 commit 1f7df4f

8 files changed

Lines changed: 576 additions & 351 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
if: startsWith(matrix.os, 'windows')
4848
shell: pwsh
4949
run: |
50-
.\scripts\windows\setVsDev.ps1
50+
.\packaging\windows\Enter-VsDevShell.ps1
5151
cmake `
5252
-S . `
5353
-B ./build `

.github/workflows/qmake.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
if: startsWith(matrix.os, 'windows')
5353
shell: pwsh
5454
run: |
55-
..\scripts\windows\setVsDev.ps1
55+
..\packaging\windows\Enter-VsDevShell.ps1
5656
& qmake ./../.
5757
& jom
5858
working-directory: build

README.md

Lines changed: 216 additions & 133 deletions
Large diffs are not rendered by default.

packaging/macos/utils.sh

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,59 @@
1-
#!/bin/bash -ex
1+
#!/bin/bash
2+
set -euo pipefail
3+
# ----------- 硬编码区 ---------------
4+
APPLE_ID="***@***"
5+
TEAM_ID="*********"
6+
NOTARY_PWD="*********"
7+
# ------------------------------------
8+
9+
log() { echo "[$(date +%F\ %T)] $*"; }
10+
die() {
11+
log "FATAL: $*"
12+
exit 1
13+
}
214

15+
# 安全删除
316
delete_file_or_dir() {
4-
local target=$1
5-
6-
if [ -e "$target" ]; then
7-
if [ -d "$target" ]; then
8-
rm -rf "$target"
9-
echo "Directory deleted: $target"
10-
else
11-
rm "$target"
12-
echo "File deleted: $target"
13-
fi
14-
else
15-
echo "Error: $target does not exist."
16-
fi
17+
local target=$1
18+
[[ -e $target ]] || {
19+
log "Skip: $target not exist"
20+
return 0
21+
}
22+
if [[ -d $target ]]; then
23+
rm -rf "$target" && log "DIR deleted: $target"
24+
else
25+
rm -f "$target" && log "FILE deleted: $target"
26+
fi
1727
}
1828

29+
# 处理 plist
1930
process_plist() {
20-
local plist_path="$1"
21-
22-
if [ -z "$plist_path" ]; then
23-
echo "Error: Plist file path is not provided."
24-
return 1
25-
fi
26-
27-
if [ ! -f "$plist_path" ]; then
28-
echo "Error: Plist file does not exist at path: $plist_path"
29-
return 1
30-
fi
31-
32-
echo "Converting plist to XML format..."
33-
plutil -convert xml1 "$plist_path" 2>/dev/null
34-
35-
echo "Linting plist file..."
36-
plutil -lint "$plist_path" 2>/dev/null
37-
38-
if [ $? -eq 0 ]; then
39-
echo "Plist file processed successfully."
40-
else
41-
echo "Error occurred while processing plist file."
42-
return 2
43-
fi
31+
local plist=$1
32+
[[ -n $plist && -f $plist ]] || {
33+
log "Skip plist: file missing"
34+
return 0
35+
}
36+
log "Convert plist → XML"
37+
plutil -convert xml1 "$plist"
38+
log "Lint plist"
39+
plutil -lint "$plist" >/dev/null || die "Plist lint failed"
40+
log "Plist processed OK"
4441
}
4542

43+
# 公证 + staple
4644
notarize_app() {
47-
local target=$1
48-
if [ ! -f "$target" ]; then
49-
echo "Error: $target does not exist."
50-
exit 1
51-
fi
45+
local target=$1
46+
[[ -f $target ]] || die "Notarize target missing: $target"
47+
48+
log "Submitting for notarization..."
49+
xcrun notarytool submit "$target" \
50+
--apple-id "$APPLE_ID" \
51+
--team-id "$TEAM_ID" \
52+
--password "$NOTARY_PWD" \
53+
--wait
54+
55+
log "Stapling ticket..."
56+
xcrun stapler staple "$target"
5257

53-
xcrun notarytool submit $target --apple-id "***@***" \
54-
--team-id "******" --password "******" --wait
55-
xcrun stapler staple $target
58+
log "Notarize & staple finished: $target"
5659
}

packaging/upload.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,26 +79,26 @@ def upload_platform(platform_key: str) -> None:
7979

8080
# 生成 update.json
8181
json_path = os.path.join(RELEASES_PATH, "update.json")
82-
utils.generate_json(VERSION, dst_path, dst_name, json_path)
82+
utils.write_json_describe(VERSION, dst_path, dst_name, json_path)
8383

8484
# 上传主安装包
85-
utils.sftp_upload_file(
85+
utils.upload_sftp(
8686
SFTP_SERVER,
8787
SFTP_PORT,
8888
SFTP_USER,
8989
SFTP_PWD,
90-
dst_path,
9190
f"{cfg['remote']}/{dst_name}",
91+
dst_path,
9292
)
9393

9494
# 上传 update.json
95-
utils.sftp_upload_file(
95+
utils.upload_sftp(
9696
SFTP_SERVER,
9797
SFTP_PORT,
9898
SFTP_USER,
9999
SFTP_PWD,
100-
json_path,
101100
f"{cfg['remote']}/update.json",
101+
json_path,
102102
)
103103

104104
print(f"[{platform_key}] 上传完成 ✔")

0 commit comments

Comments
 (0)