Yak*_*hzi 15 ssh xcode xcodebuild swift-package-manager github-actions
我正在尝试使用 Github Actions 构建一个 macOS 应用程序。这已经很有效了,直到我将我的依赖项迁移到 Swift Package Manager。现在我在构建我的应用程序时收到以下错误:
xcodebuild: error: Could not resolve package dependencies:
The server SSH fingerprint failed to verify.
我有一个私有 GitHub 存储库作为我的应用程序中的依赖项,使用 ssh 位置添加为 Swift 包。因此,我需要在Set up ssh-agent步骤中为依赖项添加我的 ssh 密钥。在一个步骤中手动克隆存储库git clone工作正常,但我需要让它与 xcodebuild 一起使用才能成功构建我的应用程序。
name: Main
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
name: Release
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Set up ssh-agent
uses: yakuhzi/action-ssh-agent@v1
with:
public: ${{ secrets.SSH_PUBLIC_KEY }}
private: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Build application
run: |
sudo xcode-select -switch /Applications/Xcode_11.app
xcodebuild -project Application.xcodeproj -scheme Application -configuration Release -derivedDataPath $HOME/Application build
Run Code Online (Sandbox Code Playgroud)
Yak*_*hzi 21
最后我想通了。这似乎是 Xcode 11 ( https://developer.apple.com/documentation/xcode_release_notes/xcode_11_release_notes ) 中的一个已知问题。
感谢这篇文章中的 Dosium(https://discuss.bitrise.io/t/xcode-11-resolving-packages-fails-with-ssh-fingerprint/10388),我能够让它工作。
解决方法是在运行xcodebuild之前运行以下命令:
for ip in $(dig @8.8.8.8 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts
TS 要求解决对私有存储库的依赖问题,但为了以防万一有人在公共存储库依赖项上遇到此问题,请确保您对该依赖关系存储库地址使用 HTTPS 而不是 SSH。
https://github.com/Alamofire/Alamofire.git
Run Code Online (Sandbox Code Playgroud)
代替
git@github.com:Alamofire/Alamofire.git
Run Code Online (Sandbox Code Playgroud)
为了CircleCI:
添加到 Yakuhzi 的答案中,这是 Circle Ci 的 yaml 文件中的步骤:
- run:
name: Enable SSH
command: |
for ip in $(dig @8.8.8.8 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4531 次 |
| 最近记录: |