-
Notifications
You must be signed in to change notification settings - Fork 5
75 lines (67 loc) · 2.7 KB
/
master.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
name: Create Release on Push
on:
push:
branches:
- master
jobs:
create-release:
name: Create Release
runs-on: ubuntu-latest
steps:
# 检出仓库代码
- name: Checkout repository
uses: actions/checkout@v3
# 获取正确的版本号 commit 信息
- name: Get commit info
id: commit_info
run: |
COMMIT_MSG=$(git log --pretty=format:"%s" | grep -E "^[0-9]+\.[0-9]+v[0-9]+$" | head -n 1)
if [ -z "$COMMIT_MSG" ]; then
echo "No valid tag found. Exiting workflow."
exit 0
fi
echo "::set-output name=message::${COMMIT_MSG}"
# 安装 zip 工具
- name: Install zip
run: sudo apt-get install -y zip
# 创建 ElysianRealm-Data 压缩包
- name: Create ElysianRealm-Data.zip
run: |
mkdir ElysianRealm-Data
find . -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.gif' \) -exec cp {} ElysianRealm-Data/ \;
zip -r ElysianRealm-Data.zip ElysianRealm-Data
# 根据标签生成 Release 内容
- name: Generate release content
id: generate_content
run: |
if [[ "${{ steps.commit_info.outputs.message }}" == *v1 ]]; then
RELEASE_BODY="### 使用 \`/更新乐土攻略\` 后可直接复制下面命令添加 \`XX乐土\` 唤醒词\n\n"
RELEASE_BODY+=" - XX\n"
RELEASE_BODY+="\`/RealmCommand add ImageName XX乐土\`\n"
RELEASE_BODY+="\`/RealmCommand add ImageName_AstralRing XX乐土2,XX星环流\`\n\n"
RELEASE_BODY+="> 指令内容[请]阅读[README.md](https://github.com/MskTim/Bh3-ElysianRealm-Strategy/blob/master/README.md)"
else
RELEASE_BODY="> 推荐使用 \`/更新乐土攻略\` 指令获取攻略"
fi
echo "::set-output name=release_body::${RELEASE_BODY}"
# 创建 Release 草稿
- name: Create release draft
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.commit_info.outputs.message }}
release_name: ${{ steps.commit_info.outputs.message }}整合包
draft: true
body: ${{ steps.generate_content.outputs.release_body }}
# 上传压缩包至 Release
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ElysianRealm-Data.zip
asset_name: ElysianRealm-Data.zip
asset_content_type: application/zip