-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (80 loc) · 3.12 KB
/
Copy pathci.yml
File metadata and controls
96 lines (80 loc) · 3.12 KB
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
name: 持续集成(构建与开发包)
on:
workflow_dispatch:
push:
branches: [main]
paths:
- 'src/module/**'
- 'src/webui/**'
- '.github/workflows/ci.yml'
- '.github/actions/build-module/**'
permissions:
contents: write
# 同一分支的新推送取消尚未完成的旧构建
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: 构建与发布开发包
runs-on: ubuntu-latest
steps:
- name: 拉取代码
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: 设置构建元信息
run: |
echo "TIMESTAMP=$(TZ='Asia/Shanghai' date +'%Y-%m-%d %H:%M:%S')" >> "$GITHUB_ENV"
echo "SHORT_HASH=${GITHUB_SHA::7}" >> "$GITHUB_ENV"
echo "COMMIT_MESSAGE=$(git log -1 --format=%s "$GITHUB_SHA")" >> "$GITHUB_ENV"
- name: 构建并打包模块
id: pack
uses: ./.github/actions/build-module
- name: 发布 Pre-release 到 GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# 删除已有的 nightly 发布和 Tag
gh release delete nightly --cleanup-tag -y || true
# 等待 API 状态同步
sleep 2
# 创建新的 nightly 发布并上传资产
gh release create nightly \
--prerelease \
--generate-notes \
--title "nightly Pre-release" \
--notes "同步最新代码变更,仅保留最新版本的构建产物。
版本: \`${{ steps.pack.outputs.version }}\` (build ${{ steps.pack.outputs.commit_count }})
构建时间: ${{ env.TIMESTAMP }}
提交: \`${{ env.SHORT_HASH }}\`" \
"${{ steps.pack.outputs.full_name }}" \
"${{ steps.pack.outputs.lite_name }}"
- name: Telegram 构建成功通知
if: success()
uses: cbrgm/telegram-github-action@v1
with:
token: ${{ secrets.TG_BOT_TOKEN }}
to: ${{ secrets.TG_CHAT_ID }}
thread-id: 2275
parse-mode: markdown
message: |
**持续集成构建成功**
版本: `${{ steps.pack.outputs.version }}` (build ${{ steps.pack.outputs.commit_count }})
说明: ${{ env.COMMIT_MESSAGE }}
[下载开发包](${{ github.server_url }}/${{ github.repository }}/releases/tag/nightly)
[提交记录](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
[构建日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
- name: 失败通知
if: failure()
uses: cbrgm/telegram-github-action@v1
with:
token: ${{ secrets.TG_BOT_TOKEN }}
to: ${{ secrets.TG_CHAT_ID }}
thread-id: 2275
parse-mode: markdown
message: |
**持续集成失败!**
提交: `${{ github.sha }}`
说明: ${{ env.COMMIT_MESSAGE }}
[点击查看构建日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})