构建可执行文件 #50
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: 构建可执行文件 | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: 构建于 ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| env: | |
| PYTHONUTF8: "1" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: windows-latest | |
| executable: dist/XHS-Downloader/XHS-Downloader.exe | |
| artifact: XHS-Downloader_Windows_X64 | |
| - os: windows-11-arm | |
| executable: dist/XHS-Downloader/XHS-Downloader.exe | |
| artifact: XHS-Downloader_Windows_ARM64 | |
| - os: macos-15-intel | |
| executable: dist/XHS-Downloader/XHS-Downloader | |
| artifact: XHS-Downloader_macOS_X64 | |
| - os: macos-latest | |
| executable: dist/XHS-Downloader/XHS-Downloader | |
| artifact: XHS-Downloader_macOS_ARM64 | |
| steps: | |
| - name: 签出存储库 | |
| uses: actions/checkout@v4 | |
| - name: 设置 uv | |
| uses: astral-sh/setup-uv@v9.0.0 | |
| with: | |
| enable-cache: true | |
| - name: 安装依赖项 | |
| run: | | |
| uv python install 3.12 | |
| uv sync --frozen --no-dev --no-install-project --python 3.12 | |
| uv pip install cx_Freeze | |
| - name: 获取构建日期 | |
| run: >- | |
| uv run --no-sync python -c | |
| "from datetime import datetime; from os import environ; open(environ['GITHUB_ENV'], 'a', encoding='utf-8').write(f'DATE={datetime.now():%Y%m%d}\n')" | |
| - name: 构建可执行文件 | |
| run: uv run --no-sync python setup.py build_exe --build-exe dist/XHS-Downloader | |
| - name: 验证可执行文件 | |
| run: >- | |
| uv run --no-sync python -c | |
| "import subprocess; subprocess.run([r'${{ matrix.executable }}', '--version'], check=True)" | |
| - name: 上传构建产物 | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact }}_${{ env.DATE }} | |
| path: dist/XHS-Downloader | |
| if-no-files-found: error |