-
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
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') | ||||||||||||||||||||||||||||||
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. If
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
if [ "$published_count" -gt 0 ]; then | ||||||||||||||||||||||||||||||
Comment on lines
+202
to
+205
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. 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.
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||
echo "✅ Successfully published $published_count package(s)." | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
# 4. Extract the published package details into a compact JSON string. | ||||||||||||||||||||||||||||||
# This creates a JSON array like: '[{"name":"pkg-a","version":"1.0.0"},...]' | ||||||||||||||||||||||||||||||
published_packages=$(echo "$json_summary" | jq -c '.packages') | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
# 5. Set both outputs for subsequent jobs. | ||||||||||||||||||||||||||||||
echo "published=true" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||
echo "publishedPackages=$published_packages" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
# 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 commentThe reason will be displayed to describe this comment to others. Learn more. This command will fail if there are no tags at HEAD (when
Suggested change
Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||
echo "No packages were published." | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
# Set both outputs to their empty/false state. | ||||||||||||||||||||||||||||||
echo "published=false" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||
echo "publishedPackages=[]" >> "$GITHUB_OUTPUT" | ||||||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||||||
env: | ||||||||||||||||||||||||||||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' | ||||||||||||||||||||||||||||||
NPM_TOKEN: '${{ secrets.NPM_TOKEN }}' | ||||||||||||||||||||||||||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
notify: | ||||||||||||||||||||||||||||||
name: Notify Slack & Website | ||||||||||||||||||||||||||||||
|
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.Copilot uses AI. Check for mistakes.