Skip to content

release: next version 📦 #20

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

Merged
merged 7 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changesets/20250318T173603-pr-19.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "chore: update description"
pr: 19
author: "jasonbahl"
type: "chore"
breaking: false
description: |
null
---
44 changes: 34 additions & 10 deletions .github/workflows/release-management.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ jobs:
echo "has_changesets=true" >> $GITHUB_OUTPUT
else
echo "has_changesets=false" >> $GITHUB_OUTPUT
echo "No changesets found. Exiting."
exit 1
echo "No changesets found. Proceeding with release without changesets."
fi

- name: Determine version bump
Expand All @@ -84,8 +83,12 @@ jobs:
# Use the specified release type
npm run version:bump -- --type=${{ github.event.inputs.release_type }}
else
# Auto-detect release type from changesets
npm run version:bump
# Auto-detect release type from changesets, or default to patch if none found
if [[ "${{ steps.check_changesets.outputs.has_changesets }}" == "true" ]]; then
npm run version:bump
else
npm run version:bump -- --type=patch
fi
fi

# Get the new version after bump
Expand Down Expand Up @@ -155,10 +158,22 @@ jobs:

# Check if the file has content
if [ ! -s /tmp/release-notes/release_notes.md ]; then
# If empty, provide a default message
# If empty, provide a more informative default message
echo "## Release Notes" > /tmp/release-notes/release_notes.md
echo "" >> /tmp/release-notes/release_notes.md
echo "No changesets found. No changes to release at this time." >> /tmp/release-notes/release_notes.md

if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "This release was manually triggered with version bump type: ${{ github.event.inputs.release_type || 'auto' }}" >> /tmp/release-notes/release_notes.md
elif [[ "${{ github.event_name }}" == "schedule" ]]; then
echo "This is a scheduled release." >> /tmp/release-notes/release_notes.md
else
echo "This release was triggered by merging a PR from develop to main." >> /tmp/release-notes/release_notes.md
fi

echo "" >> /tmp/release-notes/release_notes.md
echo "No changesets were found for this release. This typically means:" >> /tmp/release-notes/release_notes.md
echo "- No features, fixes, or breaking changes were added, or" >> /tmp/release-notes/release_notes.md
echo "- The changes made did not require a changeset" >> /tmp/release-notes/release_notes.md
else
# If there is content, replace "Upcoming Changes" with "Release Notes" if present
sed -i 's/## Upcoming Changes/## Release Notes/g' /tmp/release-notes/release_notes.md
Expand Down Expand Up @@ -246,6 +261,7 @@ jobs:

- name: Handle release creation failure
if: (github.event_name == 'pull_request_target' || github.event_name == 'workflow_dispatch') && steps.create_release.outcome == 'failure'
id: handle_failure
run: |
echo "Failed to create release. This could be because the tag already exists."
echo "Checking if release exists..."
Expand All @@ -256,9 +272,11 @@ jobs:
"https://api.github.com/repos/${{ github.repository }}/releases/tags/v${{ steps.version_bump.outputs.version }}")

if [[ "$RELEASE_EXISTS" == "200" ]]; then
echo "Release for v${{ steps.version_bump.outputs.version }} already exists. Skipping release creation."
echo "Release for v${{ steps.version_bump.outputs.version }} already exists. Marking as successful."
echo "release_exists=true" >> $GITHUB_OUTPUT
else
echo "Release creation failed for an unknown reason."
echo "release_exists=false" >> $GITHUB_OUTPUT

# Check for rate limiting
RATE_LIMIT=$(curl -s \
Expand Down Expand Up @@ -299,6 +317,7 @@ jobs:
--title "Release v${{ steps.version_bump.outputs.version }}" \
--notes-file "${{ github.workspace }}/release_notes.md"; then
echo "Successfully created release using GitHub CLI"
echo "release_exists=true" >> $GITHUB_OUTPUT
else
echo "::error::Failed to create release using GitHub CLI with notes file."

Expand All @@ -308,8 +327,10 @@ jobs:
--title "Release v${{ steps.version_bump.outputs.version }}" \
--notes "${{ steps.release_notes.outputs.content }}"; then
echo "Successfully created release using GitHub CLI with inline notes"
echo "release_exists=true" >> $GITHUB_OUTPUT
else
echo "::error::Failed to create release using all methods. Please check logs for details."
echo "release_exists=false" >> $GITHUB_OUTPUT
exit 1
fi
fi
Expand All @@ -320,8 +341,10 @@ jobs:
--title "Release v${{ steps.version_bump.outputs.version }}" \
--notes "${{ steps.release_notes.outputs.content }}"; then
echo "Successfully created release using GitHub CLI with inline notes"
echo "release_exists=true" >> $GITHUB_OUTPUT
else
echo "::error::Failed to create release using all methods. Please check logs for details."
echo "release_exists=false" >> $GITHUB_OUTPUT
exit 1
fi
fi
Expand Down Expand Up @@ -350,14 +373,15 @@ jobs:
fi

- name: Delete processed changesets
if: github.event_name == 'pull_request_target' || github.event_name == 'workflow_dispatch'
# Only delete changesets if the release was successful or already exists
if: (github.event_name == 'pull_request_target' || github.event_name == 'workflow_dispatch') && (steps.create_release.outcome == 'success' || steps.handle_failure.outputs.release_exists == 'true')
run: |
# Configure Git
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"

# Check if the .changesets directory exists and contains files
if [ -d ".changesets" ]; then
if [ -d ".changesets" ] && [ "$(find .changesets -type f -name "*.md" | wc -l)" -gt 0 ]; then
# List all changesets before deleting (for logging purposes)
echo "Changesets found in directory:"
ls -la .changesets/
Expand Down Expand Up @@ -385,7 +409,7 @@ jobs:
exit 1
fi
else
echo "No .changesets directory found"
echo "No changeset files found to delete"
fi

- name: Update develop branch
Expand Down
2 changes: 1 addition & 1 deletion automation-tests.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: Automation Tests
* Description: A plugin to test automation workflows.
* Description: A plugin to test automation workflows. Updating description in @next-version
* Version: 5.1.0
* Author: Jason Bahl
*/
Expand Down
Loading