Skip to content

Commit 0ce9c95

Browse files
committed
计算md5
1 parent 95a1852 commit 0ce9c95

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

.github/workflows/Build and Release.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,15 @@ jobs:
9494
IS_PRERELEASE: ${{ steps.check_prerelease.outputs.is_prerelease }}
9595
run: |
9696
python3 -c "
97-
import re, json, os
97+
import re, json, os, hashlib
98+
99+
# 计算 APK MD5
100+
apk_path = 'app/build/outputs/apk/release/app-release.apk'
101+
if os.path.exists(apk_path):
102+
with open(apk_path, 'rb') as f:
103+
md5_hash = hashlib.md5(f.read()).hexdigest()
104+
else:
105+
md5_hash = 'APK_NOT_FOUND'
98106
99107
with open('app/build.gradle.kts', 'r') as f:
100108
content = f.read()
@@ -115,7 +123,8 @@ jobs:
115123
'versionCode': version_code,
116124
'versionName': version_name,
117125
'releaseNotes': changelog,
118-
'downloadUrl': 'https://github.com/badnng/Hyper-pick-up-code/releases/download/' + tag_name + '/app-release.apk'
126+
'downloadUrl': 'https://github.com/badnng/Hyper-pick-up-code/releases/download/' + tag_name + '/app-release.apk',
127+
'md5': md5_hash
119128
}
120129
121130
if is_prerelease == 'true':
@@ -141,26 +150,18 @@ jobs:
141150
FILES="Stable.json Dev.json"
142151
fi
143152
144-
# ====== 关键修复:用 git add -f 强制暂存,再 stash ======
145153
for f in $FILES; do
146154
git add -f $f
147155
done
148156
149-
# 把暂存的修改保存到 stash
150157
git stash push --include-untracked
151-
152-
# 切到 master
153158
git checkout -f master
154-
155-
# 把修改拿回来
156159
git stash pop
157160
158-
# 再 add 一次(stash pop 后文件是已修改状态)
159161
for f in $FILES; do
160162
git add $f
161163
done
162164
163-
# 调试:看看文件内容
164165
echo "=== 暂存区文件 ==="
165166
git diff --cached --stat
166167

0 commit comments

Comments
 (0)