Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

ci(sdk-release): auto-sync Swift mirror + tag on npm publish

Louis Beaumontbda48c884a89
diff --git a/.github/workflows/sdk-release.yml b/.github/workflows/sdk-release.yml
index 08a57f787..c874888a9 100644
--- a/.github/workflows/sdk-release.yml
+++ b/.github/workflows/sdk-release.yml
@@ -188,3 +188,66 @@ jobs:
done < <(find npm -mindepth 1 -maxdepth 1 -type d -print0 | sort -z)
npm publish --access public --tag "$NPM_TAG" --provenance
+
+ swift-mirror:
+ # SPM cannot consume `ee/sdk/Package.swift` from a subdirectory of a
+ # repo, so the Swift SDK ships from a separate mirror repo
+ # (`screenpipe/screenpipe-sdk-swift`) where `Package.swift` is at the
+ # root. This job keeps the mirror in lockstep with npm: every time we
+ # publish `@screenpipe/[email protected]`, we sync the Swift sources and tag
+ # `vX.Y.Z` on the mirror so SPM consumers get the matching version.
+ #
+ # Manual sync drift bit us once (mirror sat at v0.1.0 while npm was at
+ # v0.4.1) — gating this on the same `publish_npm` confirmation makes
+ # the two channels move together by construction.
+ needs: [validate, npm]
+ if: needs.validate.outputs.publish_npm == 'true'
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ steps:
+ - uses: actions/checkout@v4
+ - name: Sync Swift sources into screenpipe-sdk-swift mirror
+ env:
+ # PAT must have `repo` scope on screenpipe/screenpipe-sdk-swift.
+ # We reuse the existing PAT secret (already used by release-app)
+ # rather than minting a separate one — same trust boundary, one
+ # less secret to rotate.
+ GH_TOKEN: ${{ secrets.PAT }}
+ VERSION: ${{ inputs.version }}
+ run: |
+ set -euo pipefail
+ if [[ -z "${GH_TOKEN:-}" ]]; then
+ echo "::error::PAT secret is required to push to the Swift mirror"
+ exit 1
+ fi
+
+ work=$(mktemp -d)
+ git clone "https://x-access-token:${GH_TOKEN}@github.com/screenpipe/screenpipe-sdk-swift.git" "$work/mirror"
+
+ # Per-directory rsync (not a root mirror) so the mirror's
+ # Swift-specific README.md / LICENSE.md aren't clobbered by the
+ # monorepo-wide README that documents Electron + Tauri + Node.
+ rsync -a --delete ee/sdk/Sources/ "$work/mirror/Sources/"
+ rsync -a --delete ee/sdk/Tests/ "$work/mirror/Tests/"
+ cp ee/sdk/Package.swift "$work/mirror/Package.swift"
+
+ cd "$work/mirror"
+ git config user.name "screenpipe-bot"
+ git config user.email "[email protected]"
+
+ if git diff --quiet; then
+ echo "Swift mirror already at v${VERSION} — nothing to sync"
+ else
+ git add Sources Tests Package.swift
+ git commit -m "chore: sync Swift SDK to v${VERSION}"
+ git push origin main
+ fi
+
+ # Tag even if the tree was identical — the mirror may have been
+ # synced ad-hoc earlier and just be missing the tag.
+ if git rev-parse "v${VERSION}" >/dev/null 2>&1; then
+ echo "Tag v${VERSION} already exists on mirror, skipping"
+ else
+ git tag "v${VERSION}"
+ git push origin "v${VERSION}"
+ fi