Skip to content

Add cross-platform desktop app packaging (PyInstaller + GitHub Actions) #1

Add cross-platform desktop app packaging (PyInstaller + GitHub Actions)

Add cross-platform desktop app packaging (PyInstaller + GitHub Actions) #1

Workflow file for this run

name: Release
# 打一个 v* 版本标签(例:git tag v0.2.0 && git push --tags)就会:
# 在 Windows / macOS / Linux 各构建一份桌面 app,压缩,发布到一个 GitHub Release。
# 也可在 Actions 页手动触发(workflow_dispatch)只构建、不发布。
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write # 发布 Release 需要写权限
jobs:
build:
name: Build (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
asset: viralens-windows-x64.zip
- os: macos-latest
asset: viralens-macos-arm64.zip
- os: ubuntu-latest
asset: viralens-linux-x64.zip
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12" # 各重依赖在 3.12 上 wheel 最全、最稳
- name: Install deps + PyInstaller
run: |
python -m pip install --upgrade pip
python -m pip install -e .
python -m pip install pyinstaller
- name: Build (PyInstaller, onedir)
run: python -m PyInstaller --noconfirm --clean packaging/viralens.spec
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: Compress-Archive -Path dist/viralens -DestinationPath ${{ matrix.asset }}
- name: Package (macOS) # ditto 是 mac 上正确打包 .app 的方式(保留符号链接/权限)
if: runner.os == 'macOS'
run: ditto -c -k --keepParent dist/viralens.app ${{ matrix.asset }}
- name: Package (Linux) # zip 保留可执行位,解压后 ./viralens/viralens 直接能跑
if: runner.os == 'Linux'
run: (cd dist && zip -ry ../${{ matrix.asset }} viralens)
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset }}
path: ${{ matrix.asset }}
if-no-files-found: error
release:
name: Publish Release
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: artifacts/*.zip
generate_release_notes: true
body: |
## viralens 桌面版下载
按你的系统选一个,**下载 → 解压 → 双击即用**,无需自己装 Python。
| 系统 | 文件 | 怎么打开 |
|---|---|---|
| Windows | `viralens-windows-x64.zip` | 解压后运行文件夹里的 `viralens.exe` |
| macOS (Apple Silicon) | `viralens-macos-arm64.zip` | 解压得 `viralens.app`,见下方 macOS 首次打开说明 |
| Linux (x64) | `viralens-linux-x64.zip` | 解压后运行 `./viralens/viralens` |
> **首次打开提示是正常的 —— 因为这个 app 没有花钱做苹果/微软的代码签名,不是有问题。**
> - **Windows**:若弹出「Windows 已保护你的电脑」,点 **更多信息 → 仍要运行**。
> - **macOS**:先试 **右键 → 打开**;若提示「已损坏 / 无法验证开发者」(macOS 15 Sequoia 起常见),改去 **系统设置 → 隐私与安全性**,在底部点「**仍要打开**」;或在终端执行 `xattr -dr com.apple.quarantine /把/viralens.app/拖进来` 后再双击。
启动后浏览器会自动打开界面。首次在界面里填入你的 **B站 SESSDATA** 和/或 **YouTube API key** 即可开始抓取分析。
> 可选功能「下视频分析开场镜头 + 配乐」需要自行安装 **ffmpeg**(其余抓取 / 分析 / 报告功能都无需它)。