Skip to content

构建、打包流程、文档以及依赖管理方面的重大改进#2

Open
BlueSkyXN wants to merge 5 commits into
icysaintdx:mainfrom
BlueSkyXN:main
Open

构建、打包流程、文档以及依赖管理方面的重大改进#2
BlueSkyXN wants to merge 5 commits into
icysaintdx:mainfrom
BlueSkyXN:main

Conversation

@BlueSkyXN
Copy link
Copy Markdown

此拉取请求为项目引入了构建和打包流程、文档以及依赖管理方面的重大改进。主要增强功能包括通过 GitHub Actions 使用 PyInstaller 和 Nuitka 添加了自动化多平台构建工作流,改进并重新组织了文档,以及更好的依赖处理。此外还有一些针对更安全字符串处理的小幅代码改进,以及整个项目的更新说明。

构建自动化和打包:

  • 添加了 .github/workflows/build-pyinstaller.yml,用于使用 PyInstaller 进行自动化的多平台构建,支持 Linux、macOS 和 Windows,包含构建产物上传和发布版本创建。
  • 添加了 .github/workflows/build-nuitka.yml,用于使用 Nuitka 进行自动化的多平台构建,包括构建产物上传和 GitHub 发布版本创建。
  • 更新了 build.py,将 pystrayPIL 包含为隐式导入,并确保在所有平台上始终打包托盘和窗口图标文件。

文档和项目结构:

  • BUILD_GUIDE.md 移动并更新为 docs/BUILD_GUIDE.md,扩展了 PyInstaller 和 Nuitka 的说明,阐明了构建产物命名,并记录了新的 GitHub Actions 工作流。
  • 更新了 README.md 以引用 requirements.txt 进行依赖安装,反映新的文档结构,并更新变更日志日期和说明。
  • 更新并重命名了 docs/Linux 环境安装指南.md,使用 requirements.txt 进行依赖安装,并改进了故障排除说明。

依赖管理:

  • 统一了文档和指南中的安装说明,使用 pip install -r requirements.txt 以实现一致的依赖管理。

代码改进:

  • 改进了 linux_do_gui.py 中的字符串转义,使用 json.dumps 安全地将内容传递给 JavaScript,防止注入漏洞。

其他更新:

  • 更新了变更日志和文档,以反映新版本和文件结构。
    这些更改共同实现了构建流程的现代化,使跨平台打包可复现且自动化,并改善了新贡献者的上手体验。

Introduces CI workflows for building and releasing executables using PyInstaller and Nuitka across multiple platforms. Updates .gitignore to exclude .DS_Store, corrects the release date in README, and enhances build.py to include pystray and pillow in hidden imports and data packaging. Documentation is updated and reorganized, including moving build guides to the docs directory and adding instructions for the new workflows.
Modified build workflows to install dependencies using requirements.txt instead of listing packages directly. This ensures consistency between local and CI environments. Also fixed a typo in the branches filter for the PyInstaller workflow.
Added requirements.txt with DrissionPage, pystray, and pillow dependencies. Updated .gitignore to allow requirements.txt and requirements-*.txt files to be tracked.
Refactors the Nuitka GitHub Actions workflow for clearer artifact naming, improved macOS app packaging, and more precise trigger paths. Fixes a typo in the PyInstaller workflow trigger. In linux_do_gui.py, ensures safe content injection in the editor using json.dumps, and improves the stop logic in the GUI to correctly reflect stopped status and reset state.
Replaced direct pip install commands with 'pip install -r requirements.txt' in README and documentation for consistency and easier dependency management. Updated build instructions, file structure, and output file naming conventions in both BUILD_GUIDE.md and Linux 环境安装指南.md. Also adjusted the GitHub Actions workflow for Nuitka on macOS by removing unnecessary flags.
Copilot AI review requested due to automatic review settings January 18, 2026 01:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request introduces comprehensive improvements to build automation, documentation, and dependency management for the Linux.do forum assistant tool. The changes add automated multi-platform builds using GitHub Actions with both PyInstaller and Nuitka, reorganize documentation into a dedicated docs folder, and standardize dependency management through requirements.txt. Additionally, the PR includes security improvements for string handling using json.dumps() and better state management for the stop functionality.

