Skip to content
Merged

Dev #36

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
64 changes: 57 additions & 7 deletions .github/workflows/dev_package_and_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,22 @@ name: Nuitka Package and Upload(dev)
on:
workflow_dispatch:
inputs:
run:
description: '运行 build.py'
required: true
default: 'true'
type: choice
options:
- 'true'
- 'false'
test:
description: '测试'
required: true
type: boolean
default: true
default: 'true'
type: choice
options:
- 'true'
- 'false'
config_path:
description: '测试模式时用的配置文件路径(非测试时请忽略)'
required: true
Expand Down Expand Up @@ -155,7 +166,8 @@ jobs:
nuitka-${{ runner.os }}-${{ runner.arch }}-

- name: Run packaging script on Windows
if: ${{ !github.event.inputs.test && runner.os == 'Windows' }}
if: ${{ github.event.inputs.run == 'true' && github.event.inputs.test == 'false' && runner.os == 'Windows' }}

run: |
# 设置Python使用UTF-8编码
[System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
Expand All @@ -164,7 +176,7 @@ jobs:
python ./package/nuitka_build.py ./package/nuitka_config.yml

- name: Run Test packaging script on Windows
if: ${{ github.event.inputs.test && runner.os == 'Windows' }}
if: ${{ github.event.inputs.run == 'true' && github.event.inputs.test == 'true' && runner.os == 'Windows' }}
run: |
# 设置Python使用UTF-8编码
[System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
Expand All @@ -173,19 +185,57 @@ jobs:
python ./package/nuitka_build.py ${{ github.event.inputs.config_path }}

- name: Run packaging script on Linux
if: ${{ !github.event.inputs.test && runner.os == 'Linux' }}
if: ${{ github.event.inputs.run == 'true' && github.event.inputs.test == 'false' && runner.os == 'Linux' }}
run: |
python ./package/nuitka_build.py ./package/nuitka_config.yml

- name: Run Test packaging script on Linux
if: ${{ github.event.inputs.test && runner.os == 'Linux' }}
if: ${{ github.event.inputs.run == 'true' && github.event.inputs.test == 'true' && runner.os == 'Linux' }}
run: |
python ./package/nuitka_build.py ${{ github.event.inputs.config_path }}

# 按理说不用检测 Release 是否已经发布,运行
- name: Check if Release exists
id: check_release
uses: actions/github-script@v6
with:
script: |
const tagName = process.env.TAG_NAME;
try {
const response = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tagName
});
const releaseId = response.data.id;
console.log(`Release '${tagName}' already exists with ID: ${releaseId}`);
core.setOutput('exists', 'true');
core.setOutput('release_id', releaseId);
} catch (error) {
if (error.status === 404) {
console.log(`Release '${tagName}' does not exist`);
core.setOutput('exists', 'false');
core.setOutput('release_id', '');
} else {
core.setFailed(`Failed to check release: ${error.message}`);
throw error;
}
}
env:
TAG_NAME: 'v25.07.08'

- name: Use Release ID
if: ${{ steps.check_release.outputs.exists == 'true' }}
run: |
echo "Existing Release ID: ${{ steps.check_release.outputs.release_id }}"
# 这里可以使用 release_id 进行更新操作
# 例如:gh release upload ${{ steps.check_release.outputs.release_id }} dist/*

