Getting the git commit/tag as a version

Hello !

With the old version of snapcraft (before switching to multipass), I used to have in my .yaml this :

version: git

This would take the git commit/tag of the first app and use it for the snap package version

I did not find anything in the doc and the forum, is there an easy way to have the version being the git commit/tag of one of the part/app with the current snapcraft ?

Try version-script: git -C parts/PARTNAME/src describe --tags. We have used this type of thing in a number of the snapcrafters snaps.

Isn’t version-script deprecated? I thought that the “new” way to do this was with snapcraftctl set-version? (I could be misremembering this of course)


Oh, well in that case, you could certainly use snapcraftctl set-version in an override-build or override-pull. Also, plenty of examples in snapcrafters repos :slight_smile:

1 Like

You can have a look at evince as an example and notice how they use version: git at the top but also put source-version: git in the parts (where necessary). Perhaps you’re missing the source-version bit?


That would be great !
I’m sorry I failed to find the source-version in you rexample and source-version:git in a part does not seem to work in my setup (snapcraft telling me source-version was unexpected.

To clarify, it sounds like you will want to use adopt-info: <part-with-version> and snapcraft set-version <version>

Documentation example:

snapcraft itself using a custom git-derived description:


Thanks ! This works beautifully !

Ah yes sorry, I mistyped. Should have read source-type: git in the parts section.