-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload_bom.sh
More file actions
executable file
·92 lines (84 loc) · 2.14 KB
/
upload_bom.sh
File metadata and controls
executable file
·92 lines (84 loc) · 2.14 KB
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
#!/bin/bash
set -eou pipefail
name=""
version=""
tlp=""
on_existing="error"
# Parse options
while [[ $# -gt 0 ]]; do
case "$1" in
-n|--name)
name="$2"
shift 2
;;
--name=*)
name="${1#*=}"
shift
;;
-v|--version)
version="$2"
shift 2
;;
--version=*)
version="${1#*=}"
shift
;;
-t|--tlp)
tlp="$2"
shift 2
;;
--tlp=*)
tlp="${1#*=}"
shift
;;
--on-existing)
on_existing="$2"
shift 2
;;
--on-existing=*)
on_existing="${1#*=}"
shift
;;
--)
shift
break
;;
-*)
echo "Unknown option: $1"
exit 1
;;
*)
bom_file="$1"
shift
;;
esac
done
if [ -z "$bom_file" ]; then
echo "Error: BOM file path is required."
exit 1
fi
bomnipotent_command="bomnipotent_client"
if ! command -v $bomnipotent_command &> /dev/null; then
bomnipotent_command="bomnipotent_client.exe"
fi
if ! command -v $bomnipotent_command &> /dev/null; then
echo "Error: The BOMnipotent Client binary is not available in the PATH. Please make sure it is."
echo "Inside GitHub Actions, you can use Weichwerke-Heidrich-Software/setup-bomnipotent-action to that end."
echo "https://github.com/marketplace/actions/setup-bomnipotent-client"
exit 1
fi
if [ -f "$name" ]; then
echo "Reading BOM name from file: $name"
name=$(head -n 1 "$name" | head -c 256)
fi
if [ -f "$version" ]; then
echo "Reading BOM version from file: $version"
version=$(head -n 1 "$version" | head -c 256)
fi
args=(bom upload "$bom_file")
[ -n "$name" ] && args+=(--name-overwrite "$name")
[ -n "$version" ] && args+=(--version-overwrite "$version")
[ -n "$tlp" ] && args+=(--tlp "$tlp")
[ -n "$on_existing" ] && args+=(--on-existing "$on_existing")
echo "Calling BOMnipotent with args ${args[*]}"
"$bomnipotent_command" "${args[@]}"