-
Notifications
You must be signed in to change notification settings - Fork 591
chore: agentic workflow for automatic version bump #1947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
01396dd
8fdea5b
8362c4e
0a4de1e
c482cc7
cec8c7c
b96551c
434fc00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,264 @@ | ||||||||||||||||||||||||||||||||||||||||
| name: Bump Version | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||
| workflow_dispatch: | ||||||||||||||||||||||||||||||||||||||||
| inputs: | ||||||||||||||||||||||||||||||||||||||||
| force_bump_type: | ||||||||||||||||||||||||||||||||||||||||
| description: 'Force a specific bump type (leave empty for AI auto-detection)' | ||||||||||||||||||||||||||||||||||||||||
| required: false | ||||||||||||||||||||||||||||||||||||||||
| type: choice | ||||||||||||||||||||||||||||||||||||||||
| options: | ||||||||||||||||||||||||||||||||||||||||
| - '' | ||||||||||||||||||||||||||||||||||||||||
| - major | ||||||||||||||||||||||||||||||||||||||||
| - minor | ||||||||||||||||||||||||||||||||||||||||
| - patch | ||||||||||||||||||||||||||||||||||||||||
| schedule: | ||||||||||||||||||||||||||||||||||||||||
| # Run weekly on Monday at 9:00 AM UTC | ||||||||||||||||||||||||||||||||||||||||
| - cron: '0 9 * * 1' | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||
| analyze-and-bump: | ||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||
| contents: write | ||||||||||||||||||||||||||||||||||||||||
| pull-requests: write | ||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||
| - name: Checkout code | ||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v4 | ||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||
| fetch-depth: 0 # Need full history to analyze commits | ||||||||||||||||||||||||||||||||||||||||
| submodules: false | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Set up Python | ||||||||||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v5 | ||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||
| python-version: '3.10' | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Install dependencies | ||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||
| python -m pip install --upgrade pip | ||||||||||||||||||||||||||||||||||||||||
| pip install google-generativeai | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Get current version | ||||||||||||||||||||||||||||||||||||||||
| id: current-version | ||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||
| CURRENT_VERSION=$(cat version.txt | tr -d '[:space:]') | ||||||||||||||||||||||||||||||||||||||||
| echo "version=${CURRENT_VERSION}" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||
| echo "Current version: ${CURRENT_VERSION}" | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Check for existing bump PR | ||||||||||||||||||||||||||||||||||||||||
| id: check-existing-pr | ||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||
| GH_TOKEN: ${{ github.token }} | ||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||
| # Check if there's already an open PR for version bump | ||||||||||||||||||||||||||||||||||||||||
| EXISTING_PR=$(gh pr list --state open --label "version-bump" --json number --jq '.[0].number' || echo "") | ||||||||||||||||||||||||||||||||||||||||
| if [ -n "$EXISTING_PR" ]; then | ||||||||||||||||||||||||||||||||||||||||
| echo "has_existing_pr=true" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||
| echo "existing_pr_number=${EXISTING_PR}" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||
| echo "β οΈ Existing version bump PR found: #${EXISTING_PR}" | ||||||||||||||||||||||||||||||||||||||||
| else | ||||||||||||||||||||||||||||||||||||||||
| echo "has_existing_pr=false" >> $GITHUB_OUTPUT | ||||||||||||||||||||||||||||||||||||||||
| echo "β No existing version bump PR found" | ||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| - name: Analyze commits with AI | ||||||||||||||||||||||||||||||||||||||||
| id: analyze | ||||||||||||||||||||||||||||||||||||||||
| if: steps.check-existing-pr.outputs.has_existing_pr == 'false' | ||||||||||||||||||||||||||||||||||||||||
| env: | ||||||||||||||||||||||||||||||||||||||||
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | ||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||
| echo "Analyzing commits to determine version bump..." | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Run AI analysis | ||||||||||||||||||||||||||||||||||||||||
| python scripts/ai_determine_version_bump.py \ | ||||||||||||||||||||||||||||||||||||||||
| --output-format json \ | ||||||||||||||||||||||||||||||||||||||||
| --verbose > /tmp/analysis.json 2>&1 | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| # Extract results | ||||||||||||||||||||||||||||||||||||||||
| BUMP_TYPE=$(jq -r '.bump_type' /tmp/analysis.json) | ||||||||||||||||||||||||||||||||||||||||
| NEW_VERSION=$(jq -r '.new_version' /tmp/analysis.json) | ||||||||||||||||||||||||||||||||||||||||
| REASONING=$(jq -r '.reasoning' /tmp/analysis.json) | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
| # Run AI analysis | |
| python scripts/ai_determine_version_bump.py \ | |
| --output-format json \ | |
| --verbose > /tmp/analysis.json 2>&1 | |
| # Extract results | |
| BUMP_TYPE=$(jq -r '.bump_type' /tmp/analysis.json) | |
| NEW_VERSION=$(jq -r '.new_version' /tmp/analysis.json) | |
| REASONING=$(jq -r '.reasoning' /tmp/analysis.json) | |
| # Run AI analysis | |
| python scripts/ai_determine_version_bump.py \ | |
| --output-format json \ | |
| --verbose 1> /tmp/analysis.json 2> /tmp/analysis.log | |
| echo "AI analysis logs saved to /tmp/analysis.log" | |
| # Extract results | |
| BUMP_TYPE=$(jq -r '.bump_type' /tmp/analysis.json) | |
| NEW_VERSION=$(jq -r '.new_version' /tmp/analysis.json) | |
| REASONING=$(jq -r '.reasoning' /tmp/analysis.json) |
π€ Prompt for AI Agents
In .github/workflows/bump-version.yml around lines 73β81, the workflow redirects
stderr into the JSON output ("> /tmp/analysis.json 2>&1") which corrupts the
JSON; change the invocation to capture stdout only (remove the "2>&1" redirect)
or redirect stderr to a separate file (e.g., "2>/tmp/analysis.err"), or drop the
--verbose flag so the script writes pure JSON to stdout; ensure jq reads
/tmp/analysis.json only and optionally fail the job if jq parsing fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guard against
nullfromgh pr listto avoid false positives.Current test treats
"null"as a PR number. Use// empty.Apply:
π Committable suggestion
π€ Prompt for AI Agents