-
Notifications
You must be signed in to change notification settings - Fork 2
142 lines (123 loc) · 4.22 KB
/
build.yml
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
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Build and Package ProjectExportTool
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12' # 根据你的需要设置Python版本
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller PyQt5
- name: Get current version
id: get_version
run: echo "CURRENT_VERSION=$(cat version.txt)" >> $GITHUB_ENV
- name: Increment version
id: increment_version
run: |
CURRENT_VERSION=$(cat version.txt)
NEW_VERSION=$(echo $CURRENT_VERSION | awk -F. '{$NF = $NF + 1;} 1' | sed 's/ /./g')
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo $NEW_VERSION > version.txt
- name: Commit new version
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git add version.txt
git commit -m "Bump version to ${{ env.NEW_VERSION }}"
git push origin main
- name: Create and modify spec file
run: |
pyinstaller --name ProjectExportTool --windowed --onefile main_for_mac.py
# 修改.spec文件
sed -i '' 's/console=True/console=False/' ProjectExportTool.spec
cat << 'EOF' >> ProjectExportTool.spec
block_cipher = None
a = Analysis(
['main_for_mac.py'],
pathex=[],
binaries=[],
datas=[('HarmonyOS_Sans_SC_Regular.ttf', '.')],
hiddenimports=['PyQt5', 'PyQt5.QtWidgets', 'PyQt5.QtGui', 'PyQt5.QtCore'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='ProjectExportTool',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False)
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='ProjectExportTool')
app = BUNDLE(
coll,
name='ProjectExportTool.app',
icon=None,
bundle_identifier=None
)
EOF
- name: Clean output directory
run: rm -rf /Users/runner/work/Project_Exporter/Project_Exporter/dist/ProjectExportTool.app
- name: Run PyInstaller
run: pyinstaller -y ProjectExportTool.spec
- name: Create DMG
run: |
mkdir ProjectExportTool_temp
mv dist/ProjectExportTool.app ProjectExportTool_temp/
hdiutil create -volname ProjectExportTool -srcfolder ProjectExportTool_temp -ov -format UDZO ProjectExportTool.dmg
- name: Upload DMG as artifact
uses: actions/upload-artifact@v2
with:
name: ProjectExportTool-dmg
path: ProjectExportTool.dmg
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.NEW_VERSION }}
release_name: ProjectExportTool Release ${{ env.NEW_VERSION }}
body: |
Release of ProjectExportTool version ${{ env.NEW_VERSION }}.
draft: false
prerelease: false
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ProjectExportTool.dmg
asset_name: ProjectExportTool.dmg
asset_content_type: application/octet-stream