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.
This commit is contained in:
parent
f6a228e8a7
commit
8af62e17cd
78
script/update-version
Executable file
78
script/update-version
Executable file
@ -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 <<EOM
|
||||
Usage: update-version NEW-VERSION
|
||||
|
||||
NEW-VERSION will have the 'v' automatically stripped.
|
||||
EOM
|
||||
exit
|
||||
fi
|
||||
|
||||
version=$(echo "$version" | sed -e 's/^v//')
|
||||
|
||||
update_go "$version"
|
||||
update_debian "$version"
|
||||
update_rpm "$version"
|
||||
update_versioninfo "$version"
|
||||
}
|
||||
|
||||
main "$@"
|
Loading…
Reference in New Issue
Block a user