-
Notifications
You must be signed in to change notification settings - Fork 71
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
fix: notify release step #3010
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 | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -187,16 +187,46 @@ jobs: | |||||||||||||||||||||||||||||
| tools/*/stories.js | ||||||||||||||||||||||||||||||
| key: ${{needs.build.outputs.cache-primary-key}} | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| - name: Version packages | ||||||||||||||||||||||||||||||
| - name: Version, Publish & Create GitHub Release | ||||||||||||||||||||||||||||||
| id: changesets | ||||||||||||||||||||||||||||||
| uses: changesets/action@v1 | ||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||
| version: pnpm run version | ||||||||||||||||||||||||||||||
| publish: pnpm publish -r --no-git-checks | ||||||||||||||||||||||||||||||
| createGithubReleases: true | ||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||
| set -e | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # 1. Publish packages, capturing the JSON summary report at the end. | ||||||||||||||||||||||||||||||
| publish_output=$(pnpm publish -r --no-git-checks --report-summary || true) | ||||||||||||||||||||||||||||||
| echo "$publish_output" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # 2. Extract the JSON summary from the last line of the output. | ||||||||||||||||||||||||||||||
| 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') | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| 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
AI
Aug 6, 2025
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
AI
Aug 6, 2025
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 |
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
|| truemasks 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.