diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 269a33a..712c9da 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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/* \ No newline at end of file diff --git a/generate-bundle.py b/generate-bundle.py index 38ff4e5..606f063 100644 --- a/generate-bundle.py +++ b/generate-bundle.py @@ -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) # 傻逼 # 狗屎代碼