From 8af62e17cda696b69e9353d62a17908085f9c7c4 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Mon, 24 Sep 2018 17:43:52 +0000 Subject: [PATCH] script: add a script to update version numbers The current release process is mostly manual. To improve automation, add a script that updates all the various places we store the version number in preparation for release. Make the script idempotent. In order to generate a changelog entry for the Debian changelog, use the current user's committer identity and a timestamp similar to those already used. Specify a time zone of -0000, as that means that the timestamp is in UTC, but unlike +0000, doesn't imply that we ourselves are in that timezone. --- script/update-version | 78 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 script/update-version diff --git a/script/update-version b/script/update-version new file mode 100755 index 00000000..1b76c576 --- /dev/null +++ b/script/update-version @@ -0,0 +1,78 @@ +#!/bin/sh -e + +rfc822_datestamp () { + # All the other changelog entries use this exact timestamp, so let's do so as + # well. Use -0000 to indicate that our timestamp is in UTC, even though we + # ourselves may not be. + LC_ALL=C date +'%a, %d %b %Y 14:29:00 -0000' +} + +user_id () { + git var GIT_COMMITTER_IDENT | sed -e 's/^\(.*<[^>]*>\).*$/\1/' +} + +update_go () { + local version="$1" + + sed -i '' -e "s/\(Version = \)\"[0-9.]*\"/\\1\"$version\"/" config/version.go +} + +update_debian () { + local version="$1" + + # Return if already updated. + ! grep -qs -F "git-lfs ($version)" debian/changelog || return + + local tmpdir=$(mktemp -d) + local tmpfile="$tmpdir/changelog" + + printf 'git-lfs (%s) stable; urgency=low + + * New upstream version + + -- %s %s\n\n' "$version" "$(user_id)" "$(rfc822_datestamp)" >"$tmpfile" + + cat debian/changelog >>"$tmpfile" + mv "$tmpfile" debian/changelog +} + +update_rpm () { + local version="$1" + + ruby -pi -e "\$_.gsub!(/^(Version:\\s+)[0-9.]+$/, '\\1$version')" \ + rpm/SPECS/git-lfs.spec +} + +update_versioninfo () { + local version="$1" + + ruby -pi -e "ver = '$version'; pieces = ver.split('.')" \ + -e '$_.gsub!(/("Major": )\d+/, %Q(\\1#{pieces[0]}))' \ + -e '$_.gsub!(/("Minor": )\d+/, %Q(\\1#{pieces[1]}))' \ + -e '$_.gsub!(/("Patch": )\d+/, %Q(\\1#{pieces[2]}))' \ + -e '$_.gsub!(/("ProductVersion": )"[\d.]+"/, %Q(\\1"#{ver}"))' \ + versioninfo.json +} + +main () { + local version="$1" + + if [ -z "$version" ] || [ "$version" = "--help" ] + then + cat <