generated from saic-oss/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 7
/
lib_updates
69 lines (60 loc) · 2.46 KB
/
lib_updates
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
#!/usr/bin/env shellspec
# Check DNF for an update to the given package
# Inputs: package to check for an update, e.g. "container.io"
# Return: 0 if an update is availabe; non-0 if no update is available
checkForDnfUpdate() {
dnf list updates 2>&1 | grep "^$*" > /dev/null
}
# Gets latest release from DNF
# Inputs: package to check for an update, e.g. "skopeo.x86_64"
# Return: String containing the latest release version, e.g. "0.1.2"
getLatestVersionFromDnf() {
dnf list updates 2> /dev/null | grep "$*" 2> /dev/null | awk '{print $2}' 2> /dev/null
}
# Get the latest release from a GitHub project
# Inputs: owner and repo of the GitHub project to check, e.g. "docker/compose"
# Output: String containing the latest release version, e.g. "0.1.2"
getLatestGitHubRelease() {
curl -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/"$*"/releases" 2> /dev/null | \
jq '.[0].name' 2> /dev/null
}
# Get the latest tag from a GitHub project
# Inputs: owner and repo of the GitHub project to check, e.g. "docker/compose"
# Output: String containing the latest tag version, e.g. "0.1.2"
getLatestGitHubTag() {
curl -H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/"$*"/tags" 2> /dev/null | \
jq '.[0].name' 2> /dev/null
}
# Check pip for an update to the given package
# Inputs: package to check for an update, e.g. "awscli"
# Return: 0 if an update is availabe; non-0 if no update is available
checkForPipUpdate() {
pip list --outdated 2> /dev/null | grep "^$*" > /dev/null
}
# Get latest version of an update from Pip
# Inputs: package to check for an update, e.g. "pipenv"
# Return: String containing the latest version, e.g. "0.1.2"
getLatestVersionFromPip() {
pip list --outdated 2> /dev/null | grep "$*" 2> /dev/null | awk '{print $3}' 2> /dev/null
}
# Get the latest version from asdf
# Input: name of the package, e.g. "terraform"
# Return: String containing the latest version, e.g. "0.1.2"
getLatestVersionFromAsdf() {
asdf latest $* 2> /dev/null
}
# Get the latest version from asdf list
# Some packages are not supported with asdf latest
# Input: name of the package, e.g. "java"
# Return: String containing the latest version, e.g. "0.1.2"
getLatestVersionFromAsdfList() {
asdf list $* 2> /dev/null
}
# Get the latest version from npm
# Inputs: name of the package, e.g. "serverless"
# Return: String containing the latest version, e.g. "0.1.2"
getLatestVersionFromNpm() {
npm show $* version 2> /dev/null
}