2727 types : [opened, ready_for_review]
2828 pull_request_review_comment :
2929 types : [created, edited]
30- release :
31- types : [created]
30+ workflow_run :
31+ workflows : ["PyPi"]
32+ types : [completed]
3233
3334permissions :
3435 contents : write # Allows Claude to post suggested changes (requires write for GitHub API)
@@ -485,28 +486,67 @@ jobs:
485486 - Assume good intent
486487 - Welcome contributors
487488
488- # Generate release notes when a new release is created
489+ # Generate release notes when PyPi workflow completes successfully on a tag
489490 release-notes :
490- if : github.event_name == 'release'
491+ if : |
492+ github.event_name == 'workflow_run' &&
493+ github.event.workflow_run.conclusion == 'success' &&
494+ startsWith(github.event.workflow_run.head_branch, 'v')
491495 runs-on : ubuntu-latest
492496 permissions :
493497 contents : write # For committing release notes
494498 issues : write # For creating failure notification issue
495499 concurrency :
496- group : claude-release-notes-${{ github.event.release.tag_name }}
500+ group : claude-release-notes-${{ github.event.workflow_run.head_branch }}
497501 cancel-in-progress : false
498502 steps :
503+ - name : Extract and validate tag name
504+ id : tag
505+ env :
506+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
507+ HEAD_BRANCH : ${{ github.event.workflow_run.head_branch }}
508+ run : |
509+ TAG_NAME="$HEAD_BRANCH"
510+ echo "Candidate tag: $TAG_NAME"
511+
512+ # Validate semantic version format (vX.Y.Z)
513+ if [[ ! "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
514+ echo "❌ '$TAG_NAME' is not a valid semantic version tag (expected vX.Y.Z)"
515+ echo "SKIP=true" >> $GITHUB_OUTPUT
516+ exit 0
517+ fi
518+
519+ # Verify the GitHub release exists
520+ if ! gh release view "$TAG_NAME" --repo "$GITHUB_REPOSITORY" > /dev/null 2>&1; then
521+ echo "❌ GitHub release for '$TAG_NAME' does not exist yet"
522+ echo "SKIP=true" >> $GITHUB_OUTPUT
523+ exit 0
524+ fi
525+
526+ echo "✅ Valid tag and release exists: $TAG_NAME"
527+ echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
528+ echo "SKIP=false" >> $GITHUB_OUTPUT
529+
499530 - name : Checkout repository
531+ if : steps.tag.outputs.SKIP != 'true'
500532 uses : actions/checkout@v6
501533 with :
502534 ref : main # Checkout main branch (not tag) so we can commit
503535 fetch-depth : 0 # Full history for tag comparison
504536 token : ${{ secrets.RELEASE_PAT }} # PAT needed to push past branch protection
505537
538+ - name : Fetch all tags
539+ if : steps.tag.outputs.SKIP != 'true'
540+ run : |
541+ git fetch --tags --force
542+ echo "Tags available:"
543+ git tag -l | tail -10
544+
506545 - name : Generate release context
546+ if : steps.tag.outputs.SKIP != 'true'
507547 env :
508548 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
509- CURRENT_TAG : ${{ github.event.release.tag_name }}
549+ CURRENT_TAG : ${{ steps.tag.outputs.TAG_NAME }}
510550 run : |
511551 echo "Generating release context for $CURRENT_TAG"
512552
@@ -602,6 +642,7 @@ jobs:
602642 ls -la release-diffs/ 2>/dev/null || echo "No diff files"
603643
604644 - name : Generate release notes with Claude
645+ if : steps.tag.outputs.SKIP != 'true'
605646 id : generate-notes
606647 uses : anthropics/claude-code-action@beta
607648 with :
@@ -610,7 +651,7 @@ jobs:
610651 max_turns : 30
611652 model : claude-opus-4-5-20251101
612653 prompt : |
613- Generate comprehensive release notes for GAIA version ${{ github.event.release.tag_name }}.
654+ Generate comprehensive release notes for GAIA version ${{ steps.tag.outputs.TAG_NAME }}.
614655
615656 ## FIRST ACTIONS
616657 1. Read release-context.txt - Contains commit log, contributors, PRs, and list of diff files
@@ -640,22 +681,22 @@ jobs:
640681 ### 1. `RELEASE_NOTES.md` - For GitHub Release
641682 Plain markdown for the GitHub release page.
642683
643- ### 2. `docs/releases/${{ github.event.release.tag_name }}.mdx` - For Documentation Site
684+ ### 2. `docs/releases/${{ steps.tag.outputs.TAG_NAME }}.mdx` - For Documentation Site
644685 MDX format with Mintlify frontmatter for the documentation website.
645686
646687 ## Release Notes Format (use for BOTH files)
647688
648689 For the MDX file, add this frontmatter at the top:
649690 ```
650691 ---
651- title: "${{ github.event.release.tag_name }}"
692+ title: "${{ steps.tag.outputs.TAG_NAME }}"
652693 description: "[One-line summary of this release]"
653694 ---
654695 ```
655696
656697 Then use this content structure for both files:
657698
658- # GAIA ${{ github.event.release.tag_name }} Release Notes
699+ # GAIA ${{ steps.tag.outputs.TAG_NAME }} Release Notes
659700
660701 ## Overview
661702
@@ -692,7 +733,7 @@ jobs:
692733 Key PRs:
693734 - #[number] - [PR title]
694735
695- Full Changelog: [${{ env.PREVIOUS_TAG }}...${{ github.event.release.tag_name }}](https://github.com/amd/gaia/compare/${{ env.PREVIOUS_TAG }}...${{ github.event.release.tag_name }})
736+ Full Changelog: [${{ env.PREVIOUS_TAG }}...${{ steps.tag.outputs.TAG_NAME }}](https://github.com/amd/gaia/compare/${{ env.PREVIOUS_TAG }}...${{ steps.tag.outputs.TAG_NAME }})
696737
697738 ## Guidelines
698739
@@ -712,7 +753,7 @@ jobs:
712753
713754 IMPORTANT: You MUST write BOTH files:
714755 1. `RELEASE_NOTES.md` (for GitHub release)
715- 2. `docs/releases/${{ github.event.release.tag_name }}.mdx` (for documentation site)
756+ 2. `docs/releases/${{ steps.tag.outputs.TAG_NAME }}.mdx` (for documentation site)
716757
717758 ## MANDATORY: Review Your Changes
718759 After writing the release notes files, you MUST:
@@ -725,8 +766,9 @@ jobs:
725766 Do NOT skip this review step - always verify your output before completing.
726767
727768 - name : Verify and validate release notes
769+ if : steps.tag.outputs.SKIP != 'true'
728770 env :
729- TAG_NAME : ${{ github.event.release.tag_name }}
771+ TAG_NAME : ${{ steps.tag.outputs.TAG_NAME }}
730772 run : |
731773 echo "Checking for generated release notes..."
732774
@@ -746,8 +788,9 @@ jobs:
746788 python util/validate_release_notes.py "docs/releases/$TAG_NAME.mdx" --tag "$TAG_NAME"
747789
748790 - name : Update docs.json with new release
791+ if : steps.tag.outputs.SKIP != 'true'
749792 env :
750- TAG_NAME : ${{ github.event.release.tag_name }}
793+ TAG_NAME : ${{ steps.tag.outputs.TAG_NAME }}
751794 run : |
752795 # Add the new release to docs.json navigation
753796 # Insert at the beginning of the releases array (newest first)
@@ -801,13 +844,15 @@ jobs:
801844
802845 with open(docs_json_path, 'w') as f:
803846 json.dump(docs, f, indent=2)
847+ f.write('\n') # Ensure trailing newline for linting
804848
805849 print(f"✅ Added {new_page} to docs.json")
806850 EOF
807851
808852 - name : Bump version.py to next patch version
853+ if : steps.tag.outputs.SKIP != 'true'
809854 env :
810- TAG_NAME : ${{ github.event.release.tag_name }}
855+ TAG_NAME : ${{ steps.tag.outputs.TAG_NAME }}
811856 run : |
812857 # Extract version from tag (strip 'v' prefix if present)
813858 RELEASED_VERSION="${TAG_NAME#v}"
@@ -838,9 +883,10 @@ jobs:
838883 echo "✅ version.py bumped to $NEXT_VERSION"
839884
840885 - name : Commit release notes and version bump
886+ if : steps.tag.outputs.SKIP != 'true'
841887 env :
842888 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
843- TAG_NAME : ${{ github.event.release.tag_name }}
889+ TAG_NAME : ${{ steps.tag.outputs.TAG_NAME }}
844890 NEXT_VERSION : ${{ env.NEXT_VERSION }}
845891 run : |
846892 git config user.name "github-actions[bot]"
@@ -858,20 +904,26 @@ jobs:
858904 fi
859905
860906 - name : Update GitHub Release
907+ if : steps.tag.outputs.SKIP != 'true'
861908 env :
862909 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
863- TAG_NAME : ${{ github.event.release.tag_name }}
910+ TAG_NAME : ${{ steps.tag.outputs.TAG_NAME }}
864911 run : |
865912 echo "Updating GitHub release with generated notes..."
866913 gh release edit "$TAG_NAME" --notes-file RELEASE_NOTES.md
867914 echo "✅ GitHub release updated successfully"
868915
869916 - name : Notify on failure
870- if : failure()
917+ if : failure() && steps.tag.outputs.SKIP != 'true'
871918 env :
872919 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
873- TAG_NAME : ${{ github.event.release.tag_name }}
920+ TAG_NAME : ${{ steps.tag.outputs.TAG_NAME || github.event.workflow_run.head_branch }}
874921 run : |
922+ # Fallback if TAG_NAME is empty
923+ if [ -z "$TAG_NAME" ]; then
924+ TAG_NAME="unknown"
925+ fi
926+
875927 gh issue create \
876928 --title "⚠️ Release notes generation failed for $TAG_NAME" \
877929 --body "The automated release notes generation for **$TAG_NAME** failed.
0 commit comments