Good question. I haven't tested this and I don't know Node.js well in order to quickly test but here's my suggestion.
grep
returns an exit code of 0
if it finds something and 1
if it doesn't. Any exit code other than 0
means a failure to CircleCI. Grep's -q
flag means quiet, don't output text and the &&
means only run if the previous command passes. So, this might work for you:
- run:
name: Semantic Release
# Fail if there are no changes
command: npm run semantic-release | grep -q "There are no relevant changes, so no new version is released." && exit 1
Again, I haven't personally tested it so I don't know how semantic-release
outputs things but this might work.