-
Notifications
You must be signed in to change notification settings - Fork 1
129 lines (114 loc) · 3.77 KB
/
build.yml
File metadata and controls
129 lines (114 loc) · 3.77 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Build & Release Multi-Platform Binaries
on:
workflow_dispatch:
inputs:
version:
description: '版本号(例如:v1.0.0)'
required: true
type: string
publish_release:
description: '是否发布到GitHub Releases'
required: true
type: boolean
default: false
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
include:
- os: ubuntu-latest
system: linux
ext: ''
asset-name: PhiChartSearch_${{ github.event.inputs.version }}_linux_x64
- os: windows-latest
system: windows
ext: '.exe'
asset-name: PhiChartSearch_${{ github.event.inputs.version }}_windows_x64.exe
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller
pip install -r requirements.txt
- name: Check font file (Linux)
run: |
if [ -f "Source Han Sans & Saira Hybrid-Regular #2934.ttf" ]; then
echo "Font file found"
else
echo "Error: Font file not found!" && exit 1
fi
if: matrix.os == 'ubuntu-latest'
shell: bash
- name: Check font file (Windows)
run: |
if exist "Source Han Sans & Saira Hybrid-Regular #2934.ttf" (
echo Font file found
) else (
echo Error: Font file not found! && exit 1
)
if: matrix.os == 'windows-latest'
shell: cmd
- name: Build & rename (Linux)
run: |
pyinstaller --onefile --windowed --name="PhiChartSearch" \
--add-data "Source Han Sans & Saira Hybrid-Regular #2934.ttf:." \
ChartAnalyzer.py
ls -l dist/
mv dist/PhiChartSearch "dist/${{ matrix.asset-name }}"
ls -l dist/
if: matrix.os == 'ubuntu-latest'
shell: bash
- name: Build & rename (Windows)
run: |
pyinstaller --onefile --windowed --name="PhiChartSearch" ^
--add-data "Source Han Sans & Saira Hybrid-Regular #2934.ttf;." ^
ChartAnalyzer.py
dir dist\
ren "dist\PhiChartSearch.exe" "${{ matrix.asset-name }}"
dir dist\
if: matrix.os == 'windows-latest'
shell: cmd # 严格使用cmd语法
- name: Upload binary artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset-name }}
path: dist/${{ matrix.asset-name }}
if-no-files-found: error
release:
needs: build
if: ${{ github.event.inputs.publish_release == 'true' }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
merge-multiple: true
- name: List downloaded artifacts
run: |
ls -lR ./artifacts
shell: bash
- name: Upload to Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.version }}
name: Release ${{ github.event.inputs.version }}
body_path: release.md
files: |
./artifacts/PhiChartSearch_${{ github.event.inputs.version }}_linux_x64
./artifacts/PhiChartSearch_${{ github.event.inputs.version }}_windows_x64.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}