-
Notifications
You must be signed in to change notification settings - Fork 0
/
identify_self
executable file
·121 lines (99 loc) · 1.85 KB
/
identify_self
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/sh
# identify_self — Identify Self
# Melusina Actions (https://github.com/melusina-org/setup-macports)
# This file is part of Melusina Actions.
#
# Copyright © 2022–2023 Michaël Le Barbier
# All rights reserved.
# This file must be used under the terms of the MIT License.
# This source file is licensed as described in the file LICENSE, which
# you should have received as part of this distribution. The terms
# are also available at https://opensource.org/licenses/MIT
wlog()
{
{
printf '%s: ' "$1"
shift
printf "$@"
printf '\n'
} 1>&2
}
failwith()
{
local OPTIND OPTION OPTARG status
status=1
OPTIND=1
while getopts 'x:' OPTION; do
case ${OPTION} in
x) status="${OPTARG}";;
*) 1>&2 printf 'failwith: %s: Unsupported option.\n' "${OPTION}";;
esac
done
shift $(expr ${OPTIND} - 1)
case "$1" in
[0-9][0-9][0-9]|[0-9][0-9]|[0-9])
status="$1"
shift
;;
*)
:
esac
wlog 'Error' "$@"
exit "${status}"
}
with_group_presentation()
(
if [ "${GITHUB_ACTIONS}" = 'true' ]; then
trap "printf '::endgroup::\n'" INT TERM EXIT
printf '::group::%s\n' "$1"
fi
shift
"$@"
)
identify_source()
{
local head
git_head()
(
cd "$1"
git rev-parse HEAD
)
cat <<EOF
Git HEAD: $(git_head)
EOF
}
identify_software()
{
yq_version()
{
yq --version | sed -e 's/.*version *//'
}
jq_version()
{
jq --version | sed -e 's/jq-//'
}
openssl_version()
{
if openssl version; then
:
else
printf ':not-found'
fi
}
cat <<EOF
yq: $(yq_version)
jq: $(jq_version)
openssl: $(openssl_version)
EOF
}
main()
{
with_group_presentation\
'Identify Source'\
identify_source "$@"
with_group_presentation\
'Identify Software'\
identify_software "$@"
}
main "$@"
# End of file `identify_self'