-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.sh
47 lines (42 loc) · 827 Bytes
/
utils.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# shellcheck shell=bash
echo_stderr() {
echo "$@" >&2
}
begin_group() {
if [ $# -ne 1 ]; then
echo_stderr "Invalid use of $0"
exit 1
fi
echo "::group::$1"
}
# shellcheck disable=SC2120
end_group() {
if [ $# -ne 0 ]; then
echo_stderr "Invalid use of $0"
exit 1
fi
echo "::endgroup::"
}
crate_metadata() {
if [ $# -ne 1 ]; then
echo_stderr "Invalid use of $0"
exit 1
fi
crate="$1"
cargo metadata --format-version 1 --locked --no-deps | jq -r "
[ .packages[] | select(.name == \"$crate\") ] |
if length == 1 then
first
else
error(\"expected exactly one package named $crate\")
end
"
}
crate_version() {
if [ $# -ne 1 ]; then
echo_stderr "Invalid use of $0"
exit 1
fi
crate="$1"
crate_metadata "$crate" | jq -r '.version'
}