|
14 | 14 | steps: |
15 | 15 | - name: Checkout Repository |
16 | 16 | uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
17 | 19 |
|
18 | 20 | - name: Setup Node.js |
19 | 21 | uses: actions/setup-node@v4 |
@@ -60,18 +62,29 @@ jobs: |
60 | 62 | - name: Get Previous Tag |
61 | 63 | id: prev_tag |
62 | 64 | run: | |
63 | | - tag=$(git tag --sort=-creatordate | grep '^v' | grep -v "${{ steps.get_version.outputs.version }}" | head -n1 || echo "none") |
| 65 | + # 获取所有v开头的标签,按版本排序,排除当前版本 |
| 66 | + current_version="${{ steps.get_version.outputs.version }}" |
| 67 | + tag=$(git tag -l 'v*' --sort=-version:refname | grep -v "^${current_version}$" | head -n1 || echo "none") |
| 68 | + echo "Current version: $current_version" |
| 69 | + echo "Previous tag found: $tag" |
64 | 70 | echo "previous_tag=$tag" >> $GITHUB_OUTPUT |
65 | 71 |
|
66 | 72 | - name: Generate Release Notes |
67 | 73 | id: release_notes |
68 | 74 | run: | |
69 | | - echo "🔄 更新日志(${{ steps.prev_tag.outputs.previous_tag }} → ${{ steps.get_version.outputs.version }})" > release.md |
70 | | - echo "" >> release.md |
71 | 75 | if [ "${{ steps.prev_tag.outputs.previous_tag }}" != "none" ]; then |
| 76 | + echo "🔄 更新日志(${{ steps.prev_tag.outputs.previous_tag }} → ${{ steps.get_version.outputs.version }})" > release.md |
| 77 | + echo "" >> release.md |
| 78 | + echo "## 📝 变更内容" >> release.md |
| 79 | + echo "" >> release.md |
72 | 80 | git log ${{ steps.prev_tag.outputs.previous_tag }}..HEAD --pretty=format:'- [%s](https://github.com/${{ github.repository }}/commit/%H) by @%an' >> release.md |
73 | 81 | else |
74 | | - git log --pretty=format:'- [%s](https://github.com/${{ github.repository }}/commit/%H) by @%an' >> release.md |
| 82 | + echo "🔄 更新日志(首次发布 ${{ steps.get_version.outputs.version }})" > release.md |
| 83 | + echo "" >> release.md |
| 84 | + echo "## 📝 变更内容" >> release.md |
| 85 | + echo "" >> release.md |
| 86 | + echo "- 🎉 首次发布版本" >> release.md |
| 87 | + echo "- 📦 包含所有核心功能" >> release.md |
75 | 88 | fi |
76 | 89 | echo "release_body<<EOF" >> $GITHUB_OUTPUT |
77 | 90 | cat release.md >> $GITHUB_OUTPUT |
|
0 commit comments