Skip to content

Commit 4e5e27b

Browse files
authored
Merge branch 'main' into dev (#28)
* Update dev_package_and_upload.yml (#17) * 更新 NetEase_Cloud_Music_Download * sync (#19) * Update dev_package_and_upload.yml * Update README.md * update nuitka_build.py * Update pyinstaller_package_and_release.yml * Update nuitka_package_release.yml * Update nuitka_build.py * 更新 NetEase_Cloud_Music_Download (#18) * Update dev_package_and_upload.yml (#17) * 更新 NetEase_Cloud_Music_Download * 更新依赖项,添加psutil和astropy库 * 添加favicon.ico图标文件,并在配置中启用UPX压缩 * Nuitka Build 启用多核并行编译 * test cache * 删去错误版本信息 * fix dev_package_and_upload.yml * fix dev_package_and_upload.yml * fix dev_package_and_upload.yml pip-cache-dir * Update dev_package_and_upload.yml fix type * 添加对插件的支持,更新配置文件以启用UPX插件和自定义命令 * 禁用 Nuitka Package and Upload(dev) 自动流程,启用手动触发,添加测试流程 * fix Nuitka Package and Upload(dev) * try fix nuitka_build.py * Nuitka Package and Upload(dev) update upx installer and use more os bulid * Nuitka Package and Upload(dev) fix value * Nuitka Package and Upload(dev) fix Timezone * update * update nuitka 兼容Linux Windows平台 * remove windows-11-arm * update * more option * fix artifact upload * update Package * fix workflows name and fix nuitka_build.py
1 parent fecf583 commit 4e5e27b

7 files changed

Lines changed: 554 additions & 139 deletions

File tree

.github/workflows/dev_package_and_upload.yml

Lines changed: 135 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,120 @@ name: Nuitka Package and Upload(dev)
22

33
on:
44
workflow_dispatch:
5-
push:
6-
branches:
7-
- dev
8-
paths:
9-
- 'package/nuitka_config.yml'
5+
inputs:
6+
test:
7+
description: '测试'
8+
required: true
9+
type: boolean
10+
default: true
11+
config_path:
12+
description: '测试模式时用的配置文件路径(非测试时请忽略)'
13+
required: true
14+
type: string
15+
default: 'package/nuitka_test_config.yml'
16+
# push:
17+
# branches:
18+
# - dev
19+
# paths:
20+
# - 'package/nuitka_config.yml'
1021

1122
jobs:
1223
package-and-upload:
13-
runs-on: windows-latest
24+
runs-on: ${{ matrix.os }}
25+
strategy:
26+
matrix:
27+
os: [ubuntu-latest,ubuntu-24.04-arm,windows-latest] # windows-11-arm没有对应的 Python
28+
env:
29+
PYTHON_VERSION: '3.10'
30+
NUITKA_CACHE_DIR: ${{ github.workspace }}/nuitka-cache
31+
UPXVERSION: '5.0.1'
1432

1533
# 添加必要的权限
1634
permissions:
1735
contents: write # 允许创建发布和上传资源
1836

1937
steps:
20-
- name: Set Timezone to China Standard Time
21-
run: tzutil /s "China Standard Time"
22-
shell: pwsh
2338

2439
- name: Checkout code
2540
uses: actions/checkout@v4
41+
42+
- name: Set Timezone to China Standard Time on Windows
43+
if: ${{ runner.os == 'Windows' }}
44+
run: tzutil /s "China Standard Time"
45+
shell: pwsh
46+
47+
- name: Set Timezone to China Standard Time on Linux
48+
if: ${{ runner.os == 'Linux' }}
49+
run: sudo timedatectl set-timezone Asia/Shanghai
50+
2651

2752
- name: Set up Python
2853
uses: actions/setup-python@v5
2954
with:
30-
python-version: '3.10'
55+
python-version: ${{ env.PYTHON_VERSION }}
56+
57+
- name: Cache UPX
58+
id: cache-upx
59+
uses: actions/cache@v4
60+
with:
61+
path: upx
62+
key: ${{ runner.os }}-${{ runner.arch }}-upx-v${{ env.UPXVERSION }}
63+
restore-keys: |
64+
${{ runner.os }}-${{ runner.arch }}-upx-
65+
66+
- name: Create UPX directory
67+
if: ${{ steps.cache-upx.outputs.cache-hit != 'true' }}
68+
run: mkdir -p ./upx
69+
70+
- name: Install UPX on Linux
71+
if: ${{ runner.os == 'Linux' && steps.cache-upx.outputs.cache-hit != 'true' }}
72+
run: |
73+
74+
UPX_URL="https://github.com/upx/upx/releases/download/v${{ env.UPXVERSION }}/upx-${{ env.UPXVERSION }}-${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}_linux.tar.xz"
75+
curl -L "$UPX_URL" -o upx.tar.xz
76+
tar -xf upx.tar.xz -C ./upx --strip-components=1
77+
chmod +x ./upx/upx
78+
79+
shell: bash
80+
81+
- name: Install UPX on Windows
82+
if: ${{ runner.os == 'Windows' && steps.cache-upx.outputs.cache-hit != 'true' }}
83+
run: |
84+
$arch = if (("${{ runner.arch }}" -eq "amd64") -or ("${{ runner.arch }}" -eq "X64")) { "win64" } else { "win32" }
85+
$upxVersion = "${{ env.UPXVERSION }}"
86+
$upxUrl = "https://github.com/upx/upx/releases/download/v$upxVersion/upx-$upxVersion-$arch.zip"
87+
88+
Invoke-WebRequest -Uri $upxUrl -OutFile upx.zip
89+
Expand-Archive -Path upx.zip -DestinationPath ./upx -Force
90+
91+
# Windows 版本的 UPX 解压后在子目录中,需要移动到根目录
92+
Move-Item -Path "./upx/upx-$upxVersion-$arch/*" -Destination ./upx -Force
93+
94+
shell: pwsh
3195

32-
- name: UPX Setup
96+
- name: Verify UPX installation
3397
run: |
34-
mkdir upx
35-
curl -o upx/upx.exe https://assets.ksable.top/github/upx/upx/v5.0.1/windows-amd64/upx.exe
98+
./upx/upx --version
99+
shell: bash
100+
101+
- name: get pip cache dir on Windows
102+
if: ${{ runner.os == 'Windows' }}
103+
id: pip-cache-dir-window
104+
run: echo "pip-cache-dir=$(pip cache dir)" >> $env:GITHUB_OUTPUT
105+
106+
- name: get pip cache dir on Linux
107+
if: ${{ runner.os == 'Linux' }}
108+
id: pip-cache-dir-linux
109+
run: echo "pip-cache-dir=$(pip cache dir)" >> $GITHUB_OUTPUT
110+
111+
- name: pip cache
112+
uses: actions/cache@v4
113+
with:
114+
path: ${{ runner.os == 'Windows' && steps.pip-cache-dir-window.outputs.pip-cache-dir || steps.pip-cache-dir-linux.outputs.pip-cache-dir }}
115+
key: ${{ runner.os }}-${{ runner.arch }}-pip-${{ github.event.inputs.test && hashFiles(github.event.inputs.config_path) || hashFiles('package/nuitka_build.py') }}
116+
restore-keys: |
117+
${{ runner.os }}-${{ runner.arch }}-pip-
118+
36119

37120
- name: Install dependencies
38121
run: |
@@ -52,22 +135,56 @@ jobs:
52135
# [System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
53136
# # 设置控制台编码为UTF-8
54137
# chcp.com 65001
138+
139+
- name: Install ccache on Linux
140+
if: ${{ runner.os == 'Linux' }}
141+
run: |
142+
sudo apt-get update -y
143+
sudo apt-get install -y ccache
144+
145+
- name: Cache Nuitka cache directory
146+
uses: actions/cache@v4
147+
with:
148+
path: ${{ env.NUITKA_CACHE_DIR }}
149+
key: nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-nuitka-${{ github.event.inputs.test && hashFiles(github.event.inputs.config_path) || hashFiles('package/nuitka_build.py') }}
150+
restore-keys: |
151+
nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-
152+
nuitka-${{ runner.os }}-${{ runner.arch }}-
153+
154+
- name: Run packaging script on Windows
155+
if: ${{ !github.event.inputs.test && runner.os == 'Windows' }}
156+
run: |
157+
# 设置Python使用UTF-8编码
158+
[System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
159+
# 设置控制台编码为UTF-8
160+
chcp.com 65001
161+
python ./package/nuitka_build.py ./package/nuitka_config.yml
55162
56-
- name: Run packaging script
163+
- name: Run Test packaging script on Windows
164+
if: ${{ github.event.inputs.test && runner.os == 'Windows' }}
57165
run: |
58166
# 设置Python使用UTF-8编码
59167
[System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
60168
# 设置控制台编码为UTF-8
61169
chcp.com 65001
62-
cd package
63-
python nuitka_build.py nuitka_config.yml
170+
python ./package/nuitka_build.py ${{ github.event.inputs.config_path }}
171+
172+
- name: Run packaging script on Linux
173+
if: ${{ !github.event.inputs.test && runner.os == 'Linux' }}
174+
run: |
175+
python ./package/nuitka_build.py ./package/nuitka_config.yml
176+
177+
- name: Run Test packaging script on Linux
178+
if: ${{ github.event.inputs.test && runner.os == 'Linux' }}
179+
run: |
180+
python ./package/nuitka_build.py ${{ github.event.inputs.config_path }}
64181
65182
- name: Upload files with wildcards
66183
uses: actions/upload-artifact@v4
67184
with:
68-
name: Artifact
185+
name: ${{ runner.os }}-${{ runner.arch }}-${{ github.event.inputs.test && 'test-' || '' }}artifact
69186
path: |
70-
./dist/*.exe
187+
./dist/*
71188
retention-days: 14
72189
if-no-files-found: warn
73190
overwrite: true

.github/workflows/nuitka_package_release.yml

Lines changed: 121 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,122 @@ on:
99
- 'package/nuitka_config.yml'
1010

1111
jobs:
12-
package-and-release:
12+
package-and-upload:
1313
runs-on: windows-latest
14+
# runs-on: ${{ matrix.os }}
15+
# strategy:
16+
# matrix:
17+
# os: [ubuntu-latest,ubuntu-24.04-arm,windows-latest] # windows-11-arm没有对应的 Python
18+
env:
19+
PYTHON_VERSION: '3.10'
20+
NUITKA_CACHE_DIR: ${{ github.workspace }}/nuitka-cache
21+
UPXVERSION: '5.0.1'
1422

1523
# 添加必要的权限
1624
permissions:
1725
contents: write # 允许创建发布和上传资源
1826

1927
steps:
20-
- name: Set Timezone to China Standard Time
21-
run: tzutil /s "China Standard Time"
22-
shell: pwsh
2328

2429
- name: Checkout code
2530
uses: actions/checkout@v4
2631

27-
- name: Generate version tag
28-
id: version
32+
- name: Set Timezone to China Standard Time on Windows
33+
if: ${{ runner.os == 'Windows' }}
34+
run: tzutil /s "China Standard Time"
35+
shell: pwsh
36+
37+
- name: Set Timezone to China Standard Time on Linux
38+
if: ${{ runner.os == 'Linux' }}
39+
run: sudo timedatectl set-timezone Asia/Shanghai
40+
41+
- name: Generate version tag on Windows
42+
if: ${{ runner.os == 'Windows' }}
2943
run: |
3044
# 使用 UTC 时间确保一致性
3145
$date = (Get-Date).ToUniversalTime().ToString("yy.MM.dd")
3246
$tag = "v$date"
3347
$release = "Release $date"
34-
echo "tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
35-
echo "release_name=$release" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
36-
37-
48+
echo "VERSION_TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
49+
echo "RELEASE_NAME=$release" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
50+
shell: pwsh
51+
52+
- name: Generate version tag on Linux
53+
if: ${{ runner.os == 'Linux' }}
54+
run: |
55+
# 使用 UTC 时间确保一致性
56+
DATE=$(date -u +%y.%m.%d)
57+
echo "VERSION_TAG=v$DATE" >> $GITHUB_ENV
58+
echo "RELEASE_NAME=Release $DATE" >> $GITHUB_ENV
59+
shell: bash
60+
3861
- name: Set up Python
3962
uses: actions/setup-python@v5
4063
with:
41-
python-version: '3.10'
64+
python-version: ${{ env.PYTHON_VERSION }}
65+
66+
- name: Cache UPX
67+
id: cache-upx
68+
uses: actions/cache@v4
69+
with:
70+
path: upx
71+
key: ${{ runner.os }}-${{ runner.arch }}-upx-v${{ env.UPXVERSION }}
72+
restore-keys: |
73+
${{ runner.os }}-${{ runner.arch }}-upx-
74+
75+
- name: Create UPX directory
76+
if: ${{ steps.cache-upx.outputs.cache-hit != 'true' }}
77+
run: mkdir -p ./upx
78+
79+
- name: Install UPX on Linux
80+
if: ${{ runner.os == 'Linux' && steps.cache-upx.outputs.cache-hit != 'true' }}
81+
run: |
82+
83+
UPX_URL="https://github.com/upx/upx/releases/download/v${{ env.UPXVERSION }}/upx-${{ env.UPXVERSION }}-${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}_linux.tar.xz"
84+
curl -L "$UPX_URL" -o upx.tar.xz
85+
tar -xf upx.tar.xz -C ./upx --strip-components=1
86+
chmod +x ./upx/upx
87+
88+
shell: bash
4289

43-
- name: UPX Setup
90+
- name: Install UPX on Windows
91+
if: ${{ runner.os == 'Windows' && steps.cache-upx.outputs.cache-hit != 'true' }}
4492
run: |
45-
mkdir upx
46-
curl -o upx/upx.exe https://assets.ksable.top/github/upx/upx/v5.0.1/windows-amd64/upx.exe
93+
$arch = if (("${{ runner.arch }}" -eq "amd64") -or ("${{ runner.arch }}" -eq "X64")) { "win64" } else { "win32" }
94+
$upxVersion = "${{ env.UPXVERSION }}"
95+
$upxUrl = "https://github.com/upx/upx/releases/download/v$upxVersion/upx-$upxVersion-$arch.zip"
96+
97+
Invoke-WebRequest -Uri $upxUrl -OutFile upx.zip
98+
Expand-Archive -Path upx.zip -DestinationPath ./upx -Force
99+
100+
# Windows 版本的 UPX 解压后在子目录中,需要移动到根目录
101+
Move-Item -Path "./upx/upx-$upxVersion-$arch/*" -Destination ./upx -Force
102+
103+
shell: pwsh
104+
105+
- name: Verify UPX installation
106+
run: |
107+
./upx/upx --version
108+
shell: bash
109+
110+
- name: get pip cache dir on Windows
111+
if: ${{ runner.os == 'Windows' }}
112+
id: pip-cache-dir-window
113+
run: echo "pip-cache-dir=$(pip cache dir)" >> $env:GITHUB_OUTPUT
114+
115+
- name: get pip cache dir on Linux
116+
if: ${{ runner.os == 'Linux' }}
117+
id: pip-cache-dir-linux
118+
run: echo "pip-cache-dir=$(pip cache dir)" >> $GITHUB_OUTPUT
119+
120+
- name: pip cache
121+
uses: actions/cache@v4
122+
with:
123+
path: ${{ runner.os == 'Windows' && steps.pip-cache-dir-window.outputs.pip-cache-dir || steps.pip-cache-dir-linux.outputs.pip-cache-dir }}
124+
key: ${{ runner.os }}-${{ runner.arch }}-pip-${{ github.event.inputs.test && hashFiles(github.event.inputs.config_path) || hashFiles('package/nuitka_build.py') }}
125+
restore-keys: |
126+
${{ runner.os }}-${{ runner.arch }}-pip-
127+
47128

48129
- name: Install dependencies
49130
run: |
@@ -64,26 +145,46 @@ jobs:
64145
# # 设置控制台编码为UTF-8
65146
# chcp.com 65001
66147

67-
- name: Run packaging script
148+
- name: Install ccache on Linux
149+
if: ${{ runner.os == 'Linux' }}
150+
run: |
151+
sudo apt-get update -y
152+
sudo apt-get install -y ccache
153+
154+
- name: Cache Nuitka cache directory
155+
uses: actions/cache@v4
156+
with:
157+
path: ${{ env.NUITKA_CACHE_DIR }}
158+
key: nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-nuitka-${{ github.event.inputs.test && hashFiles(github.event.inputs.config_path) || hashFiles('package/nuitka_build.py') }}
159+
restore-keys: |
160+
nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-
161+
nuitka-${{ runner.os }}-${{ runner.arch }}-
162+
163+
- name: Run packaging script on Windows
164+
if: ${{ runner.os == 'Windows' }}
68165
run: |
69166
# 设置Python使用UTF-8编码
70167
[System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
71168
# 设置控制台编码为UTF-8
72169
chcp.com 65001
73-
cd package
74-
python nuitka_build.py nuitka_config.yml
170+
python ./package/nuitka_build.py ./package/nuitka_config.yml
171+
172+
- name: Run packaging script on Linux
173+
if: ${{ runner.os == 'Linux' }}
174+
run: |
175+
python ./package/nuitka_build.py ./package/nuitka_config.yml
75176
76177
- name: Create Release
77178
id: create_release
78179
uses: softprops/action-gh-release@v1 # 使用更活跃维护的 release 操作
79180
env:
80181
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81182
with:
82-
tag_name: ${{ steps.version.outputs.tag }}
83-
name: ${{ steps.version.outputs.release_name }}
183+
tag_name: ${{ env.VERSION_TAG }}
184+
name: ${{ env.RELEASE_NAME }}
84185
generate_release_notes: true
85186
draft: false
86187
prerelease: false
87188
overwrite_files: true
88189
files: |
89-
dist/*.exe
190+
dist/*

novel_crawler/novel_crawler_v.25.07.08.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ def download_chapter(chapter_info, progress, task_id, chapter_count):
417417

418418
# 主函数开始
419419
def main():
420-
print_header("小说爬虫工具\n版本 v.25.07.07")
420+
print_header("小说爬虫工具")
421421

422422
if debug:
423423
logger.debug("Debug模式已开启")

0 commit comments

Comments
 (0)