Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated README with Swift Package support instructions. #74

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ When using **Github deploy keys**, GitHub servers will accept the _first_ known

To support picking the right key in this use case, this action scans _key comments_ and will set up extra Git and SSH configuration to make things work.

1. When creating the deploy key for a repository like `[email protected]:owner/repo.git` or `https://github.com/owner/repo`, put that URL into the key comment.
1. When creating the deploy key for a repository like `[email protected]:owner/repo.git` or `https://github.com/owner/repo`, put that URL into the key comment. You can do so using this command: `ssh-keygen -b 4096 -t rsa -N "" -f key -C "[email protected]:my-org/my-repo.git"`
2. After keys have been added to the agent, this action will scan the key comments.
3. For key comments containing such URLs, a Git config setting is written that uses [`url.<base>.insteadof`](https://git-scm.com/docs/git-config#Documentation/git-config.txt-urlltbasegtinsteadOf). It will redirect `git` requests to URLs starting with either `https://github.com/owner/repo` or `[email protected]:owner/repo` to a fake hostname/URL like `[email protected]...:owner/repo`.
4. An SSH configuration section is generated that applies to the fake hostname. It will map the SSH connection back to `github.com`, while at the same time pointing SSH to a file containing the appropriate key's public part. That will make SSH use the right key when connecting to GitHub.com.
Expand Down Expand Up @@ -126,6 +126,43 @@ env:
CARGO_NET_GIT_FETCH_WITH_CLI: true
```

### Support for Swift Packages hosted in private repository

If you are using a privately hosted Swift Package dependency in your project, there are a few additional steps to take in order for SPM to properly authenticate with your private swift package repo:

**In the private Swift Package Repo follow these steps:**

* Create a `.ssh` directory in the root: `mkdir .ssh`
* Change to the `.ssh` directory: `cd .ssh`
* Generate an SSH key pair using the repo's ssh url as a comment: `ssh-keygen -b 4096 -t rsa -N "" -f key -C "[email protected]:my-org/my-swift-package-repo.git"`
* Create a `.config` file and add the following:

```
Host github.com
HostName github.com
User git
IdentityFile ./.ssh/key
UseKeychain yes # for macOS keychain
AddKeysToAgent yes # for macOS keychain
PreferredAuthentications publickey
```

* Commit these changes.
* Go to your repo's **Deploy Keys** page: `https://github.com/my-org/my-swift-package-repo/settings/keys`
* Create a **Deploy Key** using the contents of the previously generated **public** ssh key: : `.ssh/key.pub` *(Example key name: SSH\_PUBLIC\_KEY)*

**In the repo that depends on the private Swift Package follow these steps:**

* Go to your repo's **Secrets** page: `https://github.com/my-org/my-swift-package-repo/settings/secrets/actions`
* Create a **Secret** using the contents of the **private** key you generated above: `private-swift-package/.ssh/key` *(Example key name: SPM\_SSH\_PRIVATE\_KEY)*
* Update your `xcodebuild` command to include `-scmProvider system` as that specifies SPM to use the current system's git configuration and **NOT** Xcode's.:

```
- name: Build Xcode App
run: |
xcodebuild build -workspace MyCoolApp.xcworkspace -scheme MyCoolAppExample -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 12 Pro,OS=14.4' -scmProvider system
```

## What this Action *cannot* do for you

The following items are not issues, but beyond what this Action is supposed to do.
Expand Down