# 怎么自建 GitHub Actions 的 macOS Runner？

> 用租来的 Mac mini 运行 GitHub Actions 自托管 macOS Runner 的步骤。Ship 月租 $139，CI 套餐一年 $1,783.20。加密货币付款，免实名。

- URL: https://rentcloudmac.com/zh/use-cases/github-actions-macos-runner/
- Last updated: 2026-12-03
- 发布者: RentCloudMac (https://rentcloudmac.com)

GitHub 托管的 macOS Runner 按分钟计费。如果每天都要构建，可以把按月固定收费的 Mac mini 配成自托管 Runner。下面整理了注册步骤和配置选择。

**简短回答 — 怎样拥有自己的 GitHub Actions macOS Runner？**

准备一台 Mac，在仓库的 Settings → Actions → Runners 下载 actions-runner，用 `./config.sh` 注册，再用 `./svc.sh` 注册为服务。**RentCloudMac** 的 M4、24 GB Ship 月租 $139；包含 Runner 代配置、Xcode 代装和优先支持的 CI 套餐一年 $1,783.20。可用 Monero 或比特币付款。

**要点**

- **固定价格随便用**：自托管 Runner 只付 Mac 的月租，不按构建分钟计费。
- **默认选 Ship**：24 GB 加 512 GB，跑一个 Runner、放两个 Xcode 版本都宽裕。
- **CI 套餐**：Ship 12 个月、CI Runner 代配置、Xcode 与 Fastlane 代装、12 个月优先支持，共 $1,783.20（折合每月 $148.60）。
- **安全**：GitHub 建议不要在公开仓库中使用自托管 Runner。
- **要多个 Runner**：Matrix（14 核、64 GB）一台就能跑多个 Runner。

## 注册 Runner 的步骤是什么？

1. **安装 Xcode** — 用 xcodes 安装任务要用的 Xcode，接受许可，并执行 xcodebuild -runFirstLaunch。
2. **下载 Runner** — 在 GitHub 仓库或组织的 Settings → Actions → Runners → New self-hosted runner 中选择 macOS、ARM64，用页面上显示的命令下载并解压。
3. **注册** — 执行 ./config.sh --url <仓库 URL> --token <页面显示的令牌> --labels m4,xcode。令牌很快就会过期。
4. **注册为服务** — 执行 ./svc.sh install 和 ./svc.sh start，重启后也会自动启动。
5. **在工作流中指定** — 写上 runs-on: [self-hosted, macOS, ARM64]，任务就会在这台 Mac 上运行。

*注册 Runner（远程 Mac 的终端）*

```bash
mkdir ~/actions-runner && cd ~/actions-runner
# 下载 URL 和版本请使用 GitHub 页面上显示的值
curl -o actions-runner.tar.gz -L <GitHub 显示的 osx-arm64 URL>
tar xzf actions-runner.tar.gz

./config.sh --url https://github.com/your-org/your-app --token <TOKEN> --labels m4,xcode
./svc.sh install
./svc.sh start
./svc.sh status
```

*.github/workflows/ios.yml 示例*

```yaml
name: iOS
on: [push]
jobs:
  build:
    runs-on: [self-hosted, macOS, ARM64]
    steps:
      - uses: actions/checkout@v4
      - name: Build and test
        run: |
          xcodebuild -project MyApp.xcodeproj -scheme MyApp \
            -destination 'platform=iOS Simulator,name=iPhone 16' test
```

## 不同规模的 Runner 适合哪种配置？

*自托管 macOS Runner 的用途与 RentCloudMac 配置（2026 年 12 月）*

| 用途 | 配置 | 月租 | 12 个月合约折合月租 |
| --- | --- | --- | --- |
| 小团队，一个 Runner | Ship | $139（约 926 元） | $125.10 |
| 大型应用，缓存多 | Release | $189 | $170.10 |
| 全量构建多 | Pipeline | $249 | $224.10 |
| 并行测试，多个 Runner | Matrix | $299（约 1,991 元） | $269.10 |
| CI 套餐（Ship 12 个月 + Runner 配置 + Xcode 代装 + 优先支持） | Ship | — | $148.60 |

## 什么情况下比 GitHub 托管的 Runner 划算？

**每天都有大量长时间构建的团队，用固定月租的自托管 Runner，费用更好预估。** GitHub 托管的 macOS Runner 按使用分钟计费，构建越多费用越高。自托管时，除了 Mac 的月租，只需要投入自己的维护时间。缓存和 DerivedData 留在 Mac 上，第二次以后的构建也不必重新下载依赖。

反过来，如果每个月只构建几次，托管 Runner 或 CI 服务可能更便宜。对于在国内访问 GitHub 下载依赖较慢的团队，缓存留在同一台 Mac 上的好处更明显。

## 和 AWS、MacStadium 的 Mac 比怎么样？

**根据 RentCloudMac 2026 年 12 月 3 日的价格调查，M4、24 GB 的 Mac mini 在 MacStadium 月租 $249.00，AWS 的 mac-m4.metal 730 小时为 $897.90（11 月 17 日读取）。** Ship 的 $139 与两者分别相差 −44% 和 −85%。AWS 擅长配合 IAM 和 API 按天增减主机数量；对一直运行的 Runner 来说，固定月租更有优势。详见 [RentCloudMac 与 AWS EC2 Mac 对比](https://rentcloudmac.com/zh/vs/aws-ec2-mac/ "RentCloudMac 与 AWS EC2 Mac 对比")。

## Runner 的配置能交给别人做吗？

**能。加购 CI Runner 代配置服务后，工作人员会注册 GitHub Actions 或 GitLab 的自托管 Runner，设为开机自动运行的服务，并跑一次测试任务。** 再配合 Xcode 与 Fastlane 代装服务，交付时就已经可以构建。这两项默认都不勾选，在下单时选择。

如果还要自动上传到 App Store，按[如何签名 iOS 应用并上架 App Store](https://rentcloudmac.com/zh/guides/how-to-sign-ios-app-and-upload-to-app-store/ "如何签名 iOS 应用并上架 App Store")中的 API 密钥和 Fastlane 步骤配置即可。

## GitHub Actions macOS Runner 常见问题

### 可以在公开仓库里用吗？

GitHub 不建议在公开仓库使用自托管 Runner，因为来自 fork 的拉取请求可能执行任意代码。请在私有仓库中使用。

### 能做成 GitLab Runner 吗？

能。安装 gitlab-runner，用 shell executor 注册即可同样使用。代配置服务也支持 GitLab。

### 一台 Mac 能跑多个 Runner 吗？

能，分不同目录注册多个。要同时构建就需要更多内存，Matrix 的 64 GB 更合适。

### macOS 更新会让 Runner 停下来吗？

比较安全的做法是不开自动更新，手动更新后再确认运行情况。加购托管 Mac 服务后，macOS 和 Xcode 的更新与监控由工作人员负责。

### Runner 构建有多快？

RentCloudMac 没有测量构建时间，也不发布相关数据。M4 Pro 配置的性能核心更多。

**结论**

- 每天构建的团队，把 Ship（$139）配成自托管 Runner，费用就固定了。
- 想连配置一起交出去，选 CI 套餐（一年 $1,783.20）。
- 并行测试和多个 Runner 选 Matrix，所有配置可在[价格](https://rentcloudmac.com/zh/pricing/ "RentCloudMac 价格")页比较。

**准备一台跑 CI 的 Mac** 租 Ship 12 个月，在结账时选择 CI Runner 代配置，工作人员会帮你注册 Runner。 [租 Ship 12 个月（每月 $125.10）](https://rentcloudmac.com/app/checkout/?plan=ship&term=12m&from=use-cases-github-actions-macos-runner&lang=zh)

## 来源

1. [Adding self-hosted runners](https://docs.github.com/en/actions/hosting-your-own-runners/managing-self-hosted-runners/adding-self-hosted-runners) — GitHub
2. [Security hardening for GitHub Actions](https://docs.github.com/en/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions) — GitHub
3. [MacStadium pricing](https://www.macstadium.com/pricing) — MacStadium (2026-12-03 读取)
4. [Amazon EC2 Mac instances](https://aws.amazon.com/ec2/instance-types/mac/) — Amazon Web Services (2026-11-17 读取)
5. [European Central Bank reference rates of 2 December 2026](https://www.ecb.europa.eu/stats/policy_and_exchange_rates/euro_reference_exchange_rates/html/index.en.html) — European Central Bank (2026-12-02)

---

RentCloudMac: RentCloudMac 在数据中心出租整台 Apple Mac mini（M4、M4 Pro），用于 iOS 和 macOS 应用的编译、签名、测试与上架，通过 SSH 和屏幕共享远程使用。五种配置每月 $92 至 $299，只收加密货币（Monero、比特币、USDT 等 7 种），免 KYC，付款确认后 24 小时内交付。
