Skip to content

Commit

Permalink
ncp-update: fail if version cant be parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Jan 13, 2019
1 parent 96a8021 commit 61e3ff3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
27 changes: 14 additions & 13 deletions bin/ncp-update
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[[ "$BRANCH" != "master" ]] && echo "INFO: updating to development branch '$BRANCH'"

TMPDIR="$( mktemp -d /tmp/ncp-update.XXXXXX || ( echo "Failed to create temp dir. Exiting" >&2; exit 1 ) )"
trap "rm -rf \"${TMPDIR}\"; exit 0" 0 1 2 3 15
trap "cd /; rm -rf \"${TMPDIR}\"; exit 0" 0 1 2 3 15

echo -e "Downloading updates"
git clone --depth 20 -b "$BRANCH" -q https://github.com/nextcloud/nextcloudpi.git "$TMPDIR" || {
Expand All @@ -24,18 +24,19 @@

cd "$TMPDIR"
VER=$( git describe --always --tags | grep -oP "v\d+\.\d+\.\d+" )
grep -qP "v\d+\.\d+\.\d+" <<< "$VER" && { # check format
echo "$VER" > /usr/local/etc/ncp-version
echo "$VER" > /var/run/.ncp-latest-version

# write changelog
git log --graph --oneline --decorate \
--pretty=format:"[%D] %s" --date=short | \
grep 'tag: v' | \
sed '/HEAD ->\|origin/s|\[.*\(tag: v[0-9]\+\.[0-9]\+\.[0-9]\+\).*\]|[\1]|' | \
sed 's|* \[tag: |[|' > /usr/local/etc/ncp-changelog
}
cd /

# check format
grep -qP "v\d+\.\d+\.\d+" <<< "$VER" || { "Error: missing version"; exit 1; }

echo "$VER" > /usr/local/etc/ncp-version
echo "$VER" > /var/run/.ncp-latest-version

# write changelog
git log --graph --oneline --decorate \
--pretty=format:"[%D] %s" --date=short | \
grep 'tag: v' | \
sed '/HEAD ->\|origin/s|\[.*\(tag: v[0-9]\+\.[0-9]\+\.[0-9]\+\).*\]|[\1]|' | \
sed 's|* \[tag: |[|' > /usr/local/etc/ncp-changelog

echo -e "NextCloudPi updated to version $VER"
exit 0
Expand Down
6 changes: 4 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

[v1.3.0](https://github.com/nextcloud/nextcloudpi/commit/8a49536) (2019-01-12) upgrade to NC15.0.2
[v1.3.1](https://github.com/nextcloud/nextcloudpi/commit/bb69e8d) (2019-01-13) ncp-update: fail if version cant be parsed

[v1.2.0](https://github.com/nextcloud/nextcloudpi/commit/9eaab31) (2019-01-08) add NCP Nextcloud app
[v1.3.0 ](https://github.com/nextcloud/nextcloudpi/commit/2c943b7) (2019-01-12) upgrade to NC15.0.2

[v1.2.0 ](https://github.com/nextcloud/nextcloudpi/commit/9eaab31) (2019-01-08) add NCP Nextcloud app

[v1.1.3 ](https://github.com/nextcloud/nextcloudpi/commit/d21592c) (2019-01-11) nc-update-nextcloud: only try to restore on reboot once

Expand Down

0 comments on commit 61e3ff3

Please sign in to comment.