Skip to content

Commit 6313f41

Browse files
Merge pull request NVIDIA#14 from zyga/snap/nicer-version
snap: compute version and grade from git revision and tag
2 parents 61a3c7b + fb7369b commit 6313f41

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

‎snap/snapcraft.yaml‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ source-code: https://github.com/NVIDIA/OpenShell
1414
website: https://github.com/NVIDIA/OpenShell
1515
donation: https://nvidia.com/
1616

17-
grade: stable
17+
adopt-info: workspace
1818
confinement: strict
1919

2020
apps:
@@ -60,13 +60,43 @@ parts:
6060
- clang
6161
- libclang-dev
6262
- libz3-dev
63+
- git
6364
stage-packages:
6465
- libz3-4
6566
- skopeo
6667
- openssh-client
6768
- curl
6869
rust-features: []
6970
rust-path: ["crates/openshell-cli", "crates/openshell-server", "crates/openshell-driver-vm"]
71+
override-pull: |
72+
# Pull the source using snapcraft.
73+
craftctl default
74+
75+
# Set defaults.
76+
grade=devel
77+
full_tag="$(git describe --tags --abbrev=0 2>/dev/null)" || true
78+
hash="$(git rev-parse --short HEAD 2>/dev/null)"
79+
80+
# Remove leading 'v' from tag for the version string.
81+
tag="${full_tag#v}"
82+
83+
# Check for tagged version.
84+
if [ -n "$full_tag" ]; then
85+
count="$(git rev-list "$full_tag".. --count 2>/dev/null)"
86+
if [ "$count" -eq 0 ]; then
87+
version="$tag"
88+
grade=stable
89+
else
90+
version="$tag+git$count.$hash"
91+
fi
92+
else
93+
count="$(git rev-list HEAD --count 2>/dev/null)"
94+
version="0+git$count.$hash"
95+
fi
96+
97+
# Relay back to snapcraft.
98+
craftctl set grade="$grade"
99+
craftctl set version="$version"
70100
71101
vm-runtime:
72102
plugin: nil

0 commit comments

Comments
 (0)