How to get `pkg_version` in `pkg_source` to respect an dynamic version?

The key bits of my build plan look like this:

pkg_version() {
  git tag --sort="version:refname" | tail --lines=1 | cut --delimiter=v --fields=2


do_before() {
  return $?

But I see this in my build logs:

circonus-agent: Version updated to '0.13.0'

circonus-agent: Downloading '' to 'circonus-agent__linux_64-bit.tar.gz'

Hrmm… that’s tricky. The reason it’s failing as written is that pkg_source, being at the top-level of the plan, is evaluated as we read it in. It’s also referring to ${pkg_version}, a variable which doesn’t exist in this context (since pkg_version is a function).

A brief look at the code suggests that we don’t subject pkg_source to the kind of modification that other variables get when we run update_pkg_version. We should be able to do that. Would you mind filing a bug report on this?

That’s what I suspected. I’ll do that.

1 Like