Skip to content

Commit 7747e60

Browse files
chore: notify Slack for SDK release PRs (#26)
Co-authored-by: Dhruva Reddy <dhruva2000@gmail.com>
1 parent d4819ef commit 7747e60

1 file changed

Lines changed: 146 additions & 0 deletions

File tree

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
name: SDK Release PR Notification
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, ready_for_review]
6+
7+
permissions:
8+
contents: read
9+
pull-requests: read
10+
11+
jobs:
12+
notify:
13+
name: Notify Slack
14+
if: >
15+
(github.event.action == 'ready_for_review' || github.event.pull_request.draft == false) &&
16+
(
17+
github.event.pull_request.user.login == 'fern-api[bot]' ||
18+
github.event.pull_request.user.login == 'fern-api' ||
19+
contains(github.event.pull_request.head.ref, 'fern')
20+
)
21+
runs-on: ubuntu-latest
22+
env:
23+
SLACK_WEBHOOK_URL: ${{ secrets.PRODUCTION_RELEASE_OBSERVABILITY_SLACK_WEBHOOK }}
24+
RUNBOOK_URL: https://github.com/VapiAI/docs/blob/main/.github/runbooks/sdk-release-approval.md
25+
steps:
26+
- name: Checkout PR
27+
uses: actions/checkout@v4
28+
with:
29+
ref: ${{ github.event.pull_request.head.sha }}
30+
31+
- name: Detect package metadata
32+
id: package
33+
shell: bash
34+
run: |
35+
set -euo pipefail
36+
37+
repo="${GITHUB_REPOSITORY#*/}"
38+
package="unknown"
39+
registry="unknown"
40+
41+
case "$repo" in
42+
server-sdk-typescript)
43+
package="@vapi-ai/server-sdk"
44+
registry="npm"
45+
;;
46+
server-sdk-python)
47+
package="vapi_server_sdk"
48+
registry="PyPI"
49+
;;
50+
server-sdk-go)
51+
package="github.com/VapiAI/server-sdk-go"
52+
registry="Go modules"
53+
;;
54+
server-sdk-ruby)
55+
package="vapi_server_sdk"
56+
registry="RubyGems"
57+
;;
58+
server-sdk-csharp)
59+
package="Vapi.Net"
60+
registry="NuGet"
61+
;;
62+
server-sdk-php)
63+
package="vapi/vapi"
64+
registry="Packagist"
65+
;;
66+
server-sdk-swift)
67+
package="Vapi"
68+
registry="Swift Package Manager"
69+
;;
70+
esac
71+
72+
version="$(node <<'NODE'
73+
const fs = require('fs');
74+
75+
const readJson = (path) => {
76+
try {
77+
return JSON.parse(fs.readFileSync(path, 'utf8'));
78+
} catch {
79+
return undefined;
80+
}
81+
};
82+
83+
const firstMatch = (path, regex) => {
84+
if (!fs.existsSync(path)) return undefined;
85+
return fs.readFileSync(path, 'utf8').match(regex)?.[1];
86+
};
87+
88+
const metadata = readJson('.fern/metadata.json');
89+
const packageJson = readJson('package.json');
90+
const composerJson = readJson('composer.json');
91+
92+
const version =
93+
metadata?.sdkVersion ||
94+
packageJson?.version ||
95+
composerJson?.version ||
96+
firstMatch('pyproject.toml', /^version = "([^"]+)"/m) ||
97+
firstMatch('src/Vapi.Net/Vapi.Net.csproj', /<Version>([^<]+)<\/Version>/) ||
98+
firstMatch('lib/vapi/version.rb', /VERSION = "([^"]+)"/) ||
99+
'unknown';
100+
101+
process.stdout.write(version);
102+
NODE
103+
)"
104+
105+
{
106+
echo "package=$package"
107+
echo "registry=$registry"
108+
echo "version=$version"
109+
} >> "$GITHUB_OUTPUT"
110+
111+
- name: Send Slack notification
112+
shell: bash
113+
env:
114+
PR_NUMBER: ${{ github.event.pull_request.number }}
115+
PR_TITLE: ${{ github.event.pull_request.title }}
116+
PR_URL: ${{ github.event.pull_request.html_url }}
117+
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
118+
PACKAGE_NAME: ${{ steps.package.outputs.package }}
119+
PACKAGE_REGISTRY: ${{ steps.package.outputs.registry }}
120+
PACKAGE_VERSION: ${{ steps.package.outputs.version }}
121+
run: |
122+
set -euo pipefail
123+
124+
if [ -z "${SLACK_WEBHOOK_URL}" ]; then
125+
echo "::warning::PRODUCTION_RELEASE_OBSERVABILITY_SLACK_WEBHOOK is not set; skipping Slack notification."
126+
exit 0
127+
fi
128+
129+
text="$(cat <<EOF
130+
*SDK release PR ready for review*
131+
*Repo:* \`${GITHUB_REPOSITORY}\`
132+
*PR:* <${PR_URL}|#${PR_NUMBER} ${PR_TITLE}>
133+
*Author:* \`${PR_AUTHOR}\`
134+
*Package:* \`${PACKAGE_NAME}\` (${PACKAGE_REGISTRY})
135+
*Version:* \`${PACKAGE_VERSION}\`
136+
*Next:* Review and merge the PR, then publish the release tag from the SDK repo.
137+
*Runbook:* <${RUNBOOK_URL}|SDK release approval runbook>
138+
EOF
139+
)"
140+
141+
payload="$(jq -n --arg text "$text" '{text: $text}')"
142+
curl --fail --show-error --silent \
143+
--request POST \
144+
--header 'Content-Type: application/json' \
145+
--data "$payload" \
146+
"$SLACK_WEBHOOK_URL"

0 commit comments

Comments
 (0)