-
Notifications
You must be signed in to change notification settings - Fork 0
fix: reorder release-please jobs and fix enhance-release-pr workflow #15
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
Changes from all commits
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ on: | |||||
| types: [opened, synchronize, reopened] | ||||||
| branches: | ||||||
| - main | ||||||
| workflow_dispatch: # Added to allow manual triggering | ||||||
|
|
||||||
| # Cancel in-progress runs when a new commit is pushed to the same PR | ||||||
| concurrency: | ||||||
|
|
@@ -20,20 +21,21 @@ permissions: | |||||
| jobs: | ||||||
| enhance-release-pr: | ||||||
| name: 🤖 Claude AI Enhancement | ||||||
| if: startsWith(github.head_ref, 'release-please--') | ||||||
| if: startsWith(github.event.pull_request.head.ref, 'release-please--') | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - name: 📥 Checkout PR Branch | ||||||
| uses: actions/checkout@v5 | ||||||
| with: | ||||||
| ref: ${{ github.head_ref }} | ||||||
| ref: ${{ github.event.pull_request.head.ref }} | ||||||
| fetch-depth: 0 | ||||||
| token: ${{ secrets.GITHUB_TOKEN }} | ||||||
|
|
||||||
| - name: 🏷️ Extract Version from PR Title | ||||||
| id: version | ||||||
| run: | | ||||||
| VERSION=$(echo "${{ github.event.pull_request.title }}" | grep -oP '\d+\.\d+\.\d+' || echo "") | ||||||
| # Extract version using sed -E (extended regex, more portable than grep -P) | ||||||
| VERSION=$(echo "${{ github.event.pull_request.title }}" | sed -E 's/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/' || echo "") | ||||||
|
Comment on lines
34
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new sed-based extraction returns the original PR title when no Useful? React with 👍 / 👎.
|
||||||
| VERSION=$(echo "${{ github.event.pull_request.title }}" | sed -E 's/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/' || echo "") | |
| VERSION=$(echo "${{ github.event.pull_request.title }}" | sed -n -E 's/.*([0-9]+\.[0-9]+\.[0-9]+).*/\1/p') |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,54 +32,19 @@ permissions: | |||||||
| actions: write | ||||||||
|
|
||||||||
| jobs: | ||||||||
| release-please: | ||||||||
| name: 📦 Release Please | ||||||||
| runs-on: ubuntu-latest | ||||||||
| outputs: | ||||||||
| release_created: ${{ steps.release.outputs.release_created }} | ||||||||
| releases_created: ${{ steps.release.outputs.releases_created }} | ||||||||
| tag_name: ${{ steps.release.outputs.tag_name }} | ||||||||
| version: ${{ steps.release.outputs.version }} | ||||||||
| major: ${{ steps.release.outputs.major }} | ||||||||
| minor: ${{ steps.release.outputs.minor }} | ||||||||
| patch: ${{ steps.release.outputs.patch }} | ||||||||
| sha: ${{ steps.release.outputs.sha }} | ||||||||
| pr: ${{ steps.release.outputs.pr }} | ||||||||
| prs_created: ${{ steps.release.outputs.prs_created }} | ||||||||
| steps: | ||||||||
| - name: 📥 Checkout source code | ||||||||
| uses: actions/checkout@v4 | ||||||||
|
|
||||||||
| - name: 🤖 Run Release Please | ||||||||
| id: release | ||||||||
| uses: googleapis/release-please-action@v4 | ||||||||
| with: | ||||||||
| token: ${{ secrets.GITHUB_TOKEN }} | ||||||||
| config-file: release-please-config.json | ||||||||
| manifest-file: .release-please-manifest.json | ||||||||
| target-branch: ${{ github.ref_name }} | ||||||||
|
|
||||||||
| - name: 📝 Log Release Info | ||||||||
| if: ${{ steps.release.outputs.releases_created == 'true' }} | ||||||||
| run: | | ||||||||
| echo "🎉 Release created!" | ||||||||
| echo "📦 Version: ${{ steps.release.outputs.version }}" | ||||||||
| echo "🏷️ Tag: ${{ steps.release.outputs.tag_name }}" | ||||||||
| echo "🔗 https://github.com/${{ github.repository }}/releases/tag/${{ steps.release.outputs.tag_name }}" | ||||||||
|
|
||||||||
| # ============================================================================= | ||||||||
| # Fallback: Handle Untagged Merged Release PRs | ||||||||
| # ============================================================================= | ||||||||
| # If Release Please aborts due to "untagged merged release PRs", this job | ||||||||
| # will find those PRs, create the missing tags, and create GitHub releases. | ||||||||
| # This handles edge cases like when Claude changes the version in a Release PR. | ||||||||
| # Step 1: Handle Untagged Merged Release PRs FIRST | ||||||||
| # ============================================================================= | ||||||||
| # This MUST run before release-please to prevent "untagged PRs outstanding" abort | ||||||||
| # Release Please aborts if it finds merged PRs with "autorelease: pending" label | ||||||||
| # By running this first, we ensure all untagged PRs are tagged before Release Please checks | ||||||||
| handle-untagged-releases: | ||||||||
| name: 🔧 Handle Untagged Releases (Fallback) | ||||||||
| needs: release-please | ||||||||
| # Run if Release Please didn't create a release (might have aborted) | ||||||||
| if: ${{ needs.release-please.outputs.releases_created != 'true' }} | ||||||||
| name: 🔧 Handle Untagged Releases (Pre-Check) | ||||||||
| runs-on: ubuntu-latest | ||||||||
| outputs: | ||||||||
| release_created: ${{ steps.process.outputs.release_created }} | ||||||||
| tag_name: ${{ steps.process.outputs.tag_name }} | ||||||||
| version: ${{ steps.process.outputs.version }} | ||||||||
|
Comment on lines
+44
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The job exports Useful? React with 👍 / 👎.
Comment on lines
+45
to
+47
|
||||||||
| steps: | ||||||||
| - name: 📥 Checkout source code | ||||||||
| uses: actions/checkout@v4 | ||||||||
|
|
@@ -127,7 +92,6 @@ jobs: | |||||||
| echo " SHA: $MERGE_SHA" | ||||||||
| echo " Tag: $TAG_NAME" | ||||||||
|
|
||||||||
| # Check if tag already exists | ||||||||
| if gh api repos/${{ github.repository }}/git/refs/tags/$TAG_NAME 2>/dev/null; then | ||||||||
| echo "✅ Tag $TAG_NAME already exists" | ||||||||
| else | ||||||||
|
|
@@ -138,13 +102,14 @@ jobs: | |||||||
| -f sha="$MERGE_SHA" | ||||||||
| fi | ||||||||
|
|
||||||||
| # Check if release already exists | ||||||||
| if gh release view $TAG_NAME --repo ${{ github.repository }} 2>/dev/null; then | ||||||||
| echo "✅ Release $TAG_NAME already exists" | ||||||||
| else | ||||||||
| echo "🎉 Creating GitHub Release $TAG_NAME" | ||||||||
| RELEASE_CREATED=true | ||||||||
| LATEST_TAG="$TAG_NAME" | ||||||||
| LATEST_VERSION="$VERSION" | ||||||||
|
|
||||||||
| # Extract changelog for this version | ||||||||
| CHANGELOG=$(awk -v ver="$VERSION" ' | ||||||||
| /^## \[/ { | ||||||||
| if (found) exit | ||||||||
|
|
@@ -157,7 +122,6 @@ jobs: | |||||||
| CHANGELOG="Release v$VERSION - See [CHANGELOG.md](https://github.com/${{ github.repository }}/blob/${{ github.ref_name }}/CHANGELOG.md) for details." | ||||||||
| fi | ||||||||
|
|
||||||||
| # Create release notes file using printf (heredocs break YAML indentation) | ||||||||
| { | ||||||||
| echo "## 📦 Installation" | ||||||||
| echo "" | ||||||||
|
|
@@ -185,36 +149,88 @@ jobs: | |||||||
| echo "$CHANGELOG" | ||||||||
| } > /tmp/release_notes.md | ||||||||
|
|
||||||||
| # Create the release | ||||||||
| gh release create $TAG_NAME \ | ||||||||
| --repo ${{ github.repository }} \ | ||||||||
| --title "v$VERSION" \ | ||||||||
| --notes-file /tmp/release_notes.md | ||||||||
| fi | ||||||||
|
|
||||||||
| # Update label to autorelease: tagged | ||||||||
| echo "🏷️ Updating PR #$PR_NUM label to autorelease: tagged" | ||||||||
| gh pr edit $PR_NUM \ | ||||||||
| --repo ${{ github.repository }} \ | ||||||||
| --remove-label "autorelease: pending" \ | ||||||||
| --add-label "autorelease: tagged" || true | ||||||||
|
|
||||||||
| echo "✅ Processed PR #$PR_NUM" | ||||||||
| done | ||||||||
| done < <(echo "$PENDING_PRS" | jq -c '.') | ||||||||
|
||||||||
|
|
||||||||
| # Output the latest release info (if any was created) | ||||||||
| if [ "$RELEASE_CREATED" = "true" ]; then | ||||||||
| echo "release_created=true" >> $GITHUB_OUTPUT | ||||||||
| echo "tag_name=$LATEST_TAG" >> $GITHUB_OUTPUT | ||||||||
| echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT | ||||||||
| else | ||||||||
| echo "release_created=false" >> $GITHUB_OUTPUT | ||||||||
| fi | ||||||||
|
|
||||||||
| # ============================================================================= | ||||||||
| # Step 2: Run Release Please (after untagged PRs are handled) | ||||||||
| # ============================================================================= | ||||||||
| release-please: | ||||||||
| name: 📦 Release Please | ||||||||
| needs: handle-untagged-releases | ||||||||
| runs-on: ubuntu-latest | ||||||||
| outputs: | ||||||||
| release_created: ${{ steps.release.outputs.release_created }} | ||||||||
| releases_created: ${{ steps.release.outputs.releases_created }} | ||||||||
| tag_name: ${{ steps.release.outputs.tag_name }} | ||||||||
| version: ${{ steps.release.outputs.version }} | ||||||||
| major: ${{ steps.release.outputs.major }} | ||||||||
| minor: ${{ steps.release.outputs.minor }} | ||||||||
| patch: ${{ steps.release.outputs.patch }} | ||||||||
| sha: ${{ steps.release.outputs.sha }} | ||||||||
| pr: ${{ steps.release.outputs.pr }} | ||||||||
| prs_created: ${{ steps.release.outputs.prs_created }} | ||||||||
| steps: | ||||||||
| - name: 📥 Checkout source code | ||||||||
| uses: actions/checkout@v4 | ||||||||
|
|
||||||||
| - name: 🤖 Run Release Please | ||||||||
| id: release | ||||||||
| uses: googleapis/release-please-action@v4 | ||||||||
| with: | ||||||||
| token: ${{ secrets.GITHUB_TOKEN }} | ||||||||
| config-file: release-please-config.json | ||||||||
| manifest-file: .release-please-manifest.json | ||||||||
| target-branch: ${{ github.ref_name }} | ||||||||
|
|
||||||||
| - name: 📝 Log Release Info | ||||||||
| if: ${{ steps.release.outputs.releases_created == 'true' }} | ||||||||
| run: | | ||||||||
| echo "🎉 Release created!" | ||||||||
| echo "📦 Version: ${{ steps.release.outputs.version }}" | ||||||||
| echo "🏷️ Tag: ${{ steps.release.outputs.tag_name }}" | ||||||||
| echo "🔗 https://github.com/${{ github.repository }}/releases/tag/${{ steps.release.outputs.tag_name }}" | ||||||||
|
|
||||||||
| # ============================================================================= | ||||||||
| # Step 3: Verify Release | ||||||||
| # ============================================================================= | ||||||||
|
|
||||||||
| # ============================================================================= | ||||||||
| # Verify Release | ||||||||
| # ============================================================================= | ||||||||
|
Comment on lines
219
to
221
|
||||||||
| # ============================================================================= | |
| # Verify Release | |
| # ============================================================================= |
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.
Adding
workflow_dispatchtrigger without handling the case whengithub.event.pull_requestis null will cause failures. When manually triggered,github.event.pull_request.number(line 12),github.event.pull_request.head.ref(lines 24, 30, 145, 319),github.event.pull_request.title(line 38), andgithub.event.pull_request.base.ref(lines 58-59) will all be undefined, causing the workflow to fail. Either add inputs toworkflow_dispatchto provide these values, or guard the job execution with a condition that checks if the trigger ispull_request.