File: update-version

package info (click to toggle)
git-lfs 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,808 kB
  • sloc: sh: 21,256; makefile: 507; ruby: 417
file content (78 lines) | stat: -rwxr-xr-x 1,781 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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 "$@"