Skip to content

Commit 97b0272

Browse files
committed
Track Gemini CLI releases in sync workflow
1 parent c434e20 commit 97b0272

File tree

3 files changed

+60
-16
lines changed

3 files changed

+60
-16
lines changed

.github/workflows/gemini-cli-watch.yml

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,12 @@ jobs:
2828
- name: Detect updates in google/gemini-cli
2929
id: detect
3030
shell: bash
31+
env:
32+
GITHUB_TOKEN: ${{ github.token }}
3133
run: |
3234
set -euo pipefail
3335
36+
UPSTREAM_REPO="google-gemini/gemini-cli"
3437
SUBMODULE_PATH="submodules/google-gemini-cli"
3538
MODELS_FILE="packages/core/src/config/models.ts"
3639
CONFIG_SCHEMA_FILE="schemas/settings.schema.json"
@@ -39,6 +42,7 @@ jobs:
3942
"packages/cli/src/config/config.ts"
4043
"packages/core/src/config/config.ts"
4144
)
45+
CLI_RELEVANT_PATHS_REGEX='^(packages/|schemas/|gemini-rs/|docs/|README\.md|CHANGELOG\.md|package\.json|package-lock\.json|pnpm-lock\.yaml|bun\.lockb?|Cargo\.toml|Cargo\.lock)'
4246
4347
read_file_at_sha() {
4448
local sha="$1"
@@ -136,15 +140,37 @@ PY
136140
default_branch="main"
137141
fi
138142

139-
git -C "$SUBMODULE_PATH" fetch origin "$default_branch" --depth=512
140-
latest_sha="$(git -C "$SUBMODULE_PATH" rev-parse FETCH_HEAD)"
143+
git -C "$SUBMODULE_PATH" fetch origin "$default_branch" --tags --depth=512
144+
145+
latest_release_json="$(curl -fsSL \
146+
-H "Accept: application/vnd.github+json" \
147+
-H "Authorization: Bearer $GITHUB_TOKEN" \
148+
"https://api.github.com/repos/$UPSTREAM_REPO/releases/latest")"
149+
150+
latest_release_tag="$(printf '%s' "$latest_release_json" | jq -r '.tag_name // empty')"
151+
latest_release_name="$(printf '%s' "$latest_release_json" | jq -r '.name // empty')"
152+
latest_release_url="$(printf '%s' "$latest_release_json" | jq -r '.html_url // empty')"
153+
latest_release_published_at="$(printf '%s' "$latest_release_json" | jq -r '.published_at // empty')"
154+
155+
if [ -z "$latest_release_tag" ]; then
156+
echo "Could not resolve latest upstream release tag for $UPSTREAM_REPO" >&2
157+
exit 1
158+
fi
159+
160+
latest_sha="$(git -C "$SUBMODULE_PATH" rev-list -n 1 "refs/tags/$latest_release_tag^{commit}")"
161+
current_release_tag="$(git -C "$SUBMODULE_PATH" describe --tags --exact-match "$current_sha" 2>/dev/null || true)"
141162

142163
echo "current_sha=$current_sha" >> "$GITHUB_OUTPUT"
143164
echo "latest_sha=$latest_sha" >> "$GITHUB_OUTPUT"
144165
echo "default_branch=$default_branch" >> "$GITHUB_OUTPUT"
145-
146-
if [ "$current_sha" = "$latest_sha" ]; then
147-
echo "No upstream updates."
166+
echo "current_release_tag=$current_release_tag" >> "$GITHUB_OUTPUT"
167+
echo "latest_release_tag=$latest_release_tag" >> "$GITHUB_OUTPUT"
168+
echo "latest_release_name=$latest_release_name" >> "$GITHUB_OUTPUT"
169+
echo "latest_release_url=$latest_release_url" >> "$GITHUB_OUTPUT"
170+
echo "latest_release_published_at=$latest_release_published_at" >> "$GITHUB_OUTPUT"
171+
172+
if [ "$current_sha" = "$latest_sha" ] || git -C "$SUBMODULE_PATH" merge-base --is-ancestor "$latest_sha" "$current_sha"; then
173+
echo "No newer upstream release beyond pinned submodule commit."
148174
echo "has_update=false" >> "$GITHUB_OUTPUT"
149175
exit 0
150176
fi
@@ -157,7 +183,7 @@ PY
157183

158184
echo "has_update=true" >> "$GITHUB_OUTPUT"
159185

