Use git version during build stage (downloading pre-built apps)


I’m trying to help the exercism cli team to make a snap package that can be automatically-built (maybe by

I’m trying to use version: git (which should work, the repo has tags for each version) but on my part build stage, when I try to download the tarfile, $SNAPCRAFT_PROJECT_VERSION has a value of git, which causes the download of$SNAPCRAFT_PROJECT_VERSION/exercism-linux-64bit.tgz to fail.

Documentation about $SNAPCRAFT_PROJECT_VERSION is very limited, from what I could find on this forum the git version is only available at later stages?

Is there an alternative way to do this?

Thank you :slight_smile:

Can someone give an answer, please? :slight_smile:


The recommended way would probably be to use a scriptlet to download the tarball rather than the declarative source: attribute, or ideally you’d set source: to a git repository and then check out the right version in an override-pull: block. This method means you can drop the version: git line:

    override-pull: |
      snapcraftctl pull
      last_committed_tag="$(git tag -l | grep -v v | sort -rV | head -n1)"
      last_committed_tag_ver="$(echo ${last_committed_tag} | sed 's/^v//')"
      git checkout "$last_committed_tag"
      snapcraftctl set-version "$last_committed_tag_ver"