During a conversation with @niemeyer it came to our attention that just echoing a value at the end of the script defined in version-script
would make it, on one hand error prone and on the other not extensible.
The proposal is to instead of echo
in the script to instead call these shell functions:
set-version
set-grade
So in an example this would look like:
version: 1.0
version-script: |
# We just want the version with a date appended
set-version $SNAPCRAFT_PROJECT_VERSION-$(date +%Y%m%d.%H%m)
# The grade will be stable on the 15th of every month and devel for every other day
# THIS IS JUST AN EXAMPLE
if [ $(date +%d) = "15" ]; then
set-grade stable
else
set-grade devel
The helper functions setup by snapcraft will do the appropriate validations to determine if valid values are being passed on and provide appropriate error messages.
With the introduction of this feature, the echoing one would go away.