Skip to content

Commit 5debb0d

Browse files
committed
Switch updater packaging from DMG to tar.gz archives
Update workflow to create, sign, and release .tar.gz archives instead of DMG files for both architectures. Improve updater logging.
1 parent 8bd0c5d commit 5debb0d

4 files changed

Lines changed: 67 additions & 23 deletions

File tree

.github/workflows/main.yml

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,47 +66,56 @@ jobs:
6666
VERSION=$(grep '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
6767
echo "version=$VERSION" >> $GITHUB_OUTPUT
6868
69-
- name: Sign DMG files for Updater
69+
- name: Create targz Archives
7070
run: |
7171
VERSION=${{ steps.package_version.outputs.version }}
72-
# 定义两个架构的 DMG 文件路径
73-
DMG_AARCH64="./target/release/MessAuto_${VERSION}_aarch64.dmg"
74-
DMG_X86_64="./target/x86_64-apple-darwin/release/MessAuto_${VERSION}_x64.dmg"
72+
echo "Creating aarch64 .tar.gz archive..."
73+
# -C 参数可以让我们在指定的目录中执行压缩,避免在归档中包含多余的父目录
74+
tar -czf "MessAuto_${VERSION}_aarch64.app.tar.gz" -C ./target/release/MessAuto.app
75+
echo "Creating x86_64 .tar.gz archive..."
76+
tar -czf "MessAuto_${VERSION}_x64.app.tar.gz" -C ./target/x86_64-apple-darwin/release/MessAuto.app
7577
76-
echo "Signing AARCH64 DMG..."
78+
- name: Sign Archives for Updater
79+
run: |
80+
VERSION=${{ steps.package_version.outputs.version }}
81+
# 定义两个架构的 .tar.gz 文件路径
82+
ARCHIVE_AARCH64="./MessAuto_${VERSION}_aarch64.app.tar.gz"
83+
ARCHIVE_X86_64="./MessAuto_${VERSION}_x64.app.tar.gz"
84+
85+
echo "Signing AARCH64 archive..."
7786
cargo packager signer sign \
7887
--private-key ${{ secrets.UPDATER_PRIVATE_KEY }} \
7988
--password ${{ secrets.UPDATER_KEY_PASSWORD }} \
80-
"$DMG_AARCH64"
89+
"$ARCHIVE_AARCH64"
8190
82-
echo "Signing X86_64 DMG..."
91+
echo "Signing X86_64 archive..."
8392
cargo packager signer sign \
8493
--private-key ${{ secrets.UPDATER_PRIVATE_KEY }} \
8594
--password ${{ secrets.UPDATER_KEY_PASSWORD }} \
86-
"$DMG_X86_64"
95+
"$ARCHIVE_X86_64"
8796
8897
- name: Create Update Manifests (update.json)
8998
run: |
9099
VERSION=${{ steps.package_version.outputs.version }}
91-
DMG_AARCH64="./target/release/MessAuto_${VERSION}_aarch64.dmg"
92-
DMG_X86_64="./target/x86_64-apple-darwin/release/MessAuto_${VERSION}_x64.dmg"
100+
ARCHIVE_AARCH64="./MessAuto_${VERSION}_aarch64.app.tar.gz"
101+
ARCHIVE_X86_64="./MessAuto_${VERSION}_x64.app.tar.gz"
93102
94103
# 为 aarch64 生成 update.json
95-
SIGNATURE_AARCH64=$(cat "${DMG_AARCH64}.sig")
104+
SIGNATURE_AARCH64=$(cat "${ARCHIVE_AARCH64}.sig")
96105
echo "{
97106
\"version\": \"${{ github.ref_name }}\",
98107
\"pub_date\": \"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\",
99-
\"url\": \"https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/MessAuto_${VERSION}_aarch64.dmg\",
108+
\"url\": \"https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/MessAuto_${VERSION}_aarch64.app.tar.gz\",
100109
\"signature\": \"$SIGNATURE_AARCH64\",
101110
\"format\": \"app\"
102111
}" > ./update-aarch64.json
103112
104113
# 为 x86_64 生成 update.json
105-
SIGNATURE_X86_64=$(cat "${DMG_X86_64}.sig")
114+
SIGNATURE_X86_64=$(cat "${ARCHIVE_X86_64}.sig")
106115
echo "{
107116
\"version\": \"${{ github.ref_name }}\",
108117
\"pub_date\": \"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\",
109-
\"url\": \"https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/MessAuto_${VERSION}_x64.dmg\",
118+
\"url\": \"https://github.com/${{ github.repository }}/releases/download/${{ github.ref_name }}/MessAuto_${VERSION}_x64.app.tar.gz\",
110119
\"signature\": \"$SIGNATURE_X86_64\",
111120
\"format\": \"app\"
112121
}" > ./update-x86_64.json
@@ -117,6 +126,8 @@ jobs:
117126
gh release upload ${{ github.ref_name }} \
118127
./target/release/MessAuto_${VERSION}_aarch64.dmg \
119128
./target/x86_64-apple-darwin/release/MessAuto_${VERSION}_x64.dmg \
129+
./MessAuto_${VERSION}_aarch64.app.tar.gz \
130+
./MessAuto_${VERSION}_x64.app.tar.gz \
120131
./update-aarch64.json \
121132
./update-x86_64.json
122133
env:

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "messauto"
3-
version = "1.0.1"
3+
version = "1.1.0"
44
edition = "2024"
55

