chore: modify workflow scripts
calc hash for dist.
This commit is contained in:
parent
593c5f8f7f
commit
e512bd9e2a
2 changed files with 144 additions and 100 deletions
0
scripts/build.sh
Normal file → Executable file
0
scripts/build.sh
Normal file → Executable file
44
scripts/hash.sh
Executable file
44
scripts/hash.sh
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
#!/bin/bash
|
||||
|
||||
# 定义目标目录
|
||||
TARGET_DIR="$PWD/dist"
|
||||
|
||||
# 检查目录是否存在
|
||||
if [ ! -d "$TARGET_DIR" ]; then
|
||||
echo "Error: Directory $TARGET_DIR does not exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 输出表格表头
|
||||
echo "| Filename | SHA256 | Status |"
|
||||
echo "| :--- | :--- | :--- |"
|
||||
|
||||
# 遍历所有的 .tar.gz 文件
|
||||
for file in "$TARGET_DIR"/*.tar.gz; do
|
||||
# 检查是否有匹配的文件,防止 glob 失败
|
||||
[ -e "$file" ] || continue
|
||||
|
||||
filename=$(basename "$file")
|
||||
sha_file="${file}.sha256"
|
||||
|
||||
# 计算当前的 SHA256
|
||||
# 使用 awk 只取第一列(哈希值)
|
||||
actual_sha=$(sha256sum "$file" | awk '{print $1}')
|
||||
|
||||
# 校验逻辑
|
||||
if [ -f "$sha_file" ]; then
|
||||
# 从文件中读取预期的 SHA256
|
||||
expected_sha=$(cat "$sha_file" | awk '{print $1}')
|
||||
|
||||
if [ "$actual_sha" == "$expected_sha" ]; then
|
||||
status="✅ OK"
|
||||
else
|
||||
status="❌ Mismatch"
|
||||
fi
|
||||
else
|
||||
status="⚠️ No .sha256 file"
|
||||
fi
|
||||
|
||||
# 输出表格行
|
||||
echo "| $filename | \`$actual_sha\` | $status |"
|
||||
done
|
||||
Loading…
Add table
Reference in a new issue