-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
64 lines (52 loc) · 1.27 KB
/
setup.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
#ver=> Ubuntu 20.04*
###@ MoltenObsidian setup script
###@ https://github.com/Nodsoft/setup-moltenobsidian
###@
###@ This script is intended to be used on a GitHub Actions runner
###@ to setup the MoltenObsidian CLI tool.
###@ It is assumed that the runner already has the following installed:
###@ - dotnet
# Try/catch functions
function try() {
[[ $- = *e* ]]
SAVED_OPT_E=$?
set +e
}
function catch() {
export ex_code=$?
(($SAVED_OPT_E)) && set +e
return $ex_code
}
function throw() {
exit $1
}
version=null
# Catch any errors
try
(
# Get version if any (option: -v <version>)
while getopts v: flag; do
if [ $flag == "v" ]; then
version=$OPTARG
fi
done
# Install MoltenObsidian
echo "Installing MoltenObsidian..."
command="dotnet tool install -g Nodsoft.MoltenObsidian.Tool"
if [ "$version" != "latest" ]; then
command="$command --version $version"
fi
# Debug
echo "::debug::Command: $command"
$command
echo "::group::MoltenObsidian installed successfully."
echo "Installed version: $(moltenobsidian --version)"
echo "::endgroup::"
)
catch ||
(
# Okay, something went wrong.
# Let's send an error back to the runner.
echo "::error title=Failed to install MoltenObsidian::Error: $ex_code"
)