160-
cli_changed_files="$(printf '%s\n' "$changed_files" | grep -E '^(codex-rs/|docs/|README\.md|CHANGELOG\.md|Cargo\.toml|Cargo\.lock|package\.json)' || true)"
186+
cli_changed_files="$(printf '%s\n' "$changed_files" | grep -E "$CLI_RELEVANT_PATHS_REGEX" || true)"
161187
if [ -z "$cli_changed_files" ]; then
162188
cli_changed_files="$(printf '%s\n' "$changed_files" | head -n 200)"
163189
fi
@@ -217,6 +243,11 @@ PY
217243
CURRENT_SHA: ${{ steps.detect.outputs.current_sha }}
218244
LATEST_SHA: ${{ steps.detect.outputs.latest_sha }}
219245
DEFAULT_BRANCH: ${{ steps.detect.outputs.default_branch }}
246+
CURRENT_RELEASE_TAG: ${{ steps.detect.outputs.current_release_tag }}
247+
LATEST_RELEASE_TAG: ${{ steps.detect.outputs.latest_release_tag }}
248+
LATEST_RELEASE_NAME: ${{ steps.detect.outputs.latest_release_name }}
249+
LATEST_RELEASE_URL: ${{ steps.detect.outputs.latest_release_url }}
250+
LATEST_RELEASE_PUBLISHED_AT: ${{ steps.detect.outputs.latest_release_published_at }}
220251
CLI_CHANGED_FILES: ${{ steps.detect.outputs.cli_changed_files }}
221252
COMMITS: ${{ steps.detect.outputs.commits }}
222253
CHANGED_FLAGS: ${{ steps.detect.outputs.changed_flags }}
@@ -228,6 +259,11 @@ PY
228259
const currentSha = process.env.CURRENT_SHA;
229260
const latestSha = process.env.LATEST_SHA;
230261
const defaultBranch = process.env.DEFAULT_BRANCH;
262+
const currentReleaseTag = process.env.CURRENT_RELEASE_TAG || '';
263+
const latestReleaseTag = process.env.LATEST_RELEASE_TAG || '';
264+
const latestReleaseName = process.env.LATEST_RELEASE_NAME || '';
265+
const latestReleaseUrl = process.env.LATEST_RELEASE_URL || '';
266+
const latestReleasePublishedAt = process.env.LATEST_RELEASE_PUBLISHED_AT || '';
231267
const changedFilesRaw = process.env.CLI_CHANGED_FILES || '';
232268
const commitsRaw = process.env.COMMITS || '';
233269
const changedFlags = process.env.CHANGED_FLAGS || '- (not provided)';
@@ -237,7 +273,7 @@ PY
237273
238274
const shortCurrent = currentSha.slice(0, 7);
239275
const shortLatest = latestSha.slice(0, 7);
240-
const marker = `<!-- geminisharp-gemini-cli-update:${latestSha} -->`;
276+
const marker = `<!-- geminisharp-gemini-cli-release:${latestReleaseTag}:${latestSha} -->`;
241277
const labelName = 'gemini-cli-sync';
242278
243279
const changedFiles = changedFilesRaw
@@ -281,16 +317,21 @@ PY
281317
return;
282318
}
283319
284-
const title = `Sync Gemini CLI upstream changes (${shortCurrent} -> ${shortLatest})`;
320+
const title = `Sync Gemini CLI release ${latestReleaseTag} (${shortCurrent} -> ${shortLatest})`;
285321
const body = [
286322
marker,
287323
'',
288-
'Detected upstream updates in `google-gemini/gemini-cli` affecting CLI surface tracking.',
324+
'Detected a newer upstream release in `google-gemini/gemini-cli` affecting CLI surface tracking.',
289325
'',
290326
`- Submodule path: \`submodules/google-gemini-cli\``,
291327
`- Watched branch: \`${defaultBranch}\``,
328+
`- Current pinned release tag: ${currentReleaseTag ? `\`${currentReleaseTag}\`` : '_not pinned to an exact release tag_'}`,
292329
`- Current pinned commit: \`${currentSha}\``,
330+
`- Latest upstream release tag: \`${latestReleaseTag}\``,
331+
`- Latest upstream release name: ${latestReleaseName || '_not provided_'}`,
293332
`- Latest upstream commit: \`${latestSha}\``,
333+
`- Release published at: ${latestReleasePublishedAt || '_not provided_'}`,
334+
`- Release page: ${latestReleaseUrl || '_not provided_'}`,
294335
`- Compare: ${compareUrl}`,
295336
`- Latest commit: ${latestCommitUrl}`,
296337
'',
@@ -310,7 +351,9 @@ PY
310351
commits,
311352
'',
312353
'## Action required',
354+
'- [ ] Review upstream release notes and confirm breaking/non-breaking CLI changes',
313355
'- [ ] Validate latest `gemini --help` and headless `gemini --prompt ... --output-format stream-json` output',
356+
'- [ ] Update pinned `submodules/google-gemini-cli` release/tag after validation',
314357
'- [ ] Sync C# SDK constants/options/models with upstream CLI changes',
315358
'- [ ] Add or update tests for new flags/models/features',
316359
'- [ ] Update docs (README + docs/Features + docs/Architecture if needed)',

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ If no new rule is detected -> do not update the file.
8888
- Implement code and tests together.
8989
- When asked to fix review findings, close every confirmed finding in the same pass; do not leave partial fixes.
9090
- Do not keep or add public sample projects; repository focus is SDK + tests only.
91-
- Upstream sync automation must track real `google-gemini/gemini-cli` CLI changes (flags/models/features), not TypeScript SDK surface diffs, and open actionable repository issues for required SDK follow-up.
91+
- Upstream sync automation must trigger from real `google-gemini/gemini-cli` GitHub releases/tags, then summarize real CLI changes (flags/models/features) and open actionable repository issues for required SDK follow-up.
9292
- Automatically opened upstream sync issues must include change summary/checklist and assign Copilot by default.
93-
- For `google-gemini/gemini-cli` repo sync/update work, always inspect `submodules/google-gemini-cli/gemini-rs/core/models.json` and reconcile SDK model constants against that bundled catalog because it is the repo-authoritative model source.
93+
- For `google-gemini/gemini-cli` repo sync/update work, always inspect the currently bundled upstream model catalog (currently `submodules/google-gemini-cli/packages/core/src/config/models.ts`) and reconcile SDK model constants against that catalog because the exact upstream path may move over time.
9494
- When adapting the SDK to upstream Gemini CLI changes, prioritize reflecting real CLI-specific behavior while keeping the `GeminiClient` / `GeminiThread` contract coherent with `GeminiSharpSDK.Extensions.AI` and `GeminiSharpSDK.Extensions.AgentFramework`.
9595
- At the end of implementation/code-change tasks, create a git commit unless the user explicitly says not to, so the workspace ends in a reviewable state.
9696
- Run verification in this order:

