diff --git a/.github/diy/test.sh b/.github/diy/test.sh new file mode 100755 index 0000000..3ff24e1 --- /dev/null +++ b/.github/diy/test.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# 假设您的插件版本号可以通过执行命令来获取,例如 sing-box version +PLUGIN_VERSION=$(${{ matrix.pakcages }} version | grep "$PKG_VERSION") + +# 将版本号输出到标准输出 +echo "$PLUGIN_VERSION" diff --git a/.github/workflows/litte.yml b/.github/workflows/litte.yml index 97f3134..50ae5e0 100644 --- a/.github/workflows/litte.yml +++ b/.github/workflows/litte.yml @@ -51,14 +51,27 @@ jobs: bash /$GITHUB_WORKSPACE/.github/diy/create_acl_for_luci.sh -a bash /$GITHUB_WORKSPACE/.github/diy/Modify.sh - - name: Upload - env: + - name: Get Plugin Versions + id: get_versions + run: | + cd $GITHUB_WORKSPACE/.github/diy/ + chmod +x test.sh + PLUGIN_VERSION=$("./test.sh") # 执行脚本并获取输出 + echo "::set-output name=plugin_version::$PLUGIN_VERSION" # 将版本号设置为输出变量 + + - name: Check and Commit New Versions + env: ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} run: | cd $GITHUB_WORKSPACE/${{matrix.target}} if git status --porcelain | grep .; then + PLUGIN_VERSION="${{ steps.get_versions.outputs.plugin_version }}" + + # 设置提交消息为自定义格式,包括插件版本号 + COMMIT_MESSAGE="${{matrix.target}}: update to $PLUGIN_VERSION" + git add . - git commit -am "update $(date '+%Y-%m-%d %H:%M:%S')" + git commit -m "$COMMIT_MESSAGE" git push --quiet "https://${{ secrets.ACCESS_TOKEN }}@github.com/kenzok8/litte.git" HEAD:${{matrix.target}} else echo "nothing to commit"