Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cr.sh: line 109: latest_tag: unbound variable #171

Open
na-jakobs opened this issue Oct 26, 2023 · 9 comments · May be fixed by #202
Open

cr.sh: line 109: latest_tag: unbound variable #171

na-jakobs opened this issue Oct 26, 2023 · 9 comments · May be fixed by #202

Comments

@na-jakobs
Copy link

na-jakobs commented Oct 26, 2023

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).

@na-jakobs
Copy link
Author

Steps to create an empty branch:

git checkout --orphan gh-pages
rm -rf .
git commit -m "gh-pages initial commit" --allow-empty
git push

vgrassia added a commit to bitwarden/helm-charts that referenced this issue Nov 6, 2023
Reverts #43

This action is not currently working. Same bug as
helm/chart-releaser-action#171
@IGx89
Copy link

IGx89 commented Nov 6, 2023

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?

@IGx89
Copy link

IGx89 commented Nov 6, 2023

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.

clemlesne added a commit to clemlesne/blue-agent that referenced this issue Nov 21, 2023
…ons/develop/helm/chart-releaser-action-1.6.0"

Bug helm/chart-releaser-action#171.

This reverts commit e99c326, reversing
changes made to 009810c.
@korenyoni
Copy link

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)

@IGx89
Copy link

IGx89 commented Dec 7, 2023

@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.

@korenyoni
Copy link

@IGx89

Cool yeah — I only took a quick look. In this case #130 definitely looks like the source of the regression.

@hegerdes
Copy link

Also facing this. Is there a workaround?

mishraomp added a commit to bcgov/nr-oracle-service that referenced this issue Feb 4, 2024
mishraomp added a commit to bcgov/nr-oracle-service that referenced this issue Feb 4, 2024
@IGx89
Copy link

IGx89 commented Mar 27, 2024

@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.

rofafor added a commit to elisasre/charts that referenced this issue Apr 5, 2024
didierofrivia added a commit to Kuadrant/helm-charts that referenced this issue Jun 18, 2024
didierofrivia added a commit to Kuadrant/helm-charts that referenced this issue Jun 18, 2024
fhofherr added a commit to fhofherr/chart-releaser-action that referenced this issue Jun 19, 2024
The chart_version output was written regardless of whether the
latest_tag variable was defined. The latest_tag variable is only defined
if skip_packaging is not set. This leads to issue helm#171.

Setting skip_packaging implies that an external process takes care of
packaging the chart and setting the chart version. There is thus no need
to write the chart_version output as it should already be known.

Closes helm#171
@fhofherr fhofherr linked a pull request Jun 19, 2024 that will close this issue
fhofherr added a commit to fhofherr/chart-releaser-action that referenced this issue Jun 19, 2024
The chart_version output was written regardless of whether the
latest_tag variable was defined. The latest_tag variable is only defined
if skip_packaging is not set. This leads to issue helm#171.

Setting skip_packaging implies that an external process takes care of
packaging the chart and setting the chart version. There is thus no need
to write the chart_version output as it should already be known.

Closes helm#171

Signed-off-by: Ferdinand Hofherr <[email protected]>
@bhperry
Copy link

bhperry commented Sep 24, 2024

seems like everything works fine, it just fails right at the end. Would be nice to get this fixed though.

guangbochen pushed a commit to guangbochen/chart-releaser-action that referenced this issue Nov 2, 2024
The chart_version output was written regardless of whether the
latest_tag variable was defined. The latest_tag variable is only defined
if skip_packaging is not set. This leads to issue helm#171.

Setting skip_packaging implies that an external process takes care of
packaging the chart and setting the chart version. There is thus no need
to write the chart_version output as it should already be known.

Closes helm#171

Signed-off-by: Ferdinand Hofherr <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants