forked from lambda-client/lambda-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.sh
More file actions
executable file
·57 lines (50 loc) · 1.17 KB
/
utils.sh
File metadata and controls
executable file
·57 lines (50 loc) · 1.17 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
#!/bin/bash
# Created by l1ving on 17/02/20
#
# Miscellaneous utilities used in other scripts
# Usage: "source ./utils.sh"
# Do not use this except to get relative script paths
root_kami_dir() {
pwd | sed "s/kamiblue.*/kamiblue/g"
}
check_var() {
if [ -z "$2" ]; then
echo "Variable '$1' is not set, exiting." >&2
exit 1
fi
}
check_git() {
if [ ! -d "$(root_kami_dir)/.git" ]; then
echo "Could not detect git repository, exiting" >&2
exit 1
elif [ ! "$(git status | tail -n 1)" == "nothing to commit, working tree clean" ]; then
echo "Either not working in a clean tree or you have unpushed commits. Exiting." >&2
exit 1
fi
}
# Usage: "generate_release_data "owner" "repo" "version" "branch or commit" "name" "description" "draft (bool)", "prerelease (bool)""
generate_release_data() {
cat <<EOF
{
"owner": "$1",
"repo": "$2",
"tag_name": "$3",
"target_commitish": "$4",
"name": "$5",
"body": "$6",
"draft": $7,
"prerelease": $8
}
EOF
}
# Usage: "generate_asset_data "owner" "repo" "release id""
generate_asset_data() {
cat <<EOF
{
"accept": "application/vnd.github.v3+json",
"owner": "$1",
"repo": "$2",
"release_id": "$3"
}
EOF
}