Skip to content

Commit 43b531a

Browse files
committed
ci: add workflows
1 parent bd77558 commit 43b531a

File tree

4 files changed

+104
-1
lines changed

4 files changed

+104
-1
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Multi-Platform Build
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
build:
7+
strategy:
8+
matrix:
9+
os: [ubuntu-latest, macos-latest, windows-latest]
10+
runs-on: ${{ matrix.os }}
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.12'
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install -r requirements.txt
25+
pip install pyinstaller
26+
27+
- name: Build executable
28+
run: |
29+
if [[ "${{ runner.os }}" == "Windows" ]]; then
30+
pyinstaller --onefile --name myapp-${{ runner.os }}.exe src/app.py
31+
else
32+
pyinstaller --onefile --name myapp-${{ runner.os }} src/app.py
33+
fi
34+
35+
- name: Upload artifact
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: binaries-${{ runner.os }}
39+
path: dist/

.github/workflows/pylint.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# take from github推荐的模板
2+
3+
name: Pylint
4+
5+
on: [push]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
python-version: ["3.8", "3.9", "3.10"]
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
pip install pylint
23+
- name: Analysing the code with pylint
24+
run: |
25+
pylint $(git ls-files '*.py')
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# take from github推荐的模板
2+
3+
name: Python Package using Conda
4+
5+
on: [push]
6+
7+
jobs:
8+
build-linux:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
max-parallel: 5
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python 3.10
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: '3.10'
19+
- name: Add conda to system path
20+
run: |
21+
# $CONDA 是一个环境变量,指向miniconda目录的根目录
22+
echo $CONDA/bin >> $GITHUB_PATH
23+
- name: Install dependencies
24+
run: |
25+
conda env update --file environment.yml --name base
26+
- name: Lint with flake8
27+
run: |
28+
conda install flake8
29+
# 如果存在Python语法错误或未定义的名称,则停止构建
30+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
31+
# exit- 0将所有错误视为警告。GitHub编辑器是127字符宽
32+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
33+
- name: Test with pytest
34+
run: |
35+
conda install pytest
36+
pytest

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@ pip install -r .\requirements.txt # pip freeze > requirements.txt
3434
python main.py
3535

3636
# 可执行文件
37-
pyinstaller --onefile main.py
37+
pyinstaller --onefile main.py # 当前平台
38+
pyinstaller --onefile --name app-windows.exe main.py # 指定平台
39+
pyinstaller --onefile --name app-linux main.py
40+
pyinstaller --onefile --name app-macos main.py
3841
```

0 commit comments

Comments
 (0)