From 431c7807ffc6356d94d690df581e899c9b2750ab Mon Sep 17 00:00:00 2001 From: Stephen Lee Date: Tue, 5 Aug 2025 17:30:07 -0700 Subject: [PATCH] fix: notify release step --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 09a7aec63c..668ec85648 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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') + + if [ "$published_count" -gt 0 ]; then + 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' + + 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