forked from MaaAssistantArknights/MaaAssistantArknights
-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (81 loc) · 3.28 KB
/
gen-changelog.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: gen-changelog
on:
pull_request:
types:
- opened
- reopened
- ready_for_review
workflow_dispatch:
jobs:
gen:
# startsWith 表达式不区分大小写
if: github.event.pull_request.draft == false && startsWith(github.event.pull_request.title, 'Release v')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
show-progress: false
- name: Extract tag name
id: extract_tag
env:
PR_BODY: ${{ format('{0}/{1}', runner.temp, 'output' ) }}
run: |
tag_name=$(echo "${{ github.event.pull_request.title }}" | sed -E 's/(Release|release)//' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
echo "tag_name=$tag_name" >> $GITHUB_OUTPUT
pr_title="docs: Auto Update Changelogs of "$tag_name
echo "pr_title=$pr_title" >> $GITHUB_OUTPUT
latest_stable_tag=$(git tag -l 'v*' | grep -v '-' | sort -V | tail -n 1) # 上一个 stable 版本
newest_tag=$(git describe --tags --match "v*" --abbrev=0) # 最新版本
echo "latest_stable_tag=$latest_stable_tag" >> $GITHUB_OUTPUT
echo "newest_tag=$newest_tag" >> $GITHUB_OUTPUT
if [[ $tag_name == *-* ]]; then # 判断新版本是否为 beta 版本
latest=$newest_tag # 若是,则将 latest 参数设置为最新版本
else
latest=$latest_stable_tag # 若否,则设置为上一个 stable 版本
fi
echo "latest=$latest" >> $GITHUB_OUTPUT
cat $GITHUB_OUTPUT
echo '======='
echo 'Target RP: ${{ github.event.pull_request.html_url }}' >> $PR_BODY
echo '' >> $PR_BODY
echo '<details><summary>Debug info</summary>' >> $PR_BODY
echo '' >> $PR_BODY
echo '```' >> $PR_BODY
sed 's/=/: /1' $GITHUB_OUTPUT >> $PR_BODY
echo '```' >> $PR_BODY
echo '' >> $PR_BODY
echo '</details>' >> $PR_BODY
cat $PR_BODY
- name: Generate Changelog
run: |
git switch dev
python3 tools/ChangelogGenerator/changelog_generator.py --tag "${{ steps.extract_tag.outputs.tag_name }}" --latest "${{ steps.extract_tag.outputs.latest }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add files to git
run: |
git status
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add .
commit_msg="docs: Auto Generate Changelog of Release ""${{ steps.extract_tag.outputs.tag_name }}"
git commit -m "$commit_msg"
- name: Create PR
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: ${{ steps.extract_tag.outputs.pr_title }}
body-path: ${{ format('{0}/{1}', runner.temp, 'output' ) }}
base: "dev"
branch: "changelog"
delete-branch: true
reviewers: |
AnnAngela
assignees: |
AnnAngela
- name: Add reviewers to release PR
uses: kentaro-m/auto-assign-action@v2.0.0
with:
configuration-path: ".github/release_reviewers.yaml"