fix: build both Intel and Apple Silicon architectures for macOS
This commit is contained in:
parent
cb3a661611
commit
1b54447ccb
42
.github/workflows/build.yml
vendored
42
.github/workflows/build.yml
vendored
@ -38,7 +38,10 @@ jobs:
|
|||||||
|
|
||||||
# 2. 编译 macOS 端 (.app)
|
# 2. 编译 macOS 端 (.app)
|
||||||
build-macos:
|
build-macos:
|
||||||
runs-on: macos-latest
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [macos-13, macos-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -55,21 +58,29 @@ jobs:
|
|||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
pip install pyinstaller Pillow
|
pip install pyinstaller Pillow
|
||||||
|
|
||||||
|
- name: Set Architecture Name
|
||||||
|
run: |
|
||||||
|
if [ "${{ matrix.os }}" = "macos-13" ]; then
|
||||||
|
echo "ARCH_NAME=Intel" >> $GITHUB_ENV
|
||||||
|
else
|
||||||
|
echo "ARCH_NAME=AppleSilicon" >> $GITHUB_ENV
|
||||||
|
fi
|
||||||
|
shell: bash
|
||||||
|
|
||||||
- name: Build App Bundle
|
- name: Build App Bundle
|
||||||
run: |
|
run: |
|
||||||
python -m PyInstaller build.spec --clean
|
python -m PyInstaller build.spec --clean
|
||||||
|
|
||||||
- name: Zip macOS App
|
- name: Zip macOS App
|
||||||
run: |
|
run: |
|
||||||
# macOS app 实质上是文件夹,发布前需要打包成 zip
|
|
||||||
cd dist
|
cd dist
|
||||||
zip -r CursorTokenLogin-macOS.zip CursorTokenLogin.app
|
zip -r CursorTokenLogin-macOS-${{ env.ARCH_NAME }}.zip CursorTokenLogin.app
|
||||||
|
|
||||||
- name: Upload macOS Artifact
|
- name: Upload macOS Artifact
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: CursorTokenLogin-macOS
|
name: CursorTokenLogin-macOS-${{ env.ARCH_NAME }}
|
||||||
path: dist/CursorTokenLogin-macOS.zip
|
path: dist/CursorTokenLogin-macOS-${{ env.ARCH_NAME }}.zip
|
||||||
|
|
||||||
# 3. 编译 Linux 端并打包为 .deb 和 .rpm
|
# 3. 编译 Linux 端并打包为 .deb 和 .rpm
|
||||||
build-linux:
|
build-linux:
|
||||||
@ -153,36 +164,25 @@ jobs:
|
|||||||
cursortokenlogin.deb
|
cursortokenlogin.deb
|
||||||
cursortokenlogin.rpm
|
cursortokenlogin.rpm
|
||||||
|
|
||||||
# 4. 自动创建 GitHub Release 并上传 4 个包
|
# 4. 自动创建 GitHub Release 并上传 5 个包
|
||||||
create-release:
|
create-release:
|
||||||
needs: [build-windows, build-macos, build-linux]
|
needs: [build-windows, build-macos, build-linux]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: startsWith(github.ref, 'refs/tags/v') # 仅在推送 tag 时执行 Release 发布
|
if: startsWith(github.ref, 'refs/tags/v') # 仅在推送 tag 时执行 Release 发布
|
||||||
steps:
|
steps:
|
||||||
- name: Download Windows Artifact
|
- name: Download All Artifacts
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: CursorTokenLogin-Windows
|
|
||||||
path: ./release-files
|
|
||||||
|
|
||||||
- name: Download macOS Artifact
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: CursorTokenLogin-macOS
|
|
||||||
path: ./release-files
|
|
||||||
|
|
||||||
- name: Download Linux Artifacts
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
|
||||||
name: CursorTokenLogin-Linux
|
|
||||||
path: ./release-files
|
path: ./release-files
|
||||||
|
merge-multiple: true
|
||||||
|
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
uses: softprops/action-gh-release@v2
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
release-files/CursorTokenLogin.exe
|
release-files/CursorTokenLogin.exe
|
||||||
release-files/CursorTokenLogin-macOS.zip
|
release-files/CursorTokenLogin-macOS-Intel.zip
|
||||||
|
release-files/CursorTokenLogin-macOS-AppleSilicon.zip
|
||||||
release-files/cursortokenlogin.deb
|
release-files/cursortokenlogin.deb
|
||||||
release-files/cursortokenlogin.rpm
|
release-files/cursortokenlogin.rpm
|
||||||
env:
|
env:
|
||||||
|
|||||||
@ -29,11 +29,12 @@
|
|||||||
# 2. 将 tag 单独推送到 github 触发云端自动构建
|
# 2. 将 tag 单独推送到 github 触发云端自动构建
|
||||||
git push github vx.x.x
|
git push github vx.x.x
|
||||||
```
|
```
|
||||||
3. GitHub Actions 收到 Tag 后会自动触发构建,云端会启动三个环境:
|
3. GitHub Actions 收到 Tag 后会自动触发构建,云端会启动多个编译任务,最终产出:
|
||||||
- 💻 **Windows**:编译出 `CursorTokenLogin.exe`
|
- 💻 **Windows**:编译出 `CursorTokenLogin.exe`
|
||||||
- 🍏 **macOS**:编译出 `CursorTokenLogin-macOS.zip` (内含 `.app` 应用程序)
|
- 🍏 **macOS (M1/M2/M3 芯片)**:编译出 `CursorTokenLogin-macOS-AppleSilicon.zip` (解压即得 `.app`)
|
||||||
|
- 🍏 **macOS (Intel 芯片)**:编译出 `CursorTokenLogin-macOS-Intel.zip` (解压即得 `.app`)
|
||||||
- 🐧 **Linux**:编译出 Linux 运行文件,并自动打包为 `cursortokenlogin.deb` 和 `cursortokenlogin.rpm`
|
- 🐧 **Linux**:编译出 Linux 运行文件,并自动打包为 `cursortokenlogin.deb` 和 `cursortokenlogin.rpm`
|
||||||
4. **下载成品**:构建完成后(耗时约 3~5 分钟),GitHub 会自动在您的仓库右侧 **Releases** 栏目中生成一个名为 `v1.0.0` 的发布页,进入即可直接下载编译好的 4 个包!
|
4. **下载成品**:构建完成后(耗时约 3~5 分钟),GitHub 会自动在您的仓库右侧 **Releases** 栏目中生成一个名为 `v1.0.0` 的发布页,进入即可直接下载编译好的 5 个安装包!
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user