Skip to content

Commit 9d4c336

Browse files
committed
添加Actions
1 parent b5c7554 commit 9d4c336

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

.github/workflows/main.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Bundle with Pyinstaller
2+
on: push
3+
4+
jobs:
5+
frontend:
6+
runs-on: ubuntu-latest
7+
outputs:
8+
tag: ${{ steps.set_tag.outputs.tag }}
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
submodules: recursive
13+
14+
- id: set_tag
15+
run: |
16+
if ${{ startsWith(github.ref, 'refs/tags/v') }}; then
17+
echo "tag=${GITHUB_REF#refs/tags/v}" >> "$GITHUB_OUTPUT"
18+
else
19+
echo "tag=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
20+
fi
21+
22+
- uses: actions/setup-node@v3
23+
with:
24+
node-version: 16
25+
26+
- name: Build Frontend
27+
working-directory: frontend
28+
run: |
29+
npm install
30+
npm run build
31+
32+
- name: Upload Artifact
33+
uses: actions/upload-artifact@v3
34+
with:
35+
name: frontend
36+
path: frontend/dist
37+
38+
backend:
39+
needs: frontend
40+
strategy:
41+
matrix:
42+
os: [macos, ubuntu, windows]
43+
runs-on: ${{ matrix.os }}-latest
44+
steps:
45+
- uses: actions/checkout@v3
46+
with:
47+
submodules: recursive
48+
49+
- name: Download Frontend
50+
uses: actions/download-artifact@v3
51+
with:
52+
name: frontend
53+
path: frontend/dist
54+
55+
- name: Install Dependencies
56+
run: pip3 install -r requirements.txt
57+
58+
- name: Bundle blivechat (Unix)
59+
if: matrix.os != 'windows'
60+
run: |
61+
pip3 install pyinstaller
62+
pyinstaller --noconfirm \
63+
--add-data="data:data" \
64+
--add-data="log:log" \
65+
--add-data="frontend/dist:frontend/dist" \
66+
--name blivechat \
67+
main.py
68+
69+
- name: Bundle blivechat (Windows)
70+
if: matrix.os == 'windows'
71+
run: |
72+
pip3 install pyinstaller
73+
pyinstaller --noconfirm `
74+
--add-data="data;data" `
75+
--add-data="log;log" `
76+
--add-data="frontend\dist;frontend\dist" `
77+
--name blivechat `
78+
main.py
79+
80+
- name: Package Bundle
81+
working-directory: dist
82+
run: 7z a -tzip blivechat-${{ needs.frontend.outputs.tag }}-${{ matrix.os }}-x64.zip blivechat
83+
84+
- name: Upload Artifact
85+
uses: actions/upload-artifact@v3
86+
with:
87+
name: blivechat-${{ matrix.os }}-x64
88+
path: dist/blivechat-*.zip
89+
90+
release:
91+
needs: backend
92+
if: startsWith(github.ref, 'refs/tags/')
93+
runs-on: ubuntu-latest
94+
permissions:
95+
contents: write
96+
steps:
97+
- name: Download Artifact
98+
uses: actions/download-artifact@v3
99+
100+
- name: Create Release
101+
uses: softprops/action-gh-release@v1
102+
with:
103+
files: ./**/blivechat-*.zip

0 commit comments

Comments
 (0)