python-project-template icon indicating copy to clipboard operation
python-project-template copied to clipboard

Writing new VERSION on MacOSX

Open drbecavin opened this issue 2 years ago • 1 comments

Describe the bug When I do make relase On my MacOSX. It cannot write properly VERSION file. This is due to the read command which is not working as expected in zsh.

To Reproduce Steps to reproduce the behavior: Run make release on a zsh shell.

Expected behavior

@echo "WARNING: This operation will create s version tag and push to github"
@read -p "Version? (provide the next x.y.z semver) : " TAG
@echo "$${TAG}" > project_name/VERSION

The TAG variable will always be voiid and thus the VERSION file will be emplty. No release actions will be triggered in github.

Desktop (please complete the following information):

  • OS: [macOS 12.0.1]
  • Zsh [zsh 5.8 (x86_64-apple-darwin21.0)]

Additional context For the moment I change by hand the version number in VERSION file. And I changed Makefile with: VERSION=$(shell cat checkatlas/VERSION)

@echo "Reading version $(VERSION) from: checkatlas/VERSION"
@$(ENV_PREFIX)gitchangelog > HISTORY.md
@git add checkatlas/VERSION HISTORY.md
@git commit -m "release: version $(VERSION) 🚀"

drbecavin avatar Jun 20 '22 19:06 drbecavin

I'll make a PR if I get a chance, but in the meantime, here is some info that might help. I believe the issue boils down to differences between bash and zsh. For zsh, the -p on a read command indicates that the value is to be read from a co-process, which is not the intended behavior here.

This worked for me with zsh on the CLI, I imagine it translates pretty literally to the Makefile:

read TAG\?"Version? (provide the next x.y.z semver) : " && echo "${TAG}"

It's worth finding a solution that works with either bash or zsh - I'm not sure if the above would satisfy that. One other option is to use echo to avoid differences in how read behaves. The -n means "don't print a newline after the message" and I believe it behaves the same way for bash and zsh, but haven't confirmed it.

For example:

echo -n "Version? (provide the next x.y.z semver) : "
read TAG
echo "${TAG}"

Maybe support for bash is less valuable since macOS switched the default shell to zsh in the last couple of years. 🤷‍♂️

Useful resources:

  • https://askubuntu.com/questions/1246576/zsh-read-p-no-coprocess-error-while-using-read-command-with-p-flag
  • https://zsh.sourceforge.io/Doc/Release/Shell-Builtin-Commands.html

mikeoertli avatar Aug 05 '22 14:08 mikeoertli