@@ -3,7 +3,12 @@ name: Update SDK Version
3
3
on :
4
4
release :
5
5
types : [published] # Triggers when a release is published
6
- workflow_dispatch : {} # Manual trigger without inputs
6
+ workflow_dispatch :
7
+ inputs :
8
+ version :
9
+ description : ' Version to update (leave empty to use latest release)'
10
+ required : false
11
+ type : string
7
12
8
13
jobs :
9
14
update-versions :
@@ -13,59 +18,54 @@ jobs:
13
18
pull-requests : write
14
19
15
20
steps :
21
+ - name : Debug Release Info
22
+ if : github.event_name == 'release'
23
+ run : |
24
+ echo "Release event detected!"
25
+ echo "Event action: ${{ github.event.action }}"
26
+ echo "Release tag: ${{ github.event.release.tag_name }}"
27
+ echo "Release name: ${{ github.event.release.name }}"
28
+ echo "Is prerelease: ${{ github.event.release.prerelease }}"
29
+ echo "Is draft: ${{ github.event.release.draft }}"
30
+
16
31
- name : Get Latest Release
17
32
id : latest_release
18
33
run : |
19
- LATEST_TAG=$(gh api repos/growthbook/growthbook-python/releases/latest --jq .tag_name)
20
- echo "version=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
34
+ if [ "${{ github.event_name }}" == "workflow_dispatch" ] && [ -n "${{ inputs.version }}" ]; then
35
+ echo "Using manually specified version: ${{ inputs.version }}"
36
+ echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
37
+ elif [ "${{ github.event_name }}" == "release" ]; then
38
+ echo "Using release event version: ${{ github.event.release.tag_name }}"
39
+ VERSION="${{ github.event.release.tag_name }}"
40
+ echo "version=${VERSION#v}" >> $GITHUB_OUTPUT
41
+ else
42
+ echo "Getting latest release from API..."
43
+ LATEST_TAG=$(gh api repos/growthbook/growthbook-python/releases/latest --jq .tag_name)
44
+ echo "version=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
45
+ fi
21
46
env :
22
47
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
23
48
24
- - name : Update SDK Versions Repository
25
- env :
26
- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
49
+ - name : Trigger Update in Main GrowthBook Repository
27
50
run : |
28
51
# Get version from latest release
29
52
VERSION=${{ steps.latest_release.outputs.version }}
53
+ echo "Triggering update for version: $VERSION"
30
54
31
55
# Validate version format (semver)
32
56
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
33
57
echo "Error: Version '$VERSION' is not in semantic versioning format (x.y.z)"
34
58
exit 1
35
59
fi
36
60
37
- # Remove directory if it exists and clone fresh
38
- rm -rf growthbook || true
39
- git clone https://github.com/growthbook/growthbook.git || {
40
- echo "Failed to clone repository"
41
- exit 1
42
- }
43
- cd growthbook/packages/shared/src/sdk-versioning/sdk-versions
44
-
45
- # Check if version already exists
46
- if jq -e --arg v "$VERSION" '.versions[] | select(.version == $v)' python.json > /dev/null; then
47
- echo "Version $VERSION already exists in python.json"
48
- exit 0 # Exit successfully since this is not an error condition
49
- fi
50
-
51
- # Create a new branch
52
- git checkout -b update-python-sdk-${VERSION}
53
-
54
- # Update the JSON file
55
- jq --arg v "$VERSION" \
56
- '.versions = ([{"version": $v}] + .versions)' \
57
- python.json > python.json.tmp && mv python.json.tmp python.json
58
-
59
- # Commit and push changes
60
- git config user.name "github-actions"
61
- git config user.email "[email protected] "
62
- git add python.json
63
- git commit -m "chore: update Python SDK to ${VERSION}"
64
- git push origin update-python-sdk-${VERSION}
65
-
66
- # Create Pull Request
67
- gh pr create \
68
- --title "Update Python SDK to ${VERSION}" \
69
- --body "Automated PR to update Python SDK version to ${VERSION} in capabilities matrix" \
70
- --repo growthbook/growthbook \
71
- --base main
61
+ # Trigger repository_dispatch event in the main GrowthBook repo
62
+ gh api repos/growthbook/growthbook/dispatches \
63
+ --method POST \
64
+ --field event_type='update-sdk-version' \
65
+ --field client_payload='{"version":"'$VERSION'","sdk":"python","source_repo":"growthbook/growthbook-python"}'
66
+
67
+ echo "✅ Successfully triggered update workflow in growthbook/growthbook"
68
+ echo "📋 Version: $VERSION"
69
+ echo "🔗 Check progress at: https://github.com/growthbook/growthbook/actions"
70
+ env :
71
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments