@@ -109,20 +109,39 @@ jobs:
109109 - name : Publish Release
110110 id : publish
111111 run : |
112- GITHUB_ACTIONS=0 pnpm run build > build.output.txt 2>&1
113- pnpm exec changeset publish --tag experimental--${{ steps.getSnapshotName.outputs.result }} > publish.output.txt 2>&1
112+ set -o pipefail
113+ GITHUB_ACTIONS=0 pnpm run build 2>&1 | tee build.output.txt
114+ BUILD_EXIT_CODE=$?
115+
116+ if [ $BUILD_EXIT_CODE -ne 0 ]; then
117+ echo "::error::Build failed. See output above."
118+ # Store the build output for the notification step before exiting
119+ EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
120+ echo "build<<$EOF" >> $GITHUB_OUTPUT
121+ echo "$(cat build.output.txt)" >> $GITHUB_OUTPUT
122+ echo "$EOF" >> $GITHUB_OUTPUT
123+ exit 1
124+ fi
125+
126+ pnpm exec changeset publish --tag experimental--${{ steps.getSnapshotName.outputs.result }} 2>&1 | tee publish.output.txt
127+ PUBLISH_EXIT_CODE=$?
128+
129+ if [ $PUBLISH_EXIT_CODE -ne 0 ]; then
130+ echo "::error::Publish failed. See output above."
131+ fi
114132
115133 EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
116134
117135 echo "build<<$EOF" >> $GITHUB_OUTPUT
118136 echo "$(cat build.output.txt)" >> $GITHUB_OUTPUT
119137 echo "$EOF" >> $GITHUB_OUTPUT
120- cat build.output.txt
121138
122139 echo "publish<<$EOF" >> $GITHUB_OUTPUT
123140 echo "$(cat publish.output.txt)" >> $GITHUB_OUTPUT
124141 echo "$EOF" >> $GITHUB_OUTPUT
125- cat publish.output.txt
142+
143+ # Exit with error if publish failed
144+ exit $PUBLISH_EXIT_CODE
126145 env :
127146 # Needs access to publish to npm
128147 NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
@@ -133,33 +152,51 @@ jobs:
133152
134153 - name : Pull Request Notification
135154 uses : actions/github-script@v7
155+ if : always()
136156 env :
137157 TAG : ${{ steps.getSnapshotName.outputs.result }}
138158 STATUS_DATA : ${{ steps.changesets.outputs.status }}
139159 BUILD_LOG : ${{ steps.publish.outputs.build }}
140160 PUBLISH_LOG : ${{ steps.publish.outputs.publish }}
161+ JOB_STATUS : ${{ job.status }}
141162 with :
142163 script : |
143164 let changeset = { releases: [] };
144165 try {
145166 changeset = JSON.parse(process.env.STATUS_DATA);
146167 } catch (e) {}
147- let message = 'Snapshots have been released for the following packages:'
148- for (const release of changeset.releases) {
149- if (release.type === 'none') continue;
150- message += `\n- \`${release.name}@experimental--${process.env.TAG}\``;
168+
169+ let message = '';
170+
171+ if (process.env.JOB_STATUS === 'success') {
172+ message = 'Snapshots have been released for the following packages:';
173+ for (const release of changeset.releases) {
174+ if (release.type === 'none') continue;
175+ message += `\n- \`${release.name}@experimental--${process.env.TAG}\``;
176+ }
177+ } else {
178+ message = '❌ Snapshot release failed.';
151179 }
152180
153- function details(title, body) {
181+ function details(title, body, failed = false) {
182+ if (!body) return;
154183 message += '\n';
155- message += `<details><summary><strong>${title}</strong></summary>`
184+ const icon = failed ? '❌ ' : '';
185+ message += `<details><summary><strong>${icon}${title}</strong></summary>`;
156186 message += '\n\n```\n';
157187 message += body;
158188 message += '\n```\n\n</details>';
159189 }
160190
161- details('Publish Log', process.env.PUBLISH_LOG);
162- details('Build Log', process.env.BUILD_LOG);
191+ // Show build log first if it exists
192+ if (process.env.BUILD_LOG) {
193+ details('Build Log', process.env.BUILD_LOG, process.env.JOB_STATUS !== 'success');
194+ }
195+
196+ // Only show publish log if it exists (might not if build failed)
197+ if (process.env.PUBLISH_LOG) {
198+ details('Publish Log', process.env.PUBLISH_LOG, process.env.JOB_STATUS !== 'success');
199+ }
163200
164201 github.rest.issues.createComment({
165202 issue_number: context.issue.number,
0 commit comments