diff --git a/.github/workflows/notify-wrappers.yml b/.github/workflows/notify-wrappers.yml new file mode 100644 index 000000000..480c4e376 --- /dev/null +++ b/.github/workflows/notify-wrappers.yml @@ -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 + 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