Add script to rebase libsyncthing against latest Syncthing release

This commit is contained in:
Martchus 2019-09-20 18:12:44 +02:00
parent fa328f440e
commit d9cf64fd91
1 changed files with 44 additions and 0 deletions

44
libsyncthing/update.sh Executable file
View File

@ -0,0 +1,44 @@
#!/bin/bash
set -e
shopt -s nocasematch
shopt -s nullglob
libsyncthingdir=$(dirname "$0")
syncthingrepodir=$libsyncthingdir/go/src/github.com/syncthing/syncthing
special_release_regex='rc|beta|debian'
latest_tag=
echo '==> Updating Syncthing repo'
git -C "$syncthingrepodir" remote update
echo '==> Getting latest tag/release'
for tag in $(git -C "$syncthingrepodir" tag -l --sort=-version:refname 'v*'); do
if [[ $tag =~ $special_release_regex ]]; then
continue
fi
if [[ $tag ]]; then
latest_tag=$tag
break
fi
done
if [[ -z $latest_tag ]]; then
echo 'Unable to find latest release tag'
exit -1
fi
echo "Latest Syncthing release: $latest_tag"
echo '==> Updating CMakeLists.txt'
sed -i -e "s|^\(set(META_SYNCTHING_VERSION \"\(.*\)\")\).*$|set(META_SYNCTHING_VERSION \"$latest_tag\")|" "$libsyncthingdir/CMakeLists.txt"
echo '==> Rebasing libsyncthing'
if git -C "$syncthingrepodir" rev-parse --verify "libsyncthing-$latest_tag" > /dev/null; then
echo "Nothing to do: A libsyncthing branch \"libsyncthing-$latest_tag\" for the latest release already exists."
exit 0
fi
git -C "$syncthingrepodir" checkout libsyncthing-latest
git -C "$syncthingrepodir" rebase "$latest_tag"
git -C "$syncthingrepodir" branch "libsyncthing-$latest_tag"
echo '==> Pushing updated/new libsyncthing branches to GitHub'
git -C "$syncthingrepodir" push -fu martchus libsyncthing-latest:libsyncthing-latest
git -C "$syncthingrepodir" push -u martchus "libsyncthing-$latest_tag:libsyncthing-$latest_tag"