diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 29a4d28d160..dd2d98a391e 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -48,6 +48,15 @@ parts: - LDFLAGS: "" override-pull: | snapcraftctl pull + + last_committed_tag="$(git for-each-ref --sort=taggerdate --format '%(tag)' refs/tags | tail -n 1)" + last_released_tag="$(snap info gitea | awk '$1 == "latest/candidate:" { print $2 }')" + # If the latest tag from the upstream project has not been released to + # stable, build that tag instead of master. + if [ "${last_committed_tag}" != "${last_released_tag}" ]; then + git fetch + git checkout "${last_committed_tag}" + fi version="$(git describe --always | sed -e 's/-/+git/;y/-/./')" [ -n "$(echo $version | grep "+git")" ] && grade=devel || grade=stable