wallpaper_engine_workshop_cleaning #28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nuitka Package and Upload (v2) | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| run_name: | |
| description: '运行名称' | |
| required: true | |
| type: string | |
| default: 'nuitka_package_v2' | |
| python_version: | |
| description: 'Python 版本' | |
| required: true | |
| type: string | |
| default: '3.10' | |
| upx_version: | |
| description: 'UPX 版本' | |
| required: true | |
| type: string | |
| default: '5.0.1' | |
| run_on: | |
| description: '运行环境' | |
| required: true | |
| type: choice | |
| options: | |
| - 'ubuntu-latest' | |
| - 'ubuntu-24.04-arm' | |
| - 'windows-latest' | |
| default: 'ubuntu-latest' | |
| config_path: | |
| description: '配置文件路径,相对项目根目录' | |
| required: true | |
| type: string | |
| # default: 'package/nuitka_test_config.yml' | |
| log_level: | |
| description: '日志级别' | |
| required: true | |
| type: choice | |
| options: | |
| - 'DEBUG' | |
| - 'INFO' | |
| - 'WARNING' | |
| - 'ERROR' | |
| - 'CRITICAL' | |
| default: 'DEBUG' | |
| not_exit_code: | |
| description: '禁用错误退出码' | |
| required: true | |
| type: boolean | |
| default: false | |
| retention_days: | |
| description: 'Artifacts 文件保留天数' | |
| required: true | |
| type: number | |
| default: 90 | |
| check_environment: | |
| description: '检查环境' | |
| required: true | |
| type: boolean | |
| default: false | |
| # push: | |
| # branches: | |
| # - dev | |
| # paths: | |
| # - 'package/nuitka_config.yml' | |
| run-name: ${{ inputs.run_name }} | |
| jobs: | |
| # 环境检查 | |
| check-environment: | |
| if: ${{ inputs.check_environment }} | |
| runs-on: ${{ inputs.run_on }} | |
| env: | |
| PYTHON_VERSION: ${{ inputs.python_version }} | |
| # UPXVERSION: ${{ inputs.upx_version }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set Timezone to China Standard Time on Windows | |
| if: ${{ runner.os == 'Windows' }} | |
| run: tzutil /s "China Standard Time" | |
| shell: pwsh | |
| - name: Set Timezone to China Standard Time on Linux | |
| if: ${{ runner.os == 'Linux' }} | |
| run: sudo timedatectl set-timezone Asia/Shanghai | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.PYTHON_VERSION }} | |
| - name: Get pip cache dir | |
| id: pip-cache-dir | |
| run: echo "pip-cache-dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: pip cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.pip-cache-dir.outputs.pip-cache-dir }} | |
| key: ${{ runner.os }}-${{ runner.arch }}-pip-${{ hashFiles(inputs.config_path)}} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ runner.arch }}-pip- | |
| - name: Run systemInfo on Windows | |
| if: ${{ runner.os == 'Windows' }} | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r systemInfo/dev/requirements.txt | |
| # 设置Python使用UTF-8编码 | |
| [System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process') | |
| # 设置控制台编码为UTF-8 | |
| chcp.com 65001 | |
| python systemInfo/dev/main.py | |
| - name: Run systemInfo on Linux | |
| if: ${{ runner.os == 'Linux' }} | |
| run: | | |
| pip install --upgrade pip | |
| pip install -r systemInfo/dev/requirements.txt | |
| py_executable=$(which python) | |
| sudo $py_executable ${{ github.workspace }}/systemInfo/dev/main.py | |
| package-and-upload: | |
| if: ${{ !inputs.check_environment }} | |
| runs-on: ${{ inputs.run_on }} | |
| env: | |
| PYTHON_VERSION: ${{ inputs.python_version }} | |
| NUITKA_CACHE_DIR: ${{ github.workspace }}/nuitka-cache | |
| UPXVERSION: ${{ inputs.upx_version }} | |
| # 添加必要的权限 | |
| permissions: | |
| contents: write # 允许创建发布和上传资源 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set Timezone to China Standard Time on Windows | |
| if: ${{ runner.os == 'Windows' }} | |
| run: tzutil /s "China Standard Time" | |
| shell: pwsh | |
| - name: Set Timezone to China Standard Time on Linux | |
| if: ${{ runner.os == 'Linux' }} | |
| run: sudo timedatectl set-timezone Asia/Shanghai | |
| - 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-v${{ env.UPXVERSION }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ runner.arch }}-upx- | |
| - name: Create UPX directory | |
| if: ${{ steps.cache-upx.outputs.cache-hit != 'true' }} | |
| run: mkdir -p ./upx | |
| - name: Install UPX on Linux | |
| if: ${{ runner.os == 'Linux' && steps.cache-upx.outputs.cache-hit != 'true' }} | |
| run: | | |
| UPX_URL="https://github.com/upx/upx/releases/download/v${{ env.UPXVERSION }}/upx-${{ env.UPXVERSION }}-${{ runner.arch == 'X64' && 'amd64' || 'arm64' }}_linux.tar.xz" | |
| curl -L "$UPX_URL" -o upx.tar.xz | |
| tar -xf upx.tar.xz -C ./upx --strip-components=1 | |
| chmod +x ./upx/upx | |
| shell: bash | |
| - name: Install UPX on Windows | |
| if: ${{ runner.os == 'Windows' && steps.cache-upx.outputs.cache-hit != 'true' }} | |
| run: | | |
| $arch = if (("${{ runner.arch }}" -eq "amd64") -or ("${{ runner.arch }}" -eq "X64")) { "win64" } else { "win32" } | |
| $upxVersion = "${{ env.UPXVERSION }}" | |
| $upxUrl = "https://github.com/upx/upx/releases/download/v$upxVersion/upx-$upxVersion-$arch.zip" | |
| Invoke-WebRequest -Uri $upxUrl -OutFile upx.zip | |
| Expand-Archive -Path upx.zip -DestinationPath ./upx -Force | |
| # Windows 版本的 UPX 解压后在子目录中,需要移动到根目录 | |
| Move-Item -Path "./upx/upx-$upxVersion-$arch/*" -Destination ./upx -Force | |
| shell: pwsh | |
| - name: Verify UPX installation | |
| run: | | |
| ./upx/upx --version | |
| shell: bash | |
| # - name: get pip cache dir on Windows | |
| # if: ${{ runner.os == 'Windows' }} | |
| # id: pip-cache-dir-window | |
| # run: echo "pip-cache-dir=$(pip cache dir)" >> $env:GITHUB_OUTPUT | |
| # - name: get pip cache dir on Linux | |
| # if: ${{ runner.os == 'Linux' }} | |
| # id: pip-cache-dir-linux | |
| # run: echo "pip-cache-dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
| - name: Get pip cache dir | |
| id: pip-cache-dir | |
| run: echo "pip-cache-dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
| shell: bash | |
| - name: pip cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.pip-cache-dir.outputs.pip-cache-dir }} | |
| key: ${{ runner.os }}-${{ runner.arch }}-pip-${{ hashFiles(inputs.config_path)}} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ runner.arch }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r package/nuitka_build/v2/requirements.txt | |
| - name: Get nuitka version | |
| id: get-nuitka-version | |
| run: | | |
| ver=$(python package/utils/get_nuitka_version.py) | |
| echo "Nuitka version: ${ver}" | |
| echo "nuitka-version=${ver}" >> $GITHUB_OUTPUT | |
| shell: bash | |
| # - 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: Install dependencies on Linux | |
| if: ${{ runner.os == 'Linux' }} | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y ccache | |
| echo 'export PATH="/usr/lib/ccache:$PATH"' >> ~/.bashrc | |
| source ~/.bashrc | |
| sudo apt-get install -y patchelf | |
| - 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-${{ steps.get-nuitka-version.outputs.nuitka-version }}-${{ hashFiles(inputs.config_path) }} | |
| restore-keys: | | |
| nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-nuitka-${{ steps.get-nuitka-version.outputs.nuitka-version }}-${{ hashFiles(inputs.config_path) }} | |
| nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}-nuitka-${{ steps.get-nuitka-version.outputs.nuitka-version }}- | |
| nuitka-${{ runner.os }}-${{ runner.arch }}-python-${{ env.PYTHON_VERSION }}- | |
| nuitka-${{ runner.os }}-${{ runner.arch }}- | |
| - name: Run packaging script on Windows | |
| if: ${{ runner.os == 'Windows' }} | |
| run: | | |
| # 设置Python使用UTF-8编码 | |
| [System.Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Process') | |
| # 设置控制台编码为UTF-8 | |
| chcp.com 65001 | |
| python package/nuitka_build/v2/main.py --log-level ${{ inputs.log_level }} ${{ inputs.not_exit_code && '--not-exit-code' || '' }} ${{ inputs.config_path }} | |
| shell: pwsh | |
| - name: Run packaging script on Linux | |
| if: ${{ runner.os == 'Linux' }} | |
| run: | | |
| python package/nuitka_build/v2/main.py --log-level ${{ inputs.log_level }} ${{ inputs.not_exit_code && '--not-exit-code' || '' }} ${{ inputs.config_path }} | |
| shell: bash | |
| - name: Get output name on Windows | |
| id: get-output-name-windows | |
| if: ${{ runner.os == 'Windows' }} | |
| run: | | |
| echo "output-name=$(python package/utils/get_dir_detalis.py --dir dist --get-latest-file-name)" >> $env:GITHUB_ENV | |
| shell: pwsh | |
| - name: Get output name on Linux | |
| id: get-output-name-linux | |
| if: ${{ runner.os == 'Linux' }} | |
| run: | | |
| echo "output-name=$(python package/utils/get_dir_detalis.py --dir dist --get-latest-file-name)" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Upload program artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ env.output-name }} | |
| path: ./dist/${{ env.output-name }} | |
| retention-days: ${{ inputs.retention_days }} | |
| if-no-files-found: warn | |
| overwrite: true | |
| - name: Upload logs artifact | |
| if: ${{ always() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: logs | |
| path: ./log/* | |
| retention-days: ${{ inputs.retention_days }} | |
| if-no-files-found: warn | |
| overwrite: true |