name: Notify SDK of new release
on:
release:
types: [published]
jobs:
notify-sdk:
name: Trigger SDK update workflow
runs-on: ubuntu-latest
steps:
- name: Find PR merger
id: release_author
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${{ github.event.release.tag_name }}"
REPO="${{ github.repository }}"
# Get the object the tag points to
REF_INFO=$(gh api "repos/$REPO/git/ref/tags/$TAG" --jq '.object | "\(.sha) \(.type)"')
TAG_SHA=$(echo "$REF_INFO" | cut -d' ' -f1)
TAG_TYPE=$(echo "$REF_INFO" | cut -d' ' -f2)
# Dereference annotated tag to get commit SHA
if [ "$TAG_TYPE" = "tag" ]; then
COMMIT_SHA=$(gh api "repos/$REPO/git/tags/$TAG_SHA" --jq '.object.sha')
else
COMMIT_SHA="$TAG_SHA"
fi
# Get parent of the release commit (skip chore(release) by bot)
PARENT_SHA=$(gh api "repos/$REPO/commits/$COMMIT_SHA" --jq '.parents[0].sha // empty')
AUTHOR=""
if [ -n "$PARENT_SHA" ]; then
AUTHOR=$(gh api "repos/$REPO/commits/$PARENT_SHA/pulls" --jq '.[0].user.login // empty' 2>/dev/null || echo "")
fi
echo "author=$AUTHOR" >> $GITHUB_OUTPUT
echo "Release author: ${AUTHOR:-unknown}"
- name: Trigger tycho-protocol-sdk update workflow
run: |
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token ${{ secrets.SDK_REPO_DISPATCH_TOKEN }}" \
https://api.github.com/repos/propeller-heads/tycho-protocol-sdk/dispatches \
-d '{"event_type":"tycho-simulation-release","client_payload":{"version":"${{ github.event.release.tag_name }}","release_author":"${{ steps.release_author.outputs.author }}"}}'
- name: Log notification
run: |
echo "Notified tycho-protocol-sdk of release ${{ github.event.release.tag_name }} by ${{ steps.release_author.outputs.author }}"