This commit is contained in:
jock
2025-06-09 15:45:09 +08:00
parent e59fa1ac93
commit ba32b45e75
5 changed files with 51 additions and 38 deletions
@@ -1,4 +1,4 @@
name: Build Windows Executable with PyInstaller
name: Build and Release
# 触发工作流的事件
on:
@@ -7,9 +7,12 @@ on:
- 'v*'
jobs:
build-windows:
build-and-release:
# 使用 Windows 运行环境
runs-on: windows-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest, macos-latest ]
steps:
# 检出代码
@@ -20,37 +23,45 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12.8' # 保持用户指定的 Python 版本
architecture: 'x64'
python-version: '3.12.8'
# 安装依赖和 PyInstaller
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if (Test-Path requirements.txt) { pip install -r requirements.txt }
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install pyinstaller
shell: pwsh
shell: bash
# 运行 PyInstaller 打包
- name: Build executable
- name: Build with PyInstaller
run: |
pyinstaller -y --clean -D -c -n wxdown-service --add-data=resources/credential.py:resources/ main.py
shell: pwsh
shell: bash
# 调试:列出 dist/ 目录内容
- name: List dist directory
run: |
Get-ChildItem -Path dist -Recurse
shell: pwsh
ls -al
shell: bash
# 压缩 dist/wxdown-service/ 为 wxdown-service.zip
- name: Create zip archive
- name: Zip the bundle
if: runner.os == 'Windows'
run: |
Compress-Archive -Path dist/wxdown-service/* -DestinationPath wxdown-service-windows.zip
shell: pwsh
- name: Zip the bundle
if: runner.os == 'macOS'
run: |
zip -r wxdown-service-macos.zip dist/wxdown-service
shell: bash
# 上传打包结果
- name: Upload release assets
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
files: wxdown-service-windows.zip
files: |
wxdown-service-windows.zip
wxdown-service-macos.zip
+24
View File
@@ -0,0 +1,24 @@
import platform
import subprocess
def is_certificate_installed(cert_name = 'mitmproxy'):
if platform.system() == 'Windows':
import wincertstore
stores = ["MY", "ROOT", "CA"]
for store in stores:
with wincertstore.CertSystemStore(store) as store:
for cert in store.itercerts():
name = cert.get_name()
if name == cert_name:
return True
return False
elif platform.system() == 'Darwin':
try:
result = subprocess.run(['security', 'find-certificate', '-c', cert_name], capture_output=True, text=True)
return result.returncode == 0
except FileNotFoundError:
raise NotImplementedError("此系统中未找到 security 命令")
else:
raise NotImplementedError(f"暂不支持该系统: {platform.system()}")
-9
View File
@@ -1,9 +0,0 @@
import subprocess
def is_certificate_installed(cert_name = 'mitmproxy'):
try:
result = subprocess.run(['security', 'find-certificate', '-c', cert_name], capture_output=True, text=True)
return result.returncode == 0
except FileNotFoundError:
raise NotImplementedError("此系统中未找到 security 命令")
-12
View File
@@ -1,12 +0,0 @@
import wincertstore
def is_certificate_installed(cert_name = "mitmproxy"):
stores = ["MY", "ROOT", "CA"]
for storename in stores:
with wincertstore.CertSystemStore(storename) as store:
for cert in store.itercerts():
name = cert.get_name()
if name == cert_name:
return True
return False
+2 -3
View File
@@ -2,8 +2,7 @@ import re
import urllib.request
import requests
from cert import win
import cert
# 检查代理是否正确
@@ -24,7 +23,7 @@ def is_proxy_correct(target_proxy_address):
# 检查证书是否安装
def wait_until_certificate_installed():
while True:
if win.is_certificate_installed('mitmproxy'):
if cert.is_certificate_installed('mitmproxy'):
break
else:
input(