mirror of
https://github.com/CCLeonOS/LeonOS.git
synced 2026-03-03 15:17:01 +00:00
Update release-auto-commit.yml
This commit is contained in:
20
.github/workflows/release-auto-commit.yml
vendored
20
.github/workflows/release-auto-commit.yml
vendored
@@ -16,21 +16,11 @@ jobs:
|
|||||||
- name: Get previous release tag
|
- name: Get previous release tag
|
||||||
id: prev_tag
|
id: prev_tag
|
||||||
run: |
|
run: |
|
||||||
# 强制获取所有标签(防止标签未被拉取)
|
# 获取上一个标签或初始commit
|
||||||
git fetch --tags
|
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || git rev-list --max-parents=0 HEAD)
|
||||||
|
|
||||||
# 尝试获取上一个标签
|
# 按照建议:清理值中的换行和回车符,使用printf确保格式正确
|
||||||
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null)
|
printf "prev_tag=%s\n" "$(echo "$PREV_TAG" | tr -d '\n' | tr -d '\r')" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
# 严格验证是否为有效标签(非空且存在于标签列表中)
|
|
||||||
if [ -n "$PREV_TAG" ] && git tag --list | grep -q "^$PREV_TAG$"; then
|
|
||||||
: # 有效标签,不做处理
|
|
||||||
else
|
|
||||||
PREV_TAG="initial-commit"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# 彻底清理输出值(移除所有特殊字符)
|
|
||||||
echo "prev_tag=$(echo "$PREV_TAG" | tr -d '\n')" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
- name: Generate commit log
|
- name: Generate commit log
|
||||||
id: commit_log
|
id: commit_log
|
||||||
@@ -41,7 +31,7 @@ jobs:
|
|||||||
COMMIT_LOG=$(git log ${{ steps.prev_tag.outputs.prev_tag }}..HEAD --pretty=format:"- [%h] %s" --reverse)
|
COMMIT_LOG=$(git log ${{ steps.prev_tag.outputs.prev_tag }}..HEAD --pretty=format:"- [%h] %s" --reverse)
|
||||||
fi
|
fi
|
||||||
COMMIT_LOG="${COMMIT_LOG//$'\n'/\\n}"
|
COMMIT_LOG="${COMMIT_LOG//$'\n'/\\n}"
|
||||||
echo "commit_log=$COMMIT_LOG" >> "$GITHUB_OUTPUT"
|
printf "commit_log=%s\n" "$COMMIT_LOG" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Update release notes
|
- name: Update release notes
|
||||||
uses: actions/github-script@v7
|
uses: actions/github-script@v7
|
||||||
|
|||||||
Reference in New Issue
Block a user