- name: Upload files with wildcards
if: ${{ github.event.inputs.run == 'true' }}
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-${{ runner.arch }}-${{ github.event.inputs.test && 'test-' || '' }}artifact
name: ${{ runner.os }}-${{ runner.arch }}-${{ github.event.inputs.test && 'test-' || 'beta-' }}artifact
path: |
./dist/*
retention-days: 14
Expand Down
52 changes: 51 additions & 1 deletion .github/workflows/nuitka_package_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,48 @@ jobs:
run: |
python ./package/nuitka_build.py ./package/nuitka_config.yml

# 按理说不用检测 Release 是否已经发布,运行
- name: Check if Release exists
id: check_release
uses: actions/github-script@v6
with:
script: |
const tagName = process.env.TAG_NAME;
try {
const response = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: tagName
});
const releaseId = response.data.id;
console.log(`Release '${tagName}' already exists with ID: ${releaseId}`);
core.setOutput('exists', 'true');
core.setOutput('release_id', releaseId);
} catch (error) {
if (error.status === 404) {
console.log(`Release '${tagName}' does not exist`);
core.setOutput('exists', 'false');
core.setOutput('release_id', '');
} else {
core.setFailed(`Failed to check release: ${error.message}`);
throw error;
}
}
env:
TAG_NAME: ${{ env.VERSION_TAG }}

- name: Use Release ID
if: ${{ steps.check_release.outputs.exists == 'true' }}
run: |
echo "Existing Release ID: ${{ steps.check_release.outputs.release_id }}"
# 这里可以使用 release_id 进行更新操作
# 例如:gh release upload ${{ steps.check_release.outputs.release_id }} dist/*

# 仅当Release不存在时执行创建操作
- name: Create Release
if: ${{ steps.check_release.outputs.exists == 'false' }}
id: create_release
uses: softprops/action-gh-release@v1 # 使用更活跃维护的 release 操作
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand All @@ -191,3 +230,14 @@ jobs:
overwrite_files: true
files: |
dist/*

- name: Upload Release Assets
if: ${{ steps.check_release.outputs.exists == 'true' }}
uses: xresloader/upload-to-github-release@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
file: "./dist/*"
release_id: ${{ steps.check_release.outputs.release_id }}
verbose: false
overwrite: true
13 changes: 7 additions & 6 deletions package/nuitka_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def main():
task = MyDict(task)
try:
print(f"\n{'='*40}")
print(f"开始打包任务: [{i}/{len(config)}] {name}")
print(f"开始打包任务: [{i}/{len(config)}] {task.get('name')}")
print(f"{'='*40}")

# 解析任务参数 - 使用路径规范化
Expand All @@ -119,10 +119,11 @@ def main():
requirements = task.get('install-requirements', [])
enable_plugins = task.get('enable-plugins', [])

icon = task.get('icon')
# icon = task.get('icon')
name = task.get('name')
version = task.get('version')
timeout = task.get('timeout', 60 * 45)
os_list = task.get('os-list', ['Linux','Windows'])

# c-compiler
# c_compiler_clang = task.get('c-compiler', {}).get('clang', False)
Expand Down Expand Up @@ -155,8 +156,8 @@ def main():
only_windows_command = task.get('only-windows-command')
clean_cache = task.get('clean-cache')

if Machine not in task.get('os', ['Windows','Linux']):
print(f"警告: 任务 [{i}/{len(config)} {name}] 不支持当前操作系统 {Machine}")
if system_os not in os_list:
print(f"警告: 任务 [{i}/{len(config)}] {name} 不支持当前操作系统 {system_os}")
task_error_list.append(name)
continue

Expand Down Expand Up @@ -305,10 +306,10 @@ def main():
shutil.rmtree(temp_output_path)

except Exception as e:
print(f"任务[{i}/{len(config)} {name}]失败: {str(e)}")
print(f"任务[{i}/{len(config)} {task.get('name')}]失败: {str(e)}")
import traceback
traceback.print_exc()
task_error_list.append(name)
task_error_list.append(task.get('name'))

# 输出最终结果
print("\n" + "="*50)
Expand Down
14 changes: 14 additions & 0 deletions package/nuitka_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# onefile: 2 # 0:文件夹 1:单文件 2:两者
# distpath: 'dist'
timeout: 2700
os-list:
- 'Linux'
- 'Windows'
custom-command: []
only-linux-command: []
only-windows-command: []
Expand Down Expand Up @@ -47,6 +50,8 @@
windows-disable-console: False
# distpath: 'dist'
timeout: 2700
os-list:
- 'Windows'
custom-command: []
only-linux-command: []
only-windows-command: []
Expand Down Expand Up @@ -80,6 +85,9 @@
windows-disable-console: False
# distpath: 'dist'
timeout: 2700
os-list:
- 'Linux'
- 'Windows'
custom-command: []
only-linux-command: []
only-windows-command: []
Expand Down Expand Up @@ -110,6 +118,9 @@
windows-disable-console: False
# distpath: 'dist'
timeout: 2700
os-list:
- 'Linux'
- 'Windows'
custom-command: []
only-linux-command: []
only-windows-command: []
Expand Down Expand Up @@ -141,6 +152,9 @@
windows-disable-console: False
# distpath: 'dist'
timeout: 2700
os-list:
- 'Linux'
- 'Windows'
custom-command: []
only-linux-command: []
only-windows-command: []
Expand Down
3 changes: 3 additions & 0 deletions package/nuitka_test_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# distpath: 'dist'
timeout: 2700
custom-command: []
os-list:
- 'Linux'
- 'Windows'
only-linux-command: []
only-windows-command: []
clean-cache: # 禁用选定的缓存,设置"all"则为所有缓存。当前允许的值有:"all(全部)","ccache","bytecode(字节码)","compression(压缩)","dll-dependencies(dll依赖项)"。
Expand Down