Skip to content

Commit c81ca31

Browse files
committed
feat: auto sdk bumps
1 parent 3607ef0 commit c81ca31

File tree

7 files changed

+1170
-0
lines changed

7 files changed

+1170
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Auto-release after SDK update
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
7+
8+
jobs:
9+
check-and-release:
10+
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'sdk-update')
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
fetch-depth: 0
19+
20+
- name: Configure Git
21+
run: |
22+
git config --global user.name "github-actions[bot]"
23+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
24+
25+
- name: Get version from VERSION file
26+
id: get-version
27+
run: |
28+
version=$(cat VERSION | tr -d '\n')
29+
echo "version=v$version" >> $GITHUB_OUTPUT
30+
echo "CLI version: v$version"
31+
32+
- name: Check if tag already exists
33+
id: check-tag
34+
run: |
35+
if git rev-parse "refs/tags/${{ steps.get-version.outputs.version }}" >/dev/null 2>&1; then
36+
echo "tag_exists=true" >> $GITHUB_OUTPUT
37+
echo "Tag ${{ steps.get-version.outputs.version }} already exists"
38+
else
39+
echo "tag_exists=false" >> $GITHUB_OUTPUT
40+
echo "Tag ${{ steps.get-version.outputs.version }} does not exist"
41+
fi
42+
43+
- name: Create and push tag
44+
if: steps.check-tag.outputs.tag_exists == 'false'
45+
run: |
46+
echo "Creating tag ${{ steps.get-version.outputs.version }}"
47+
git tag -a "${{ steps.get-version.outputs.version }}" -m "Release ${{ steps.get-version.outputs.version }}
48+
49+
Automated release triggered by SDK update to maintain API compatibility.
50+
51+
This release includes:
52+
- Updated Go SDK dependency
53+
- Latest API data model definitions
54+
- Compatibility improvements
55+
56+
SDK Update PR: ${{ github.event.pull_request.html_url }}"
57+
58+
git push origin "${{ steps.get-version.outputs.version }}"
59+
echo "✅ Tag ${{ steps.get-version.outputs.version }} created and pushed"
60+
61+
- name: Create GitHub Release
62+
if: steps.check-tag.outputs.tag_exists == 'false'
63+
uses: softprops/action-gh-release@v2
64+
with:
65+
tag_name: ${{ steps.get-version.outputs.version }}
66+
name: "CLI ${{ steps.get-version.outputs.version }}"
67+
body: |
68+
## 🤖 Automated SDK Update Release
69+
70+
This release was automatically triggered by a Go SDK update to ensure the CLI remains compatible with the latest API changes.
71+
72+
### What's Changed
73+
- 📦 Updated Vapi Go SDK to latest version
74+
- 🔄 Refreshed API data model definitions
75+
- 🛠️ Improved compatibility with recent API changes
76+
77+
### Installation
78+
79+
#### Universal Install Script (Recommended)
80+
```bash
81+
curl -sSL https://vapi.ai/install.sh | bash
82+
```
83+
84+
#### Package Managers
85+
```bash
86+
# npm
87+
npm install -g @vapi-ai/cli
88+
89+
# Homebrew (macOS/Linux)
90+
brew tap VapiAI/homebrew-tap && brew install vapi-cli
91+
92+
# Docker
93+
docker run -it ghcr.io/vapiai/cli:${{ steps.get-version.outputs.version }} --help
94+
```
95+
96+
### Related Changes
97+
- 🔗 **SDK Update PR**: ${{ github.event.pull_request.html_url }}
98+
- 📋 **SDK Changelog**: [Go SDK Releases](https://github.com/VapiAI/server-sdk-go/releases)
99+
100+
---
101+
*This release was created automatically to maintain API compatibility.*
102+
draft: false
103+
prerelease: false
104+
generate_release_notes: true
105+
env:
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
107+
108+
- name: Log release info
109+
run: |
110+
echo "🎉 Release process completed!"
111+
echo "Version: ${{ steps.get-version.outputs.version }}"
112+
echo "Triggered by: SDK update PR #${{ github.event.pull_request.number }}"
113+
echo "Release will be built by GoReleaser workflow..."
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
name: Auto-update Go SDK
2+
3+
on:
4+
schedule:
5+
# Run daily at 2 AM UTC
6+
- cron: "0 2 * * *"
7+
workflow_dispatch: # Allow manual trigger
8+
inputs:
9+
force_update:
10+
description: "Force update even if no new SDK version"
11+
required: false
12+
default: false
13+
type: boolean
14+
15+
jobs:
16+
check-sdk-updates:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
has_updates: ${{ steps.check-updates.outputs.has_updates }}
20+
new_version: ${{ steps.check-updates.outputs.new_version }}
21+
current_version: ${{ steps.check-updates.outputs.current_version }}
22+
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
with:
27+
token: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Set up Go
30+
uses: actions/setup-go@v5
31+
with:
32+
go-version: "1.24"
33+
34+
- name: Check for SDK updates
35+
id: check-updates
36+
run: |
37+
# Get current SDK version from go.mod
38+
current_version=$(grep "github.com/VapiAI/server-sdk-go" go.mod | awk '{print $2}')
39+
echo "Current SDK version: $current_version"
40+
echo "current_version=$current_version" >> $GITHUB_OUTPUT
41+
42+
# Get latest SDK version from GitHub API
43+
latest_version=$(curl -s https://api.github.com/repos/VapiAI/server-sdk-go/releases/latest | jq -r '.tag_name')
44+
echo "Latest SDK version: $latest_version"
45+
echo "new_version=$latest_version" >> $GITHUB_OUTPUT
46+
47+
# Compare versions (remove 'v' prefix for comparison)
48+
current_clean=$(echo $current_version | sed 's/^v//')
49+
latest_clean=$(echo $latest_version | sed 's/^v//')
50+
51+
if [[ "$current_clean" != "$latest_clean" ]] || [[ "${{ github.event.inputs.force_update }}" == "true" ]]; then
52+
echo "SDK update available: $current_version -> $latest_version"
53+
echo "has_updates=true" >> $GITHUB_OUTPUT
54+
else
55+
echo "No SDK updates available"
56+
echo "has_updates=false" >> $GITHUB_OUTPUT
57+
fi
58+
59+
update-and-release:
60+
runs-on: ubuntu-latest
61+
needs: check-sdk-updates
62+
if: needs.check-sdk-updates.outputs.has_updates == 'true'
63+
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v4
67+
with:
68+
token: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Set up Go
71+
uses: actions/setup-go@v5
72+
with:
73+
go-version: "1.24"
74+
75+
- name: Configure Git
76+
run: |
77+
git config --global user.name "github-actions[bot]"
78+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
79+
80+
- name: Update Go SDK dependency
81+
run: |
82+
echo "Updating Go SDK to ${{ needs.check-sdk-updates.outputs.new_version }}"
83+
go get github.com/VapiAI/server-sdk-go@${{ needs.check-sdk-updates.outputs.new_version }}
84+
go mod tidy
85+
86+
- name: Run tests
87+
run: |
88+
echo "Running tests to ensure compatibility..."
89+
make test
90+
91+
- name: Run linter
92+
run: |
93+
echo "Running linter to ensure code quality..."
94+
make lint
95+
96+
- name: Bump CLI version
97+
id: bump-version
98+
run: |
99+
# Read current CLI version
100+
current_cli_version=$(cat VERSION | tr -d '\n')
101+
echo "Current CLI version: $current_cli_version"
102+
103+
# Parse version components (assuming semantic versioning)
104+
IFS='.' read -ra ADDR <<< "$current_cli_version"
105+
major=${ADDR[0]}
106+
minor=${ADDR[1]}
107+
patch=${ADDR[2]}
108+
109+
# Increment patch version
110+
new_patch=$((patch + 1))
111+
new_cli_version="$major.$minor.$new_patch"
112+
113+
echo "New CLI version: $new_cli_version"
114+
echo "$new_cli_version" > VERSION
115+
116+
echo "new_cli_version=$new_cli_version" >> $GITHUB_OUTPUT
117+
118+
- name: Update version references
119+
run: |
120+
# Update any hardcoded version references in the code
121+
new_version="${{ steps.bump-version.outputs.new_cli_version }}"
122+
123+
# Update version in cmd/version.go if it exists
124+
if [ -f "cmd/version.go" ]; then
125+
sed -i "s/version = \"[^\"]*\"/version = \"$new_version\"/" cmd/version.go
126+
fi
127+
128+
- name: Commit changes
129+
run: |
130+
git add .
131+
git commit -m "chore: update Go SDK to ${{ needs.check-sdk-updates.outputs.new_version }}
132+
133+
- Updated github.com/VapiAI/server-sdk-go from ${{ needs.check-sdk-updates.outputs.current_version }} to ${{ needs.check-sdk-updates.outputs.new_version }}
134+
- Bumped CLI version to ${{ steps.bump-version.outputs.new_cli_version }}
135+
- Updated dependencies with go mod tidy
136+
137+
This automated update ensures the CLI stays compatible with the latest API changes."
138+
139+
- name: Create Pull Request
140+
id: create-pr
141+
uses: peter-evans/create-pull-request@v7
142+
with:
143+
token: ${{ secrets.GITHUB_TOKEN }}
144+
branch: auto-update-sdk-${{ needs.check-sdk-updates.outputs.new_version }}
145+
title: "chore: Auto-update Go SDK to ${{ needs.check-sdk-updates.outputs.new_version }}"
146+
body: |
147+
## 🤖 Automated SDK Update
148+
149+
This PR automatically updates the Vapi Go SDK to the latest version to ensure CLI compatibility with recent API changes.
150+
151+
### Changes
152+
- **Go SDK**: `${{ needs.check-sdk-updates.outputs.current_version }}` → `${{ needs.check-sdk-updates.outputs.new_version }}`
153+
- **CLI Version**: Bumped to `${{ steps.bump-version.outputs.new_cli_version }}`
154+
- **Dependencies**: Updated with `go mod tidy`
155+
156+
### Verification
157+
- ✅ Tests passed (`make test`)
158+
- ✅ Linting passed (`make lint`)
159+
- ✅ Dependencies resolved (`go mod tidy`)
160+
161+
### Next Steps
162+
1. Review the changes in this PR
163+
2. Merge when ready
164+
3. A new release will be automatically created
165+
166+
### SDK Release Notes
167+
Check the [Go SDK releases](https://github.com/VapiAI/server-sdk-go/releases/tag/${{ needs.check-sdk-updates.outputs.new_version }}) for details on what changed.
168+
169+
---
170+
*This PR was created automatically by the SDK update workflow. Review and merge when ready.*
171+
labels: |
172+
dependencies
173+
automation
174+
sdk-update
175+
assignees: |
176+
${{ github.actor }}
177+
178+
- name: Log PR creation
179+
if: steps.create-pr.outputs.pull-request-number
180+
run: |
181+
echo "📋 SDK Update PR created: #${{ steps.create-pr.outputs.pull-request-number }}"
182+
echo "🔗 PR URL: ${{ steps.create-pr.outputs.pull-request-url }}"
183+
echo ""
184+
echo "ℹ️ This PR requires manual review and approval."
185+
echo " Once merged, it will automatically trigger a new release."
186+
187+
notify-on-failure:
188+
runs-on: ubuntu-latest
189+
needs: [check-sdk-updates, update-and-release]
190+
if: failure() && needs.check-sdk-updates.outputs.has_updates == 'true'
191+
192+
steps:
193+
- name: Notify on failure
194+
run: |
195+
echo "❌ SDK update workflow failed!"
196+
echo "Current SDK version: ${{ needs.check-sdk-updates.outputs.current_version }}"
197+
echo "New SDK version: ${{ needs.check-sdk-updates.outputs.new_version }}"
198+
echo "Manual intervention may be required."
199+
200+
# You can add Slack/Discord notifications here if needed
201+
# curl -X POST -H 'Content-type: application/json' \
202+
# --data '{"text":"🚨 CLI SDK auto-update failed for version ${{ needs.check-sdk-updates.outputs.new_version }}"}' \
203+
# ${{ secrets.SLACK_WEBHOOK_URL }}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: SDK Fallback Check
2+
3+
# Fallback safety net in case webhooks fail
4+
# Runs weekly to ensure we don't miss SDK updates
5+
on:
6+
schedule:
7+
# Run weekly on Sundays at 3 AM UTC
8+
- cron: "0 3 * * 0"
9+
workflow_dispatch: # Allow manual trigger
10+
11+
jobs:
12+
fallback-check:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Check SDK versions
20+
id: version-check
21+
run: |
22+
# Get current SDK version
23+
current_version=$(grep "github.com/VapiAI/server-sdk-go" go.mod | awk '{print $2}')
24+
25+
# Get latest SDK version
26+
latest_version=$(curl -s https://api.github.com/repos/VapiAI/server-sdk-go/releases/latest | jq -r '.tag_name')
27+
28+
echo "current_version=$current_version" >> $GITHUB_OUTPUT
29+
echo "latest_version=$latest_version" >> $GITHUB_OUTPUT
30+
31+
# Compare versions
32+
current_clean=$(echo $current_version | sed 's/^v//')
33+
latest_clean=$(echo $latest_version | sed 's/^v//')
34+
35+
if [ "$current_clean" != "$latest_clean" ]; then
36+
echo "outdated=true" >> $GITHUB_OUTPUT
37+
echo "⚠️ CLI is outdated! Current: $current_version, Latest: $latest_version"
38+
else
39+
echo "outdated=false" >> $GITHUB_OUTPUT
40+
echo "✅ CLI is up to date with SDK version $current_version"
41+
fi
42+
43+
- name: Trigger webhook update if outdated
44+
if: steps.version-check.outputs.outdated == 'true'
45+
run: |
46+
echo "🚨 Webhook may have failed - triggering manual SDK update"
47+
48+
# Trigger the webhook-based update workflow
49+
gh workflow run sdk-webhook-update.yml \
50+
--field sdk_version="${{ steps.version-check.outputs.latest_version }}" \
51+
--field force_update=true
52+
53+
echo "✅ Manual SDK update workflow triggered"
54+
echo "📋 Check Actions tab for progress"
55+
env:
56+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: Log status
59+
run: |
60+
echo "📊 Fallback Check Results:"
61+
echo " Current SDK: ${{ steps.version-check.outputs.current_version }}"
62+
echo " Latest SDK: ${{ steps.version-check.outputs.latest_version }}"
63+
echo " Outdated: ${{ steps.version-check.outputs.outdated }}"
64+
65+
if [ "${{ steps.version-check.outputs.outdated }}" = "false" ]; then
66+
echo "✅ No action needed - webhooks are working correctly"
67+
else
68+
echo "🔧 Triggered manual update - webhooks may need attention"
69+
fi

0 commit comments

Comments
 (0)