66
[dependencies]

src/updater.rs

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ pub fn check_for_updates() {
3737
let current_version = match Version::parse(CURRENT_VERSION) {
3838
Ok(version) => version,
3939
Err(e) => {
40-
error!("{}", t!("updater.failed_to_parse_version", error = e.to_string()));
40+
error!(
41+
"{}",
42+
t!("updater.failed_to_parse_version", error = e.to_string())
43+
);
4144
return;
4245
}
4346
};
@@ -52,35 +55,57 @@ pub fn check_for_updates() {
5255

5356
match check_update(current_version, config) {
5457
Ok(Some(update)) => {
55-
info!("{}", t!("updater.new_version_found", version = update.version.to_string()));
58+
info!(
59+
"{}",
60+
t!(
61+
"updater.new_version_found",
62+
version = update.version.to_string()
63+
)
64+
);
5665
match download_update(update) {
5766
Ok((update_obj, update_bytes)) => {
5867
info!("{}", t!("updater.update_download_complete"));
5968
if show_install_notification(&update_obj.version) {
69+
let byc = update_bytes.clone();
6070
if let Err(e) = install_update(update_obj, update_bytes) {
61-
error!("{}", t!("updater.update_check_failed", error = e.to_string()));
71+
error!(
72+
"{}",
73+
t!("updater.update_check_failed", error = e.to_string())
74+
);
75+
// 输出 update_bytes 的前 100 可读数据
76+
info!(
77+
"update_bytes (first 64 bytes in hex): {:02x?}",
78+
&byc[..std::cmp::min(64, byc.len())]
79+
);
6280
}
6381
} else {
6482
info!("{}", t!("updater.user_canceled_update"));
6583
}
6684
}
6785
Err(e) => {
68-
error!("{}", t!("updater.update_download_failed", error = e.to_string()));
86+
error!(
87+
"{}",
88+
t!("updater.update_download_failed", error = e.to_string())
89+
);
6990
}
7091
}
7192
}
7293
Ok(None) => {
7394
info!("{}", t!("updater.already_up_to_date"));
7495
}
7596
Err(e) => {
76-
error!("{}", t!("updater.update_check_failed", error = e.to_string()));
97+
error!(
98+
"{}",
99+
t!("updater.update_check_failed", error = e.to_string())
100+
);
77101
}
78102
}
79103
});
80104
}
81105

82106
fn download_update(update: Update) -> Result<(Update, Vec<u8>), Box<dyn std::error::Error>> {
83107
info!("{}", t!("updater.downloading_update"));
108+
info!("{:?}", update.download_url);
84109

85110
let update_bytes = update.download()?;
86111
info!("{}", t!("updater.update_downloaded"));
@@ -99,7 +124,10 @@ fn install_update(update: Update, update_bytes: Vec<u8>) -> Result<(), Box<dyn s
99124
}
100125

101126
fn show_install_notification(version: &str) -> bool {
102-
info!("{}", t!("updater.new_version_downloaded", version = version));
127+
info!(
128+
"{}",
129+
t!("updater.new_version_downloaded", version = version)
130+
);
103131

104132
// 使用系统通知询问用户是否要安装更新
105133
let title = t!("updater.update_available");
@@ -109,7 +137,12 @@ fn show_install_notification(version: &str) -> bool {
109137
t!("updater.update_installed")
110138
);
111139

112-
let user_choice = notification::dialog(&title, &content, &t!("updater.install"), &t!("updater.user_chosen_later"));
140+
let user_choice = notification::dialog(
141+
&title,
142+
&content,
143+
&t!("updater.install"),
144+
&t!("updater.user_chosen_later"),
145+
);
113146

114147
if user_choice {
115148
info!("{}", t!("updater.user_chosen_install"));

0 commit comments

Comments
 (0)