-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.sh
40 lines (33 loc) · 1.19 KB
/
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
#!/bin/bash
get_latest_release() {
# Retrieves the latest release version of a github repsitory
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep -Po '"tag_name": "\K.*?(?=")' # Get tag line
}
get_latest_tag() {
# Retrieves the latest version tag of a github repsitory
curl "https://api.github.com/repos/$1/tags" |
grep -Po '"name": "\K.*?(?=")' |
head -1 # Get first tag from GitHub api
}
BOLD="$(tput bold 2>/dev/null || printf '')"
GREY="$(tput setaf 0 2>/dev/null || printf '')"
UNDERLINE="$(tput smul 2>/dev/null || printf '')"
RED="$(tput setaf 1 2>/dev/null || printf '')"
GREEN="$(tput setaf 2 2>/dev/null || printf '')"
YELLOW="$(tput setaf 3 2>/dev/null || printf '')"
BLUE="$(tput setaf 4 2>/dev/null || printf '')"
MAGENTA="$(tput setaf 5 2>/dev/null || printf '')"
NO_COLOR="$(tput sgr0 2>/dev/null || printf '')"
info() {
printf '%s\n' "${BOLD}${GREY}>${NO_COLOR} $*"
}
warn() {
printf '%s\n' "${YELLOW}! $*${NO_COLOR}"
}
error() {
printf '%s\n' "${RED}x $*${NO_COLOR}" >&2
}
completed() {
printf '%s\n' "${GREEN}✓${NO_COLOR} $*"
}