Repository navigation
chore(release): suggest version via claude -p instead of an Anthropic API key - #1299
dangrondahl wants to merge 1 commit into
Conversation
… API key The release version/changelog suggestion now runs through the Claude Code CLI under the releaser's own Claude login, removing the shared API key in 1Password and the ANTHROPIC_API_KEY fallback. The call runs from an empty temp dir with all tools disabled, so it stays a plain diff-in, text-out request.
|
Claude finished @dangrondahl's task in 1m 22s —— View job PR review:
|
| RESPONSE=$(cd "$WORK_DIR" && claude -p \ | ||
| --model "$CLAUDE_MODEL" \ | ||
| --tools "" \ | ||
| --output-format json \ | ||
| --no-session-persistence \ | ||
| --strict-mcp-config \ | ||
| --disable-slash-commands \ | ||
| < input) || true |
There was a problem hiding this comment.
Nit on isolation: the empty cwd keeps out the repo's CLAUDE.md and .mcp.json. The releaser's user-level config still loads, though: ~/.claude/CLAUDE.md, user hooks such as SessionStart/Stop, and plugins. A personal "always answer in X style" memory, or a hook that prints to stdout, could bend the output away from the BUMP: / ---CHANGELOG--- format. If you want the call fully deterministic, look at --setting-sources "", or --bare if your Claude Code version supports it. Also consider --append-system-prompt/--system-prompt to pin the format. Not a blocker: the parser already falls back to patch, and the $EDITOR step catches any odd output.
| # The response may start with a thinking block, so join all text blocks instead of reading content[0]. | ||
| CONTENT=$(echo "$RESPONSE" | jq -r '[.content[]? | select(.type == "text") | .text] | join("\n")') | ||
| WORK_DIR=$(mktemp -d) | ||
| trap 'rm -rf "$WORK_DIR"; rm -f "$RELEASE_NOTES_FILE" "$SUGGESTED_VERSION_FILE"' EXIT |
There was a problem hiding this comment.
Temp dir leaks on success. The trap - EXIT near the end of the script (line 158) clears this trap, so rm -rf "$WORK_DIR" only runs on failure. Every successful make release leaves a /tmp/tmp.XXXX/input holding the prompt and up to 50 KB of the diff. The old DIFF_FILE leaked the same way, so this isn't new, but it's a one-line fix. Add rm -rf "$WORK_DIR" just before the final trap - EXIT, or clean it up right after the claude -p call since nothing reads it afterwards:
RESPONSE=$(cd "$WORK_DIR" && claude -p ... < input) || true
rm -rf "$WORK_DIR"
💊 Blue pill. One of two alternative PRs that remove the shared Anthropic API key from the release flow. Only one should merge; the other is the red pill, #1300.
bin/suggest-version-ai.shnow calls the Claude Code CLI (claude -p) under the releaser's own Claude login, instead of calling the Messages API with a key from 1Password (orANTHROPIC_API_KEY).make releasebehaves as before: same prompt, same parsing, same$EDITORstep and confirmation.CLAUDE.mdor MCP servers.curlchecks are gone from the Makefile; the release guide now listsjqand a logged-in Claude Code CLI as prerequisites.op://Shared/Anthropic API Keyitem can be deleted if nothing else uses it.Choose this if you want
make releaseto stay a fixed, scripted flow.Tested locally (writing to a scratch dir, no tag created): since
v2.48.2it suggested a patch with "No user-facing CLI changes" (correct, only CI changed); sincev2.48.0it suggested a minor with a changelog under three headings.claudemissing and an invalid model both exit 1 and leave no stale output files.Checklist
charts/k8s-reporter/) updated, if needed (n/a)