docs/Features/release-and-sync-automation.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ Keep package quality and upstream Gemini CLI parity automatically verified throu
4343
- Release workflow must pack every packable NuGet project in the repository, not a hand-maintained subset.
4444
- Release workflow must use generated GitHub release notes.
4545
- Release workflow must create/push git tag `v<version>` before publishing GitHub release.
46-
- Gemini CLI watch runs daily and opens issue when upstream `google-gemini/gemini-cli` changed since pinned submodule SHA.
46+
- Gemini CLI watch runs daily and opens issue when a newer upstream `google-gemini/gemini-cli` GitHub release/tag exists beyond the pinned submodule commit.
4747
- Completing a Gemini CLI sync issue must update the pinned `submodules/google-gemini-cli` commit after validation.
48-
- Sync issue body must derive flag changes from CLI source snapshots, model changes from `packages/core/src/config/models.ts`, and feature changes from `packages/core/src/config/config.ts` so alerts stay actionable.
48+
- Sync issue body must derive flag changes from CLI source snapshots, model changes from the bundled upstream model catalog (`packages/core/src/config/models.ts` in the current repo layout), and feature changes from `schemas/settings.schema.json` so alerts stay actionable.
4949
- SDK model constants must cover every bundled slug from `submodules/google-gemini-cli/packages/core/src/config/models.ts` whenever upstream Gemini repo sync work updates the pinned submodule.
5050
- Sync issue must assign Copilot by default.
51-
- Duplicate sync issue for same upstream SHA is not allowed.
51+
- Duplicate sync issue for the same upstream release tag/SHA is not allowed.
5252

5353
---
5454

@@ -59,7 +59,8 @@ flowchart LR
5959
Push["push / pull_request"] --> CI["ci.yml"]
6060
Main["push main"] --> Release["release.yml"]
6161
Daily["daily cron"] --> Watch["gemini-cli-watch.yml"]
62-
Watch --> Issue["GitHub Issue: Gemini CLI sync"]
62+
Watch --> UpstreamRelease["latest upstream GitHub release"]
63+
UpstreamRelease --> Issue["GitHub Issue: Gemini CLI sync"]
6364
CI --> Quality["build + test"]
6465
Release --> NuGet["NuGet publish + GitHub release"]
6566
```
@@ -90,4 +91,4 @@ flowchart LR
9091

9192
- Workflows are versioned and valid in repository.
9293
- Local commands match CI commands.
93-
- Daily sync issue automation is configured and documented.
94+
- Daily release-following sync issue automation is configured and documented.

0 commit comments

Comments
 (0)