@@ -128,18 +128,26 @@ jobs:
128
128
shell : bash
129
129
id : lerna-publish
130
130
run : |
131
- # Attempt to publish all packages
132
- pnpm exec lerna publish from-package --force-publish --yes --otp ${{ steps.wait-for-secrets.outputs.OTP }}
133
- EXIT_CODE=$?
134
- echo "EXIT_CODE=$EXIT_CODE" >> $GITHUB_ENV
135
- OUTPUT=$(cat /dev/stdout)
136
- echo "OUTPUT=$OUTPUT" >> $GITHUB_ENV
131
+ set -o pipefail
132
+ OUTPUT_FILE=$(mktemp)
133
+ pnpm exec lerna publish from-package --force-publish --yes --otp ${{ steps.wait-for-secrets.outputs.OTP }} 2>&1 | tee $OUTPUT_FILE
134
+ EXIT_CODE=${PIPESTATUS[0]}
135
+ OUTPUT=$(cat $OUTPUT_FILE)
136
+ echo "publish_failed=false" >> $GITHUB_OUTPUT
137
+ echo "publish_output<<EOF" >> $GITHUB_OUTPUT
138
+ echo "$OUTPUT" >> $GITHUB_OUTPUT
139
+ echo "EOF" >> $GITHUB_OUTPUT
137
140
if [ $EXIT_CODE -ne 0 ]; then
138
- echo "::set-output name=publish_failed::true"
141
+ if echo "$OUTPUT" | grep -q 'HttpErrorAuthOTP'; then
142
+ echo "publish_failed=true" >> $GITHUB_OUTPUT
143
+ else
144
+ echo "::error title=Lerna Publish Failed::$OUTPUT"
145
+ exit $EXIT_CODE
146
+ fi
139
147
fi
140
148
141
149
- name : Check for EOTP and Prompt for New OTP
142
- if : ${{ steps.lerna-publish.outputs.publish_failed == 'true' && contains(env.OUTPUT, 'HttpErrorAuthOTP') }}
150
+ if : ${{ steps.lerna-publish.outputs.publish_failed == 'true' }}
143
151
uses : step-security/wait-for-secrets@v1
144
152
id : wait-for-new-otp
145
153
with :
@@ -149,14 +157,13 @@ jobs:
149
157
description: 'OTP from authenticator app'
150
158
151
159
- name : Retry Lerna Publish with New OTP
152
- if : ${{ steps.lerna-publish.outputs.publish_failed == 'true' && contains(env.OUTPUT, 'HttpErrorAuthOTP') }}
160
+ if : ${{ steps.lerna-publish.outputs.publish_failed == 'true' }}
153
161
env :
154
162
GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
155
163
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
156
164
NPM_CONFIG_PROVENANCE : true
157
165
shell : bash
158
166
run : |
159
- # Retry the publish command with the new OTP
160
167
pnpm exec lerna publish from-package --force-publish --yes --otp ${{ steps.wait-for-new-otp.outputs.OTP }} || {
161
168
echo "::error title=Publish Failed::Publishing failed even after providing a new OTP."
162
169
exit 1
0 commit comments