Skip to content

Commit

Permalink
优化构建
Browse files Browse the repository at this point in the history
  • Loading branch information
lilingfengdev committed Jun 4, 2024
1 parent 4d3b383 commit 3a1bbbb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: ${{ matrix.os }}-latest
automatic_release_tag: ${{ matrix.os }}
prerelease: true
files: |
dist/*
22 changes: 18 additions & 4 deletions generate-bundle.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import os
import shutil
import urllib.request
import zipfile

import PyInstaller.__main__
import platform
if platform.system() == 'Windows':
urllib.request.urlretrieve("https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-win64.zip",
"upx.zip")
zip = zipfile.ZipFile("upx.zip")
zip.extract("upx/upx.exe", path=os.getcwd())
shutil.move("upx/upx.exe", os.path.join(os.getcwd(), "upx.exe"))
os.mkdir("dist")
for file in os.listdir(os.getcwd()):
if file != "utils.py" and file != "generate-bundle.py" and file.endswith(".py") and not os.path.isdir(file):
print(f"build {file}", flush=True)
PyInstaller.__main__.run(["-F", file, "--optimize", "2", "-i", "favicon.ico", "--exclude-module",
"charset_normalizer,_ctypes,_decimal,_hashlib,_bz2,_lzma,pyexpat,decimal,ctypes,"
"hashlib,bz2,lzma", ])

flag = ["-F", file, "--optimize", "2", "-i", "favicon.ico", "--exclude-module",
"charset_normalizer,_ctypes,_decimal,_hashlib,_bz2,_lzma,pyexpat,decimal,ctypes,"
"hashlib,bz2,lzma", ]
if platform.system() != 'Windows':
flag.append("--strip")
flag.append("--no-upx")
PyInstaller.__main__.run(flag)
# 傻逼
# 狗屎代碼

0 comments on commit 3a1bbbb

Please sign in to comment.