Skip to content

Nuitka Package and Upload(dev) #24

Nuitka Package and Upload(dev)

Nuitka Package and Upload(dev) #24

name: Nuitka Package and Upload(dev)
on:
workflow_dispatch:
inputs:
test:
description: '测试'
required: true
type: boolean
default: true
config_path:
description: '测试模式时用的配置文件路径(非测试时请忽略)'
required: true
type: string
default: 'package/nuitka_test_config.yml'
# push:
# branches:
# - dev
# paths:
# - 'package/nuitka_config.yml'
jobs:
package-and-release:
runs-on: windows-latest
env:
PYTHON_VERSION: '3.10'
NUITKA_CACHE_DIR: ${{ github.workspace }}/nuitka-cache
# 添加必要的权限
permissions:
contents: write # 允许创建发布和上传资源
steps:
- name: Set Timezone to China Standard Time
run: tzutil /s "China Standard Time"
shell: pwsh
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Cache UPX
id: cache-upx
uses: actions/cache@v4
with:
path: upx
key: ${{ runner.os }}-${{ runner.arch }}-upx-v5.0.1
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-upx-
- name: UPX Setup
if: ${{ steps.cache-upx.outputs.cache-hit != 'true' }}
run: |
mkdir upx
curl -o upx/upx.exe https://assets.ksable.top/github/upx/upx/v5.0.1/windows-amd64/upx.exe
- name: get pip cache dir
id: pip-cache-dir
run: echo "pip-cache-dir=$(pip cache dir)" >> $env:GITHUB_OUTPUT
- name: pip cache
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache-dir.outputs.pip-cache-dir }} # pip缓存路径
key: ${{ runner.os }}-${{ runner.arch }}-pip-${{ hashFiles('package/nuitka_build.py') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-pip- # 后备恢复键(当精确键不存在时,使用最近的缓存)
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nuitka pyyaml ordered-set==4.1.0 wheel==0.38.4 zstandard==0.20.0
# - name: insatll mingw
# run: |
# mkdir C:\Users\%username%\AppData\Local\Nuitka\Nuitka\Cache\downloads\gcc\x86_64\14.2.0posix-19.1.1-12.0.0-msvcrt-r2
# curl -o C:\Users\%username%\AppData\Local\Nuitka\Nuitka\Cache\downloads\gcc\x86_64\14.2.0posix-19.1.1-12.0.0-msvcrt-r2\winlibs-x86_64-posix-seh-gcc-14.2.0-llvm-19.1.1-mingw-w64msvcrt-12.0.0-r2.zip https://github.com/brechtsanders/winlibs_mingw/releases/download/14.2.0posix-19.1.1-12.0.0-msvcrt-r2/winlibs-x86_64-posix-seh-gcc-14.2.0-llvm-19.1.1-mingw-w64msvcrt-12.0.0-r2.zip
# tar -xf C:\Users\%username%\AppData\Local\Nuitka\Nuitka\Cache\downloads\gcc\x86_64\14.2.0posix-19.1.1-12.0.0-msvcrt-r2\winlibs-x86_64-posix-seh-gcc-14.2.0-llvm-19.1.1-mingw-w64msvcrt-12.0.0-r2.zip -C C:\Users\%username%\AppData\Local\Nuitka\Nuitka\Cache\downloads\gcc\x86_64\14.2.0posix-19.1.1-12.0.0-msvcrt-r2\
# - name: Fix Python encoding (Windows)
# run: |
# # 设置Python使用UTF-8编码
# [System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
# # 设置控制台编码为UTF-8
# chcp.com 65001
- name: Cache Nuitka cache directory
uses: actions/cache@v4
with:
path: ${{ env.NUITKA_CACHE_DIR }}
key: nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-nuitka-${{ hashFiles('package/nuitka_build.py') }}
restore-keys: |
nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-
nuitka-${{ runner.os }}-${{ runner.arch }}-
- name: Run packaging script
if: ${{ !github.event.inputs.test }}
run: |
# 设置Python使用UTF-8编码
[System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
# 设置控制台编码为UTF-8
chcp.com 65001
cd package
python nuitka_build.py nuitka_config.yml
- name: Run Test packaging script
if: ${{ github.event.inputs.test }}
run: |
# 设置Python使用UTF-8编码
[System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process')
# 设置控制台编码为UTF-8
chcp.com 65001
cd package
python nuitka_build.py ${{ github.event.inputs.config_path }}
- name: Upload files with wildcards
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-${{ runner.arch }}-${{ github.event.inputs.test && 'test-' || '' }}artifact
path: |
./dist/*.exe
retention-days: 14
if-no-files-found: warn
overwrite: true