-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtesting.sh
More file actions
111 lines (87 loc) · 2.25 KB
/
Copy pathtesting.sh
File metadata and controls
111 lines (87 loc) · 2.25 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env bash
# Usage: ./bump_version.sh <major|minor|patch> - Increments the relevant version part by one.
#
# Usage 2: ./bump_version.sh <version-from> <version-to>
# e.g: ./bump_version.sh 1.1.1 2.0
set -e
current_version=$(grep -E '\* Version:\s[^\s]+(.*)' secured-wp.php | awk '{ print $3 }')
echo $current_version
sed -ri "s/@since latest/@since $current_version/g" *.php
exit
# Define which files to update and the pattern to look for
# $1 Current version
# $2 New version
# function bump_files() {
# bump testing.php "\"@since\": \"latest\"" "\"@since\": \"$2\""
# #bump README.md "my-plugin v$current_version" "my-plugin v$new_version"
# }
# function bump() {
# echo -n "Updating $1..."
# tmp_file=$(mktemp)
# rm -f "$tmp_file"
# sed -i "s/$2/$3/1w $tmp_file" $1
# if [ -s "$tmp_file" ]; then
# echo "Done"
# else
# echo "Nothing to change"
# fi
# rm -f "$tmp_file"
# }
# function confirm() {
# read -r -p "$@ [Y/n]: " confirm
# case "$confirm" in
# [Nn][Oo]|[Nn])
# echo "Aborting."
# exit
# ;;
# esac
# }
# if [ "$1" == "" ]; then
# echo >&2 "No 'from' version set. Aborting."
# exit 1
# fi
current_version=$(grep '* Version:\s[^\s]' secured-wp.php)
echo
echo `grep -o '* Version:\s[^\s]' secured-wp.php`
exit
if [ "$1" == "latest" ] || [ "$1" == "minor" ] || [ "$1" == "patch" ]; then
current_version=$(grep '* Version:\s[^\s]' secured-wp.php)
echo
echo $current_version
exit
IFS='.' read -a version_parts <<< "$current_version"
major=${version_parts[0]}
minor=${version_parts[1]}
patch=${version_parts[2]}
case "$1" in
"major")
major=$((major + 1))
minor=0
patch=0
;;
"minor")
minor=$((minor + 1))
patch=0
;;
"patch")
patch=$((patch + 1))
;;
esac
new_version="$major.$minor.$patch"
echo
echo $new_version
exit
else
if [ "$2" == "" ]; then
echo >&2 "No 'to' version set. Aborting."
exit 1
fi
current_version="$1"
new_version="$2"
fi
if ! [[ "$new_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo >&2 "'to' version doesn't look like a valid semver version tag (e.g: 1.2.3). Aborting."
exit 1
fi
# confirm "Bump version number from $current_version to $new_version?"
# bump_files "$current_version" "$new_version"