Skip to content
Merged
Show file tree
Hide file tree
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
32 changes: 28 additions & 4 deletions .github/actions/setup-mistkit/action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Setup MistKit
description: Replaces the local MistKit path dependency with a remote branch reference
description: Replaces the local MistKit path dependency with a remote reference, pinned to the branch's current commit

inputs:
branch:
Expand All @@ -8,19 +8,43 @@ inputs:
runs:
using: composite
steps:
# Resolve the branch to its current HEAD commit and pin the dependency by
# `revision:` rather than `branch:`. This makes the dependency content-addressed,
# so `swift package dump-package` (which swift-build@v1 hashes for its cache key)
# changes whenever the MistKit branch advances — otherwise a new MistKit commit on
# the same branch yields a stale cache hit and is never rebuilt. Falls back to a
# `branch:` pin if the ref can't be resolved (e.g. offline).
- name: Update Package.swift (Unix)
if: inputs.branch != '' && runner.os != 'Windows'
shell: bash
run: |
BRANCH='${{ inputs.branch }}'
REF=$(git ls-remote https://github.com/brightdigit/MistKit.git "$BRANCH" | head -n1 | cut -f1)
if [ -n "$REF" ]; then
REQ='revision: "'"$REF"'"'
echo "Pinning MistKit to $BRANCH @ $REF"
else
REQ='branch: "'"$BRANCH"'"'
echo "Could not resolve $BRANCH to a commit; pinning by branch"
fi
if [ "$RUNNER_OS" = "macOS" ]; then
sed -i '' 's|\.package(name: "MistKit", path: "\.\./\.\.")|.package(url: "https://github.com/brightdigit/MistKit.git", branch: "'"${{ inputs.branch }}"'")|g' Package.swift
sed -i '' 's|\.package(name: "MistKit", path: "\.\./\.\.")|.package(url: "https://github.com/brightdigit/MistKit.git", '"$REQ"')|g' Package.swift
else
sed -i 's|\.package(name: "MistKit", path: "\.\./\.\.")|.package(url: "https://github.com/brightdigit/MistKit.git", branch: "'"${{ inputs.branch }}"'")|g' Package.swift
sed -i 's|\.package(name: "MistKit", path: "\.\./\.\.")|.package(url: "https://github.com/brightdigit/MistKit.git", '"$REQ"')|g' Package.swift
fi
rm -f Package.resolved
- name: Update Package.swift (Windows)
if: inputs.branch != '' && runner.os == 'Windows'
shell: pwsh
run: |
(Get-Content Package.swift) -replace '\.package\(name: "MistKit", path: "\.\./\.\."\)', ".package(url: `"https://github.com/brightdigit/MistKit.git`", branch: `"${{ inputs.branch }}`")" | Set-Content Package.swift
$branch = '${{ inputs.branch }}'
$ref = (git ls-remote https://github.com/brightdigit/MistKit.git $branch | Select-Object -First 1) -split "`t" | Select-Object -First 1
if ($ref) {
$req = "revision: `"$ref`""
Write-Host "Pinning MistKit to $branch @ $ref"
} else {
$req = "branch: `"$branch`""
Write-Host "Could not resolve $branch to a commit; pinning by branch"
}
(Get-Content Package.swift) -replace '\.package\(name: "MistKit", path: "\.\./\.\."\)', ".package(url: `"https://github.com/brightdigit/MistKit.git`", $req)" | Set-Content Package.swift
Remove-Item -Path Package.resolved -Force -ErrorAction SilentlyContinue
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
[![Maintainability](https://qlty.sh/badges/55637213-d307-477e-a710-f9dba332d955/maintainability.svg)](https://qlty.sh/gh/brightdigit/projects/MistKit)
[![Documentation](https://img.shields.io/badge/docc-read_documentation-blue)](https://swiftpackageindex.com/brightdigit/MistKit/documentation)

A Swift Package for Server-Side and Command-Line Access to [CloudKit Web Services](https://developer.apple.com/documentation/cloudkitwebservices)
A Swift Package for Server-Side and Command-Line Access to [CloudKit Web Services](https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitWebServicesReference/index.html)

## Table of Contents
- [Overview](#overview)
Expand Down Expand Up @@ -330,7 +330,7 @@ Check out the `Examples/` directory for complete working examples:

### Apple References

- **[CloudKit Web Services](https://developer.apple.com/documentation/cloudkitwebservices)**: Official CloudKit Web Services REST API documentation
- **[CloudKit Web Services](https://developer.apple.com/library/archive/documentation/DataManagement/Conceptual/CloudKitWebServicesReference/index.html)**: Official CloudKit Web Services REST API documentation
- **[CloudKit framework](https://developer.apple.com/documentation/cloudkit)**: On-device CloudKit framework (iOS/macOS)
- **[CloudKit JS](https://developer.apple.com/documentation/cloudkitjs)**: Browser-based CloudKit access used for web auth token capture
- **[CKFetchWebAuthTokenOperation](https://developer.apple.com/documentation/cloudkit/ckfetchwebauthtokenoperation)**: iOS/macOS API for exchanging an iCloud session for a web auth token
Expand Down
Loading