Skip to content

Instantly share code, notes, and snippets.

@mkllnk
Created June 16, 2019 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkllnk/f1ef628271d002044d0bab98b0a04592 to your computer and use it in GitHub Desktop.
Save mkllnk/f1ef628271d002044d0bab98b0a04592 to your computer and use it in GitHub Desktop.
Script to update the version within several files of the Git-ftp project
#!/bin/sh
set -ex
test -w git-ftp
test -w tests/git-ftp-test.sh
test "$(git status -uno --porcelain | wc -l)" -eq 0
current="$(grep "\<VERSION='.*'" git-ftp | cut -d "'" -f2)"
test -n "$1"
newvers="$1"
if [ "$2" = "-u" ]; then
newvers="$newvers-UNRELEASED"
fi
sed -i "s/\<VERSION='.*'/VERSION='$newvers'/" git-ftp tests/git-ftp-test.sh
# Regular expression for a version number
verx='[0-9]\+\.[0-9]\+\.[0-9]\+\(-UNRELEASED\)\?'
datex='[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}'
sed -i "s/^% GIT-FTP(1) Git-ftp $verx\$/% GIT-FTP(1) Git-ftp $newvers/" man/git-ftp.1.md
sed -i "s/^% $datex$/% $(date -u '+%Y-%m-%d')/" man/git-ftp.1.md
git commit -a -m "Version $newvers"
set +x
echo "!!! TODO: change changelog file:"
echo "
Version $newvers
=============
"
last_released="$(git tag | tail -1)"
git log "$last_released..." --merges --pretty=format:"* %b"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment