Skip to content
Open
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
62 changes: 62 additions & 0 deletions .github/workflows/notify-wrappers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Tells the cross-platform wrappers (Flutter, Expo, KMP) that a new native SDK
# release exists. Each wrapper's native-sdk-bump.yml picks the event up, bumps
# its pinned native version, and opens a PR (with any integration work done by
# an agent on top).
#
# iOS releases are created by hand (tag-version.yml only pings Slack), so
# `release: published` fires for them. `published` rather than `created`:
# `created` also fires for drafts.
#
# Requires the WRAPPER_DISPATCH_TOKEN secret: a fine-grained PAT (or GitHub App
# token) with "Contents: read & write" on every repo in WRAPPER_REPOS — that is
# the permission the repository_dispatch API checks. GITHUB_TOKEN cannot
# dispatch into other repositories.
name: Notify wrapper SDKs

on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: Released version to announce (e.g. 4.18.0)
required: true
type: string

permissions:
contents: read

env:
PLATFORM: ios
WRAPPER_REPOS: superwall/Superwall-Flutter superwall/expo-superwall superwall/Superwall-KMP

jobs:
dispatch:
runs-on: ubuntu-latest
# Wrappers only ship stable native versions.
if: github.event_name != 'release' || !github.event.release.prerelease
steps:
- name: Dispatch native-sdk-release
env:
GH_TOKEN: ${{ secrets.WRAPPER_DISPATCH_TOKEN }}
VERSION: ${{ inputs.version || github.event.release.tag_name }}
run: |
VERSION="${VERSION#v}"
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::notice::'$VERSION' is not a stable x.y.z version, not notifying wrappers."
exit 0
fi
failed=0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tag-version.yml runs pod trunk push and the Slack "please create a release" ping at the same time, since both only depend on tag. Trunk push is a macOS lint and build that can take a while or fail outright, so a release can be published before the pod exists on CocoaPods. When that happens, Flutter and Expo get a bump PR whose pod install can't resolve SuperwallKit at that version. Consider waiting for the version to show up on trunk before dispatching. The manual workflow_dispatch path can still be used to re-send the event.

Technical details
# Dispatch can race the CocoaPods trunk push

## Affected sites
- .github/workflows/notify-wrappers.yml:49 — dispatches right after the version check passes
- .github/workflows/tag-version.yml — `cocoapods` and `slack` jobs both `needs: tag` and run in parallel

## Required outcome
- Wrappers that consume iOS through CocoaPods are only notified once `SuperwallKit $VERSION` can be resolved from trunk. If it never appears, the run fails visibly instead of opening bump PRs that can't build.

## Suggested approach
Before the loop, poll the trunk API with a bounded timeout:
```bash
for _ in $(seq 1 60); do
  curl -sfo /dev/null "https://trunk.cocoapods.org/api/v1/pods/SuperwallKit/specs/$VERSION" && break
  sleep 30
done || true
curl -sfo /dev/null "https://trunk.cocoapods.org/api/v1/pods/SuperwallKit/specs/$VERSION" \
  || { echo "::error::SuperwallKit $VERSION not on CocoaPods trunk"; exit 1; }
```
CDN propagation can lag trunk slightly, but this closes most of the window.

for repo in $WRAPPER_REPOS; do
# One wrapper being unreachable must not stop the others.
if gh api "repos/$repo/dispatches" \
-f event_type=native-sdk-release \
-f "client_payload[platform]=$PLATFORM" \
-f "client_payload[version]=$VERSION"; then
echo "Notified $repo of $PLATFORM $VERSION"
else
echo "::error::Could not dispatch to $repo"
failed=1
fi
done
exit $failed