Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 214 additions & 0 deletions .github/workflows/build-nuitka.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
name: 构建 (Nuitka)

on:
push:
pull_request:
workflow_dispatch:

concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true

jobs:
builder_matrix:
# 仅在push或pull_request事件包含'进行打包'时执行,workflow_dispatch无条件执行
if: |
github.event_name == 'workflow_dispatch' ||
contains(github.event.head_commit.message, 'nuitka进行打包') ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.title, '进行打包'))
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
arch: x64
pack_mode: dir
- os: windows-2022
arch: x86
pack_mode: dir

runs-on: ${{ matrix.os }}
steps:
- name: 检出仓库
uses: actions/checkout@v4.2.2
- name: 安装 Python
uses: actions/setup-python@v5.3.0
with:
python-version: "3.8.10"
architecture: ${{ matrix.arch }}
- name: 安装 uv
uses: astral-sh/setup-uv@v4

- name: 初始化 zip 文件夹
run: mkdir zip

- name: 更新 version_info.txt
if: startsWith(github.ref_name, 'v')
run: |
python update_version.py
env:
VERSION: ${{ github.ref_name }}

- name: 运行 Windows 构建 (PyInstaller)
if: ${{ matrix.os == 'windows-2022' }}
run: |
echo "开始 Windows 构建流程..."
# 直接运行打包脚本build_pyinstaller.py
uv sync
uv run build_pyinstaller.py

- name: 打包操作
if: ${{ matrix.os == 'windows-2022'}}
run: |
echo "开始打包操作..."

# 创建zip_dist/SecRandom目录
mkdir -p zip_dist/SecRandom

