Skip to content

Commit 7c59b05

Browse files
committed
ci: auto-generate skills on toolbox version updates
1 parent 89f3048 commit 7c59b05

2 files changed

Lines changed: 163 additions & 0 deletions

File tree

.github/scripts/generate_skills.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Ensure VERSION is passed from the environment
5+
if [ -z "$VERSION" ]; then
6+
echo "Error: VERSION environment variable is not set."
7+
exit 1
8+
fi
9+
10+
# SKILL CONFIGURATION
11+
# Format: "toolset" "description"
12+
# The skill name is automatically generated as "bigquery-<toolset>"
13+
SKILLS=(
14+
"data"
15+
"Use these skills when you need to handle large-scale data exploration and dataset management. Use when users need to find data assets or run SQL at scale. Provides metadata discovery and query execution across the data warehouse."
16+
17+
"analytics"
18+
"Use these skills when you need to handle advanced data intelligence and predictive tasks. Use when a user asks \"why\" data changed or needs future projections. Provides automated insight generation and time-series forecasting."
19+
)
20+
21+
echo "VALIDATING TOOLSETS BEFORE GENERATION"
22+
23+
# Dynamically build the SUPPORTED_TOOLSETS array from the SKILLS array.
24+
# We use 'set --' to process the array in chunks without index arithmetic.
25+
SUPPORTED_TOOLSETS=()
26+
set -- "${SKILLS[@]}"
27+
while [ $# -gt 0 ]; do
28+
SUPPORTED_TOOLSETS+=("$1")
29+
shift 2
30+
done
31+
32+
echo "Currently Supported Toolsets: ${SUPPORTED_TOOLSETS[*]}"
33+
34+
# Fetch the upstream source of truth YAML for this specific version
35+
RAW_URL="https://raw.githubusercontent.com/googleapis/mcp-toolbox/v${VERSION}/internal/prebuiltconfigs/tools/bigquery.yaml"
36+
echo "Fetching upstream config from: $RAW_URL"
37+
UPSTREAM_YAML=$(curl -sL --fail "$RAW_URL" || { echo "Error: Could not fetch upstream YAML for v$VERSION"; exit 1; })
38+
39+
# Extract the list of toolsets. Each toolset is its own YAML document:
40+
# kind: toolset
41+
# name: <toolset>
42+
UPSTREAM_TOOLSETS=$(echo "$UPSTREAM_YAML" | awk '$1=="kind:" && $2=="toolset"{f=1; next} f && $1=="name:"{print $2; f=0}')
43+
44+
# Compare upstream toolsets against our supported list
45+
MISSING_TOOLSETS=false
46+
47+
for upstream_tool in $UPSTREAM_TOOLSETS; do
48+
if [ -z "$upstream_tool" ] || [ "$upstream_tool" == "-" ]; then continue; fi
49+
50+
if [[ ! " ${SUPPORTED_TOOLSETS[*]} " =~ " ${upstream_tool} " ]]; then
51+
echo "ERROR: Upstream configuration contains a new toolset: '$upstream_tool'"
52+
MISSING_TOOLSETS=true
53+
fi
54+
done
55+
56+
if [ "$MISSING_TOOLSETS" = true ]; then
57+
echo "PIPELINE FAILED: Missing Toolset Generators"
58+
echo "The source of truth file has toolsets that your script does not support."
59+
echo "Please update the SKILLS array in generate_skills.sh to include generators"
60+
echo "for the missing toolsets above, then commit your changes to unblock this PR."
61+
exit 1
62+
fi
63+
64+
echo "Validation passed. All upstream toolsets are supported."
65+
66+
echo "BEGINNING SKILL GENERATION"
67+
68+
LICENSE_HEADER="// Copyright 2026 Google LLC
69+
//
70+
// Licensed under the Apache License, Version 2.0 (the \"License\");
71+
// you may not use this file except in compliance with the License.
72+
// You may obtain a copy of the License at
73+
//
74+
// http://www.apache.org/licenses/LICENSE-2.0
75+
//
76+
// Unless required by applicable law or agreed to in writing, software
77+
// distributed under the License is distributed on an \"AS IS\" BASIS,
78+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
79+
// See the License for the specific language governing permissions and
80+
// limitations under the License."
81+
82+
ADDITIONAL_NOTES="Note: The scripts automatically load the environment variables from various .env files. Do not ask the user to set vars unless skill executions fails due to env var absence."
83+
84+
# Base Command Function
85+
generate_skill() {
86+
local TOOLSET="$1"
87+
local SKILL_DESC="$2"
88+
local SKILL_NAME="bigquery-$TOOLSET"
89+
90+
echo "Generating skill: $SKILL_NAME..."
91+
92+
npx "@toolbox-sdk/server@${VERSION}" --prebuilt bigquery skills-generate \
93+
--name "$SKILL_NAME" \
94+
--description "$SKILL_DESC" \
95+
--toolset="$TOOLSET" \
96+
--license-header "$LICENSE_HEADER" \
97+
--additional-notes="$ADDITIONAL_NOTES"
98+
}
99+
100+
set -- "${SKILLS[@]}"
101+
while [ $# -gt 0 ]; do
102+
generate_skill "$1" "$2"
103+
shift 2
104+
done
105+
106+
echo "All skills generated successfully!"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Generate Skills
16+
17+
on:
18+
pull_request:
19+
paths:
20+
- "toolbox_version.txt"
21+
22+
jobs:
23+
generate-skills:
24+
# Only run for same-repo PRs (e.g. renovate's toolbox bump), where the
25+
# built-in GITHUB_TOKEN can push back to the PR branch.
26+
if: github.event.pull_request.head.repo.full_name == github.repository
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: write
30+
steps:
31+
- name: Check out PR branch
32+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
33+
with:
34+
ref: ${{ github.head_ref }}
35+
36+
- name: Generate skills
37+
run: |
38+
VERSION="$(tr -d '\n' < toolbox_version.txt)"
39+
echo "Detected toolbox version: $VERSION"
40+
export VERSION
41+
chmod +x ./.github/scripts/generate_skills.sh
42+
./.github/scripts/generate_skills.sh
43+
44+
- name: Commit and push regenerated skills
45+
run: |
46+
if [ -z "$(git status --porcelain)" ]; then
47+
echo "No skill changes generated. Nothing to commit."
48+
exit 0
49+
fi
50+
51+
echo "Changes detected. Committing regenerated skills..."
52+
git config user.name "release-please[bot]"
53+
git config user.email "55107282+release-please[bot]@users.noreply.github.com"
54+
55+
git add .
56+
git commit -m "chore: auto-generate skills for toolbox v$(tr -d '\n' < toolbox_version.txt)"
57+
git push

0 commit comments

Comments
 (0)