Skip to content

Commit 2329ea2

Browse files
committed
feat:build cicd
1 parent fa527a5 commit 2329ea2

1 file changed

Lines changed: 139 additions & 9 deletions

File tree

.github/workflows/build_linux_only.yml

Lines changed: 139 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,167 @@ on:
44
workflow_dispatch:
55
push:
66
tags:
7-
- 'build.*'
7+
- "build.*"
88

99
jobs:
1010
build_x86_64:
1111
name: Build for x86_64
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v2
15+
uses: actions/checkout@v4
1616
with:
1717
repository: dataelement/bisheng-telemetry-search
1818
token: ${{ secrets.CROSS_REPO_TOKEN }}
1919
path: bisheng-telemetry-search
2020

2121
- name: Set up Python
22-
uses: actions/setup-python@v4
22+
uses: actions/setup-python@v5
2323
with:
2424
python-version: '3.10'
2525

2626
- name: Install build dependencies
2727
run: |
28-
apt-get update
29-
apt-get install -y build-essential
28+
sudo apt-get update
29+
sudo apt-get install -y build-essential
3030
pip install --upgrade pip setuptools wheel
3131
pip install cython
3232
33-
- name: Build the project
34-
working-directory: ./bisheng-telemetry-search
33+
- name: Build and Clean Artifacts
34+
working-directory: ./bisheng-telemetry-search/telemetry_search
3535
run: |
36+
# 执行构建
3637
python build_all.py --delete-source
37-
ls -lh
3838
39-
39+
# 在上传前彻底清理源代码和中间文件
40+
# 即使 build_all.py 做了清理,这里再次强制清理,防止 .c 文件泄露
41+
find . -name "*.c" -delete
42+
find . -name "*.cpp" -delete
43+
find . -name "__pycache__" -exec rm -rf {} +
44+
rm -rf ./build
45+
rm -f build_all.py setup.py # 删除构建脚本本身
4046
47+
# 准备输出
48+
mkdir ../../build_output
49+
cp -r ./* ../../build_output/
50+
51+
echo "Listing artifacts to be uploaded:"
52+
ls -R ../../build_output/
53+
54+
- name: Upload x86_64 build artifacts
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: telemetry_search-x86_64
58+
path: ./build_output/*
59+
60+
build_arm:
61+
name: Build for ARM
62+
runs-on: ubuntu-22.04-arm
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v4
66+
with:
67+
repository: dataelement/bisheng-telemetry-search
68+
token: ${{ secrets.CROSS_REPO_TOKEN }}
69+
path: bisheng-telemetry-search
70+
71+
- name: Set up Python
72+
uses: actions/setup-python@v5
73+
with:
74+
python-version: '3.10'
75+
76+
- name: Install build dependencies
77+
run: |
78+
sudo apt-get update
79+
sudo apt-get install -y build-essential
80+
pip install --upgrade pip setuptools wheel
81+
pip install cython
82+
83+
- name: Build and Clean Artifacts
84+
working-directory: ./bisheng-telemetry-search/telemetry_search
85+
run: |
86+
# 1. 执行构建
87+
python build_all.py --delete-source
88+
89+
# 2. [关键] 强制清理 .c / .cpp / __pycache__
90+
find . -name "*.c" -delete
91+
find . -name "*.cpp" -delete
92+
find . -name "__pycache__" -exec rm -rf {} +
93+
rm -rf ./build
94+
rm -f build_all.py setup.py
95+
96+
# 3. 准备输出
97+
mkdir ../../build_output
98+
cp -r ./* ../../build_output/
99+
100+
echo "Listing artifacts to be uploaded:"
101+
ls -R ../../build_output/
102+
103+
- name: Upload ARM build artifacts
104+
uses: actions/upload-artifact@v4
105+
with:
106+
name: telemetry_search-arm
107+
path: ./build_output/*
108+
109+
deploy_to_sso_project:
110+
name: Deploy Artifacts to SSO Project
111+
needs: [ build_x86_64, build_arm ]
112+
runs-on: ubuntu-latest
113+
steps:
114+
- name: Checkout SSO Project
115+
uses: actions/checkout@v4
116+
with:
117+
repository: dataelement/bisheng
118+
token: ${{ secrets.CROSS_REPO_TOKEN }}
119+
# 使用 ref 指定分支,而不是 base
120+
ref: feat/2.3.0
121+
path: bisheng
122+
# 确保拉取完整的历史以便正确提交
123+
fetch-depth: 0
124+
125+
- name: Download x86_64 build artifacts
126+
uses: actions/download-artifact@v4
127+
with:
128+
name: telemetry_search-x86_64
129+
path: ./telemetry_search_x86_64
130+
131+
- name: Download ARM build artifacts
132+
uses: actions/download-artifact@v4
133+
with:
134+
name: telemetry_search-arm
135+
path: ./telemetry_search_arm
136+
137+
- name: Merge and Place Files
138+
run: |
139+
# 创建临时合并目录
140+
mkdir -p ./telemetry_search
141+
142+
# 先复制 x86_64 文件
143+
cp -r ./telemetry_search_x86_64/* ./telemetry_search/
144+
145+
# 再复制 ARM 文件 (不会覆盖 .so,因为文件名包含架构信息;会覆盖 .py,但应该是一样的)
146+
cp -r ./telemetry_search_arm/* ./telemetry_search/
147+
148+
find ./telemetry_search -name "*.c" -delete
149+
150+
# 移动到目标仓库目录
151+
cp -r ./telemetry_search ./bisheng/src/backend/bisheng/
152+
153+
echo "Final content of target directory:"
154+
ls -lh ./bisheng/src/backend/bisheng/telemetry_search
155+
156+
- name: Commit and Push changes
157+
working-directory: ./bisheng
158+
run: |
159+
git config --global user.name "github-actions[bot]"
160+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
161+
162+
git add .
163+
164+
# 检查是否有变更,有才提交
165+
if git diff --staged --quiet; then
166+
echo "No changes to commit"
167+
else
168+
git commit -m "chore: update telemetry_search build artifacts [skip ci]"
169+
git push origin feat/2.3.0
170+
fi

0 commit comments

Comments
 (0)