Changes:

  • Added GitHub Actions workflows for automated builds on Linux, macOS, and Windows using PyInstaller and Nuitka
  • Created requirements.txt for standardized dependency management and updated all documentation to reference it
  • Improved string escaping in linux_do_gui.py to prevent JavaScript injection vulnerabilities
  • Enhanced stop/done state tracking with _stop_requested flag

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
requirements.txt New file defining project dependencies (DrissionPage, pystray, pillow)
.github/workflows/build-pyinstaller.yml Automated multi-platform build workflow using PyInstaller with artifact uploads and releases
.github/workflows/build-nuitka.yml Automated multi-platform build workflow using Nuitka with artifact uploads and releases
linux_do_gui.py Security improvement using json.dumps() for safe JavaScript content passing; added _stop_requested flag for better state management
docs/BUILD_GUIDE.md Updated and reorganized build documentation with GitHub Actions info and requirements.txt references
build.py Added pystray and PIL as hidden imports; included icon data files for all platforms
README.md Updated to reference requirements.txt and new docs structure; corrected changelog date
.gitignore Added exceptions to allow requirements.txt files while excluding other .txt files; added .DS_Store

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread build.py
"--onefile",
"--windowed",
"--name", f"{APP_NAME}_v{APP_VERSION}_Windows",
"--add-data", f"{MAIN_SCRIPT};.",
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main script is incorrectly added as data with --add-data on line 56. PyInstaller should not have the main script added as data - it's already being compiled as the main entry point (line 65). This line should be removed as it's unnecessary and could cause issues.

Suggested change
"--add-data", f"{MAIN_SCRIPT};.",

Copilot uses AI. Check for mistakes.
Comment thread build.py
Comment on lines +68 to 73
# 打包图标数据,供运行时托盘与窗口图标使用
if os.path.exists(ICON_WIN):
cmd.extend(["--add-data", f"{ICON_WIN};."])

# 如果有图标文件
if os.path.exists(ICON_WIN):
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon file handling is duplicated. Lines 68-70 add the icon as data for runtime use, and lines 72-74 add it as the application icon. Both blocks check the same condition (if os.path.exists(ICON_WIN)). While both serve different purposes (--add-data for runtime access, --icon for the executable icon), this could be refactored into a single conditional block for clarity.

Suggested change
# 打包图标数据,供运行时托盘与窗口图标使用
if os.path.exists(ICON_WIN):
cmd.extend(["--add-data", f"{ICON_WIN};."])
# 如果有图标文件
if os.path.exists(ICON_WIN):
# 打包图标数据,供运行时托盘与窗口图标使用,并设置应用图标
if os.path.exists(ICON_WIN):
cmd.extend(["--add-data", f"{ICON_WIN};."])

Copilot uses AI. Check for mistakes.
Comment thread build.py
Comment on lines +146 to +148
# 打包图标数据,供运行时托盘与窗口图标使用
if os.path.exists(ICON_WIN):
cmd.extend(["--add-data", f"{ICON_WIN}:."])
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon file handling is duplicated. Lines 146-148 add the icon as data for runtime use. This pattern is repeated across all three build functions. Consider refactoring to avoid code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
- master
- dev
pull_request:
workflow_dispatch:
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow supports workflow_dispatch trigger but doesn't define any inputs. Consider adding a version input parameter similar to the Nuitka workflow to allow manual builds with specific version tags, or document that manual triggers will always create dev builds.

Copilot uses AI. Check for mistakes.
Comment thread build.py
Comment on lines +107 to 113
# 打包图标数据,供运行时托盘与窗口图标使用
if os.path.exists(ICON_WIN):
cmd.extend(["--add-data", f"{ICON_WIN}:."])

# 如果有图标文件
if os.path.exists(ICON_MAC):
cmd.extend(["--icon", ICON_MAC])
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon file handling is duplicated. Lines 107-109 add the icon as data for runtime use, and lines 111-113 add it as the application icon. Both blocks check conditions for icon existence. While both serve different purposes (--add-data for runtime access, --icon for the executable icon), this could be refactored into a single conditional block for clarity.

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +25
inputs:
version:
description: 'Version tag for release (e.g., v8.1.0)'
required: false
default: ''
Copy link

Copilot AI Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow defines a version input for workflow_dispatch events but never uses it. The version is always derived from the git reference in the build job (if present), but there's no step to resolve the version like in the PyInstaller workflow. Consider either using the input.version value when provided, or removing the unused input parameter.

Suggested change
inputs:
version:
description: 'Version tag for release (e.g., v8.1.0)'
required: false
default: ''

Copilot uses AI. Check for mistakes.
@icysaintdx
Copy link
Copy Markdown
Owner

感谢你的贡献!这个 PR 的改进方向很好,特别是: - 新增 PyInstaller 和 Nuitka 自动构建工作流 - 统一依赖管理(requirements.txt) - 文档结构优化 - 代码安全改进 不过目前存在一些问题需要解决: 1. 合并冲突:PR 与主分支存在冲突,需要先解决 2. 代码质量问题(Copilot 审查发现): - build.py 第 56 行:主脚本被错误地通过 --add-data 添加为数据文件 - build.py 第 68-73、107-113、146-148 行:图标处理逻辑重复,建议重构 - build-pyinstaller.yml 第 12 行:定义了 workflow_dispatch 但未定义输入参数 - build-nuitka.yml 第 21-25 行:定义了 version 输入但从未使用 3. 兼容性确认:项目在 v8.4 版本已有类似的构建流程,需要确认不会产生冲突 建议: - 先解决合并冲突 - 修复上述代码质量问题 - 测试与现有构建流程的兼容性 修复后我会重新审查并合并。再次感谢你的贡献

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants