Skip to content

Commit

Permalink
do not fail if grep does not find a match
Browse files Browse the repository at this point in the history
  • Loading branch information
CircleCI committed Nov 27, 2024
1 parent 01b9b15 commit 723fe23
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@ echo "Publish to NPM"
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc
echo "Running semantic-release"

# merge stderr and stdout and check for "no new version is released". If found, bail.
# merge stderr and stdout so we can examine the logs if the command fails logically but doesn't return a non-zero exit code
npm run semantic-release 2>&1 | tee semantic_release_logs.txt

cat semantic_release_logs.txt | grep "npm ERR! Exit status" > npm_error.txt
if [ -s npm_error.txt ]; then
if grep -q "npm ERR! Exit status" semantic_release_logs.txt; then
echo "semantic-release failed, see details above"
exit 1
fi

cat semantic_release_logs.txt | grep "no new version is released" > no_new_version.txt || echo "It looks like a new version has been published!"
if [ -s no_new_version.txt ]; then
echo "Marking deployment as failed as no new version would be released."
if grep -q "no new version is released" semantic_release_logs.txt; then
echo "Marking deployment as failed, as no new version would be released."
exit 1
fi


echo "Pushing to origin/main"
git push origin main

Expand Down

0 comments on commit 723fe23

Please sign in to comment.