commit 7ab983ceb03f4f4aaf901d55b590a41ee42b6c50 Author: hy <1048382248@qq.com> Date: Fri Apr 26 17:55:11 2024 +0800 添加 action.yaml diff --git a/action.yaml b/action.yaml new file mode 100644 index 0000000..ed31e17 --- /dev/null +++ b/action.yaml @@ -0,0 +1,36 @@ +name: shell_hash +description: 获取文件哈希 + +inputs: + file_array: + required: true + description: 文件路径 + +outputs: + hash: + description: 文件哈希 + value: ${{ steps.get_hash.outputs.res }} + +runs: + using: composite + steps: + - name: 获取最新发布版本号 + id: get_hash + shell: bash + run: | + # 初始化 res 变量 + res="" + fileStr =${{inputs.file_array}} + # 读取 fileStr 变量中的每一行文件路径 + while IFS= read -r filepath; do + # 获取文件的 MD5 哈希值 + file_hash=$(md5sum "$filepath" | awk '{print $1}') + # 将哈希值追加到 res 变量中 + res+="$file_hash" + done <<< "$fileStr" + + # 计算 res 的哈希值 + final_hash=$(echo -n "$res" | md5sum | awk '{print $1}') + + echo "res=$final_hash" >> "$GITHUB_OUTPUT" + echo "final_hash=$final_hash" \ No newline at end of file