Skip to content

fix(mac): use pillow instead of sips for icns conversion to prevent e… #6

fix(mac): use pillow instead of sips for icns conversion to prevent e…

fix(mac): use pillow instead of sips for icns conversion to prevent e… #6

Workflow file for this run

name: Build macOS App
on:
push:
branches: [ "main", "master" ]
workflow_dispatch: # 允许手动触发打包
jobs:
build:
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller pillow
- name: Compile Swift Helper
working-directory: ./Mac
run: |
# 编译 Swift 脚本为可执行的二进制文件
swiftc nowplaying.swift -o mac_nowplaying
chmod +x mac_nowplaying
- name: Build with PyInstaller
working-directory: ./Mac
run: |
# 使用 Pillow 无损将 PNG 转换为 macOS 专用的 .icns 格式 (绕过 sips 的色彩配置文件报错)
python -c "from PIL import Image; Image.open('../Windows/Assets/CarpeCast-logo.png').resize((512,512)).save('icon.icns')"
# 使用 --windowed 打包,指定名字和图标
pyinstaller --windowed --name "CarpeCast" --icon=icon.icns --add-binary "mac_nowplaying:." sender.py
# 压缩 .app 以防 GitHub Actions 上传时吞掉顶层目录
cd dist
zip -ry CarpeCast-Mac.zip CarpeCast.app
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: CarpeCast-Mac
path: Mac/dist/CarpeCast-Mac.zip