Xcode Cloud always generates empty .txt file

Hi,

Having set up Xcode Cloud workflows being run from a tag, I wanted to automate release-notes generation for a release. I came up with the following script:

git log --pretty=format:%s git tag -l --sort=-v:refname "{CI_TAG}*" | head -1...git tag -l --sort=-v:refname "${CI_TAG}*" | head -2 | awk '{split($0, tags, "\n")} END {print tags[1]}' > release-notes.txt

Markdown messes it up a bit with a format of this script. Anyways, I ran it in with test values instead of CI_TAG and it does what I need. The script is working and generates an appropriate output to the file.

However, when it's added to ci_post_xcodebuild.sh or even at Build Phases it always results with an empty release-notes.txt file.

Why does it happen this way? What's going wrong?