File tree Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Expand file tree Collapse file tree 1 file changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ on :
2
+ push :
3
+ # Sequence of patterns matched against refs/tags
4
+ tags :
5
+ - ' v*' # Push events to matching v*, i.e. v1.0, v20.15.10
6
+
7
+ name : Create Release
8
+ permissions : write-all
9
+
10
+ jobs :
11
+ release :
12
+ runs-on : ubuntu-latest
13
+ steps :
14
+ - name : Checkout code
15
+ uses : actions/checkout@v4
16
+ with :
17
+ fetch-depth : 0
18
+
19
+ - name : Setup Node.js
20
+ uses : actions/setup-node@v4
21
+ with :
22
+ node-version : 18
23
+
24
+ - name : Install dependencies
25
+ run : npm install -g gen-git-log
26
+
27
+ - name : Find Last Tag
28
+ id : last_tag
29
+ run : |
30
+
31
+ # 获取所有标签,按版本排序(降序)
32
+ Tags=$(git tag --list --sort=-version:refname)
33
+
34
+ # 获取最新的标签(即列表中的第一个)
35
+ LATEST_TAG=$(echo "$Tags" | awk 'NR==1 {print $1; exit}')
36
+
37
+ # 获取倒数第二个标签(如果存在)
38
+ if [[ -n "$Tags" ]]; then
39
+ # 使用 tail 获取除了最后一个标签之外的所有标签,然后用 head 获取第一个
40
+ SECOND_LATEST_TAG=$(echo "$Tags" | tail -n +2 | head -n 1)
41
+ else
42
+ SECOND_LATEST_TAG=""
43
+ fi
44
+
45
+ # 设置输出变量
46
+ echo "::set-output name=tag_last::${LATEST_TAG:-v1.0.0}"
47
+ echo "::set-output name=tag_second::${SECOND_LATEST_TAG:-v1.0.0}"
48
+
49
+ - name : Generate Release Notes
50
+ run : |
51
+ rm -rf log
52
+ newTag=${{ steps.last_tag.outputs.tag_last }}
53
+ git-log -m tag -f -S ${{ steps.last_tag.outputs.tag_second }} -v ${newTag#v}
54
+
55
+ - name : Create Release
56
+ id : create_release
57
+ uses : actions/create-release@v1
58
+ env :
59
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
60
+ with :
61
+ tag_name : ${{ steps.last_tag.outputs.tag_last }}
62
+ release_name : Release ${{ steps.last_tag.outputs.tag_last }}
63
+ body_path : log/${{steps.last_tag.outputs.tag_last}}.md
64
+ draft : false
65
+ prerelease : false
You can’t perform that action at this time.
0 commit comments