Skip to content

Commit 2722df9

Browse files
committed
👷 ci: 添加GitHub Actions构建和发布工作流
添加CI/CD工作流,用于在推送标签或主分支时自动构建SimpleCutPy应用并发布版本。工作流包括Python环境设置、FFmpeg安装、依赖安装、PyInstaller构建以及创建发布版本和上传构建产物。
1 parent 9116ae3 commit 2722df9

File tree

2 files changed

+87
-2
lines changed

2 files changed

+87
-2
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Build and Release SimpleCutPy
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
build:
15+
runs-on: windows-latest
16+
17+
steps:
18+
- uses: actions/checkout@v3
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: "3.12"
24+
25+
- name: Install FFmpeg
26+
uses: FedericoCarboni/setup-ffmpeg@v2
27+
with:
28+
ffmpeg-version: "6.0"
29+
architecture: "x64"
30+
31+
- name: Install dependencies
32+
run: |
33+
python -m pip install --upgrade pip
34+
pip install -e .
35+
pip install pyinstaller
36+
37+
- name: Build with PyInstaller
38+
run: |
39+
pyinstaller SimpleCutPy.spec
40+
41+
- name: Upload build artifacts
42+
uses: actions/upload-artifact@v3
43+
with:
44+
name: SimpleCutPy-build
45+
path: dist/SimpleCutPy/
46+
47+
release:
48+
needs: build
49+
runs-on: windows-latest
50+
if: startsWith(github.ref, 'refs/tags/')
51+
52+
steps:
53+
- uses: actions/checkout@v3
54+
55+
- name: Download build artifacts
56+
uses: actions/download-artifact@v3
57+
with:
58+
name: SimpleCutPy-build
59+
path: dist/SimpleCutPy/
60+
61+
- name: Create zip archive
62+
run: |
63+
cd dist
64+
7z a -tzip SimpleCutPy-${{ github.ref_name }}.zip SimpleCutPy/
65+
66+
- name: Create Release
67+
id: create_release
68+
uses: actions/create-release@v1
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
with:
72+
tag_name: ${{ github.ref_name }}
73+
release_name: Release ${{ github.ref_name }}
74+
draft: false
75+
prerelease: false
76+
77+
- name: Upload Release Asset
78+
uses: actions/upload-release-asset@v1
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
with:
82+
upload_url: ${{ steps.create_release.outputs.upload_url }}
83+
asset_path: dist/SimpleCutPy-${{ github.ref_name }}.zip
84+
asset_name: SimpleCutPy-${{ github.ref_name }}.zip
85+
asset_content_type: application/zip

SimpleCutPy.spec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33

44
a = Analysis(
5-
['src\\main.py'],
6-
pathex=['src', '.venv/Lib/site-packages'],
5+
['src\main.py'],
6+
pathex=['src'],
77
binaries=[],
88
datas=[],
99
hiddenimports=['wx', 'src', 'pymediainfo'],

0 commit comments

Comments
 (0)