# 复制dist/SecRandom目录下的所有文件到zip_dist/SecRandom目录下
Copy-Item -Recurse -Force dist/SecRandom/* zip_dist/SecRandom/

# 创建app目录
mkdir -p zip_dist/SecRandom/app

# 复制app/resources文件夹到zip_dist/SecRandom目录下
Copy-Item -Recurse -Force app/resources zip_dist/SecRandom/app

# 复制 LICENSE 文件到zip_dist/SecRandom目录下
Copy-Item LICENSE zip_dist/SecRandom/

# 使用 zip 压缩文件
mkdir zip -Force
$outputZip = "zip/SecRandom-Windows-${{ github.ref_name }}-${{ matrix.arch }}-dir.zip"
Compress-Archive -Path zip_dist/SecRandom/* -DestinationPath $outputZip -Force
echo "目录模式打包完成: $outputZip"

- name: 上传应用程序
if: ${{ github.event_name != 'pull_request' }}
uses: actions/upload-artifact@v4.4.2
with:
name: windows-2022-${{ matrix.arch }}-${{ matrix.pack_mode }}
path: ./zip

release:
needs: [builder_matrix]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: 设置 git-cliff
uses: kenji-miyake/setup-git-cliff@v1

- name: 生成 changelog
id: generate-changelog
run: |
git cliff

- name: 准备发布
run: |
echo "准备发布目录..."
mkdir -p release
mkdir -p artifacts

- name: 下载 artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
run-id: ${{ github.run_id }}

- name: 准备 artifacts
run: |
echo "整理构建产物..."
# Windows 构建产物
mv artifacts/windows-2022-x64-dir/* release/ 2>/dev/null || echo "未找到 Windows x64-dir 构建产物"
mv artifacts/windows-2022-x86-dir/* release/ 2>/dev/null || echo "未找到 Windows x86-dir 构建产物"
echo "构建产物整理完成"
ls -la release/

- name: 计算 SHA256 值
run: |
echo "开始计算SHA256校验值..."
cd release
echo "" > SHA256SUMS.txt
for file in *; do
if [ -f "$file" ]; then
echo "计算 $file 的SHA256值..."
sha256sum "$file" >> SHA256SUMS.txt
fi
done
echo "SHA256校验值计算完成:"
cat SHA256SUMS.txt

- name: 验证 SHA256SUMS.txt 文件
run: |
echo "验证SHA256SUMS.txt文件..."
cd release
if [ ! -f "SHA256SUMS.txt" ]; then
echo "错误:在release目录中未找到SHA256SUMS.txt文件"
exit 1
fi
if [ ! -s "SHA256SUMS.txt" ]; then
echo "错误:SHA256SUMS.txt文件为空"
exit 1
fi
echo "SHA256SUMS.txt文件验证通过"
cd ..

- name: 生成 需发布 的表格信息
run: |
cd release
echo "" >> ../CHANGELOG.md
echo "Full Changelog: [v1.3.0.5...${{ github.ref_name }}](https://github.com/SECTL/SecRandom/compare/v1.3.0.5...${{ github.ref_name }})" >> ../CHANGELOG.md
echo "" >> ../CHANGELOG.md
echo "**国内 下载链接**" >> ../CHANGELOG.md
echo "| 平台/打包方式 | 支持架构 | 完整版 |" >> ../CHANGELOG.md
echo "| --- | --- | --- |" >> ../CHANGELOG.md
echo "| Windows | x64, x86 | [下载](https://www.123684.com/s/9529jv-U4Fxh) |" >> ../CHANGELOG.md
echo "" >> ../CHANGELOG.md
echo "**Github 镜像 下载链接**" >> ../CHANGELOG.md
echo "| 镜像源 | 平台/打包方式 | 支持架构 | 完整版 |" >> ../CHANGELOG.md
echo "| --- | --- | --- | --- |" >> ../CHANGELOG.md
echo "| ghfast.top | Windows 目录模式 | x64 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x64-dir.zip) |" >> ../CHANGELOG.md
echo "| ghfast.top | Windows 目录模式 | x86 | [下载 ${{ github.ref_name }}](https://ghfast.top/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x86-dir.zip) |" >> ../CHANGELOG.md
echo "| gh-proxy.com | Windows 目录模式 | x64 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x64-dir.zip) |" >> ../CHANGELOG.md
echo "| gh-proxy.com | Windows 目录模式 | x86 | [下载 ${{ github.ref_name }}](https://gh-proxy.com/https://github.com/SECTL/SecRandom/releases/download/${{ github.ref_name }}/SecRandom-Windows-${{ github.ref_name }}-x86-dir.zip) |" >> ../CHANGELOG.md
echo "" >> ../CHANGELOG.md
echo "**SHA256 校验值-请核对下载的文件的SHA256值是否正确**" >> ../CHANGELOG.md
echo "| 文件名 | SHA256 值 |" >> ../CHANGELOG.md
echo "| --- | --- |" >> ../CHANGELOG.md
while read -r line; do
hash=$(echo "$line" | awk '{print $1}')
file=$(echo "$line" | awk '{print $2}')
echo "| $file | $hash |" >> ../CHANGELOG.md
done < SHA256SUMS.txt
rm SHA256SUMS.txt
cd ..

- name: 确定发布类型
id: release-type
run: |
if [[ "${{ github.ref }}" == *"beta"* || "${{ github.ref }}" == *"alpha"* ]]; then
echo "is_beta=true" >> $GITHUB_ENV
else
echo "is_beta=false" >> $GITHUB_ENV
fi

- name: 发布
uses: softprops/action-gh-release@v2
with:
token: ${{ secrets.Releases_BOT }}
files: release/*
body_path: CHANGELOG.md
draft: false
prerelease: ${{ env.is_beta == 'true' }}
tag_name: ${{ github.ref_name }}
name: SecRandom 新版本 - ${{ github.ref_name }}
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47 changes: 4 additions & 43 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 构建
name: 构建 (PyInstaller)

on:
push:
Expand Down Expand Up @@ -49,52 +49,13 @@ jobs:
env:
VERSION: ${{ github.ref_name }}

- name: 运行 Windows 构建
- name: 运行 Windows 构建 (PyInstaller)
if: ${{ matrix.os == 'windows-2022' }}
run: |
echo "开始 Windows 构建流程..."
# 创建虚拟环境
echo "创建虚拟环境..."
uv venv
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

# 激活虚拟环境
echo "激活虚拟环境..."
.venv/Scripts/activate

# 安装依赖
echo "安装项目依赖..."
# 直接运行打包脚本build_pyinstaller.py
uv sync

# 安装 pyinstaller
echo "安装 PyInstaller..."
uv pip install pyinstaller
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

# 清理之前的构建文件
echo "清理之前的构建文件..."
Remove-Item -Recurse -Force dist -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force build -ErrorAction SilentlyContinue
Remove-Item -Recurse -Force zip_dist -ErrorAction SilentlyContinue
echo "构建环境准备完成"
# 根据打包模式选择不同的PyInstaller参数
if ('${{ matrix.pack_mode }}' -eq 'dir') {
# 目录模式打包
echo "开始目录模式打包..."
pyinstaller main.py `
-w `
-D `
-i ./resources/secrandom-icon-paper.ico `
-n SecRandom `
--add-data ./app/resources:app/resources `
--add-data LICENSE:. `
--version-file=version_info.txt
if ($LASTEXITCODE -ne 0) {
echo "目录模式打包失败"
exit $LASTEXITCODE
}
echo "目录模式打包完成"
}
uv run build_pyinstaller.py

- name: 打包操作
if: ${{ matrix.os == 'windows-2022'}}
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ MANIFEST
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
Expand Down
70 changes: 70 additions & 0 deletions Secrandom.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
"""PyInstaller spec leveraging shared packaging utilities."""

from PyInstaller.utils.hooks import collect_data_files

from packaging_utils import (
ADDITIONAL_HIDDEN_IMPORTS,
collect_data_includes,
collect_language_modules,
collect_view_modules,
normalize_hidden_imports,
)

block_cipher = None

base_datas = [(str(item.source), item.target) for item in collect_data_includes()]

try:
qfluentwidgets_datas = collect_data_files("qfluentwidgets")
except Exception as exc:
print(f"Warning: unable to collect qfluentwidgets resources: {exc}")
qfluentwidgets_datas = []

all_datas = base_datas + qfluentwidgets_datas

language_hiddenimports = collect_language_modules()
view_hiddenimports = collect_view_modules()

all_hiddenimports = normalize_hidden_imports(
language_hiddenimports + view_hiddenimports + ADDITIONAL_HIDDEN_IMPORTS
)

a = Analysis(
["main.py"],
pathex=[],
binaries=[],
datas=all_datas,
hiddenimports=all_hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)

pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name="SecRandom",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
1 change: 1 addition & 0 deletions app/Language/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Language package
1 change: 1 addition & 0 deletions app/Language/modules/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Language modules package
20 changes: 7 additions & 13 deletions app/Language/modules/remaining_list.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
# 剩余名单页面语言配置
remaining_list = {
"ZH_CN": {
"title": {
"name": "未抽取学生名单",
"description": "剩余名单页面标题"
},
"title": {"name": "未抽取学生名单", "description": "剩余名单页面标题"},
"title_with_class": {
"name": "{class_name} - 未抽取学生名单",
"description": "带班级名称的标题"
},
"count_label": {
"name": "剩余人数:{count}",
"description": "剩余人数标签文本"
"description": "带班级名称的标题",
},
"count_label": {"name": "剩余人数:{count}", "description": "剩余人数标签文本"},
"no_students": {
"name": "暂无未抽取的学生",
"description": "没有剩余学生时的提示文本"
"description": "没有剩余学生时的提示文本",
},
"student_info": {
"name": "学号: {id}\n性别: {gender}\n小组: {group}",
"description": "学生卡片信息格式"
}
"description": "学生卡片信息格式",
},
}
}
}
Loading
Loading