chart-releaser-action
chart-releaser-action copied to clipboard
cr.sh: line 109: latest_tag: unbound variable
cr.sh will fail if there are no tags in the repository.
Steps to recreate:
- Create an empty branch (
git checkout --orphan gh-pages
) and push to repo
Pushing to branch "gh-pages"
warning: not sending a push certificate since the receiving end does not support --signed push
To https://github.com/<org>/<repo>
298a8e3..218a1fc HEAD -> gh-pages
/__w/_actions/helm/chart-releaser-action/main/cr.sh: line 109: latest_tag: unbound variable
Error: Process completed with exit code 1.
I am using the latest version of the action (main branch).
Steps to create an empty branch:
git checkout --orphan gh-pages
rm -rf .
git commit -m "gh-pages initial commit" --allow-empty
git push
Just ran into this too when upgrading from v1.5 to v1.6. The code only sets the latest_tag variable when skip_packaging is false, but it still attempts to read the variable when skip_packaging is true:
if [[ -z "$skip_packaging" ]]; then
echo 'Looking up latest tag...'
local latest_tag
latest_tag=$(lookup_latest_tag)
...
else
install_chart_releaser
rm -rf .cr-index
mkdir -p .cr-index
release_charts
update_index
fi
echo "chart_version=${latest_tag}" >chart_version.txt
Looks like the bug was introduced in #130 by @n-oden. Hopefully a simple fix?
This error might have two causes, no tags in repo and skip_packaging set to false -- I'm still getting it in the latter scenario even with tags present.
Looks like the bug was introduced in #130 by @n-oden. Hopefully a simple fix?
On a quick glance, #96 is more likely to be the source of this issue than #130 (which doesn't change lookup_latest_tag
's logic at all)
@korenyoni thanks for taking a look, but lookup_latest_tag isn't even called in my scenario's code path (skip_packaging = false).
Take a look at this code added in #130 (abridged to make the bug more obvious):
if [[ -z "$skip_packaging" ]]; then
echo 'Looking up latest tag...'
local latest_tag
latest_tag=$(lookup_latest_tag)
...
fi
echo "chart_version=${latest_tag}" >chart_version.txt
See how latest_tag is declared a local variable and then is accessed outside of its scope. If this was C# the compiler would throw an error :p.
@IGx89
Cool yeah — I only took a quick look. In this case #130 definitely looks like the source of the regression.
Also facing this. Is there a workaround?
@davidkarlsen I see you seem to be a maintainer of this repo. Sorry to bother you, but would you be able to take a look at this? Quite a few of us have had to downgrade back to v1.5 due to this bug. I'd love to use some of the new functionality from 1.6 but currently can't. If you have time to review/merge PRs but not create them, let us know and maybe we can contribute a fix for this regression. I see 9 open PRs so I'm hesitant to spend time on that myself without knowing someone would look at it.