-
Notifications
You must be signed in to change notification settings - Fork 69
fix: notify release step #3010
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?
fix: notify release step #3010
Conversation
|
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.
Pull Request Overview
This pull request refactors the release workflow to replace the changesets GitHub Action with a custom shell script implementation for publishing packages and creating GitHub releases.
Key changes:
- Replaces the
changesets/action@v1
with a custom shell script that handles package publishing, tagging, and GitHub release creation - Adds logic to detect if packages were actually published and conditionally create releases
- Introduces structured output variables for downstream jobs to consume
set -e | ||
|
||
# 1. Publish packages, capturing the JSON summary report at the end. | ||
publish_output=$(pnpm publish -r --no-git-checks --report-summary || true) |
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.
Using || true
masks all potential errors from the publish command, making it difficult to distinguish between actual failures and expected scenarios where no packages need publishing. Consider checking the exit code explicitly or using a more specific error handling approach.
publish_output=$(pnpm publish -r --no-git-checks --report-summary || true) | |
set +e | |
publish_output=$(pnpm publish -r --no-git-checks --report-summary 2>&1) | |
publish_exit_code=$? | |
set -e |
Copilot uses AI. Check for mistakes.
# 3. Check if any packages were actually published by checking the 'added' count. | ||
published_count=$(echo "$json_summary" | jq -r '.added') | ||
|
||
if [ "$published_count" -gt 0 ]; then |
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.
Extracting JSON from the last line assumes the JSON summary is always on the final line, but if the publish command fails or produces unexpected output, this could capture non-JSON content. Consider validating that the extracted content is valid JSON before proceeding.
# 3. Check if any packages were actually published by checking the 'added' count. | |
published_count=$(echo "$json_summary" | jq -r '.added') | |
if [ "$published_count" -gt 0 ]; then | |
# Validate that the extracted line is valid JSON. | |
if ! echo "$json_summary" | jq empty > /dev/null 2>&1; then | |
echo "❌ Error: The last line of pnpm publish output is not valid JSON. Aborting publish step." | |
echo "published=false" >> "$GITHUB_OUTPUT" | |
echo "publishedPackages=[]" >> "$GITHUB_OUTPUT" | |
exit 1 | |
fi | |
# 3. Check if any packages were actually published by checking the 'added' count. | |
published_count=$(echo "$json_summary" | jq -r '.added') |
Copilot uses AI. Check for mistakes.
|
||
# 6. Create Git tags and GitHub Releases. | ||
npx changeset tag | ||
git tag --points-at HEAD | xargs -I % sh -c 'gh release create % --generate-notes' |
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.
This command will fail if there are no tags at HEAD (when git tag --points-at HEAD
returns empty). Consider adding a check to ensure tags exist before attempting to create releases, or handle the case where no tags are found.
git tag --points-at HEAD | xargs -I % sh -c 'gh release create % --generate-notes' | |
tags_at_head=$(git tag --points-at HEAD) | |
if [ -n "$tags_at_head" ]; then | |
echo "$tags_at_head" | xargs -I % sh -c 'gh release create % --generate-notes' | |
else | |
echo "No tags found at HEAD; skipping GitHub release creation." | |
fi |
Copilot uses AI. Check for mistakes.
json_summary=$(echo "$publish_output" | tail -n 1) | ||
|
||
# 3. Check if any packages were actually published by checking the 'added' count. | ||
published_count=$(echo "$json_summary" | jq -r '.added') |
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.
If jq
fails to parse the JSON or the .added
field doesn't exist, this will produce an empty string or 'null', which could cause the subsequent numeric comparison to fail. Consider adding validation to ensure the value is a valid number before the comparison.
published_count=$(echo "$json_summary" | jq -r '.added') | |
published_count=$(echo "$json_summary" | jq -r 'if (.added | type == "number") then .added else 0 end') |
Copilot uses AI. Check for mistakes.
Size Change: 0 B Total Size: 1.98 MB ℹ️ View Unchanged
|
✍️ Proposed changes
🎟 Jira ticket: Name of ticket
✅ Checklist
For bug fixes, new features & breaking changes
pnpm changeset
and documented my changesFor new components
🧪 How to test changes