forked from mriedmann/humhub-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·50 lines (42 loc) · 1.9 KB
/
update.sh
File metadata and controls
executable file
·50 lines (42 loc) · 1.9 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
#!/usr/bin/env bash
set -xeo pipefail
UPDATE_NEEDED=false
CUR_VERSION=""
NEW_VERSION=""
GIT_BRANCH=""
upstream_versions=$(curl -s https://api.github.com/repos/humhub/humhub/releases | jq -r '.[] | select(.prerelease==false) | .name' | sort --version-sort)
upstream_versions_prerelease=$(curl -s https://api.github.com/repos/humhub/humhub/releases | jq -r '.[] | select(.prerelease==true) | .name' | sort --version-sort)
local_versions=$(cat versions.txt) # to avoid problems when writing doing loop
while IFS= read -r line; do
local_version_prefix=$(echo "$line" | cut -d' ' -f2)
local_version=$(echo "$line" | cut -d' ' -f1)
# If the current local_version contains the word 'beta' we have to consult
# the list of prereleases.
if [[ $local_version =~ "beta" ]]; then
latest_upstream_version=$(echo "$upstream_versions_prerelease" | grep "$local_version_prefix" | tail -n1)
else
latest_upstream_version=$(echo "$upstream_versions" | grep "$local_version_prefix" | tail -n1)
fi
if [ "$local_version" != "$latest_upstream_version" ]; then
echo "$local_version_prefix: UPDATE NEEDED! ($local_version != $latest_upstream_version)"
postfix=${line/$local_version $local_version_prefix/}
sed -i "s/$line/$latest_upstream_version $local_version_prefix$postfix/" versions.txt
CUR_VERSION="$local_version"
NEW_VERSION="$latest_upstream_version"
UPDATE_NEEDED=true
export CUR_VERSION
export NEW_VERSION
export UPDATE_NEEDED
break
else
echo "$local_version_prefix: no update needed ($local_version == $latest_upstream_version)"
fi
done <<< "$local_versions"
if [ $UPDATE_NEEDED = true ]; then
GIT_BRANCH="update-$NEW_VERSION"
export GIT_BRANCH
git branch "$GIT_BRANCH" || true
git checkout "$GIT_BRANCH"
git add versions.txt
git commit -m "update from $CUR_VERSION to $NEW_VERSION"
fi