make_a_release.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/sh -uef
  2. # A small helper script to release mtd-utils. Takes the new version
  3. # as a parameter.
  4. fatal() {
  5. printf "Error: %s\n" "$1" >&2
  6. exit 1
  7. }
  8. usage() {
  9. cat <<EOF
  10. Usage: ${0##*/} <new_ver> <outdir>
  11. <new_ver> - mtd utils version to create in X.Y.Z[-rcX] format
  12. <outdir> - the output directory where to store the tarball with the
  13. gpg signature
  14. EOF
  15. exit 0
  16. }
  17. [ $# -eq 0 ] && usage
  18. [ $# -eq 2 ] || fatal "Insufficient or too many argumetns"
  19. new_ver="$1"; shift
  20. outdir="$1"; shift
  21. release_name="mtd-utils-$new_ver"
  22. tag_name="v$new_ver"
  23. # Make sure the input is sane and the makefile contains sensible version
  24. VER_REGEX="\([0-9]\+.[0-9]\+.[0-9]\+\)\(-rc[0-9]\+\)\?"
  25. echo "$new_ver" | grep -q -x "$VER_REGEX" ||
  26. fatal "please, provide new version in X.Y.Z[-rcX] format"
  27. grep -q -x "m4_define(\[RELEASE\], $VER_REGEX)" configure.ac ||
  28. fatal "configure.ac does not contain a valid version string"
  29. # Make sure the git index is up-to-date
  30. [ -z "$(git status --porcelain)" ] || fatal "Git index is not up-to-date"
  31. # Make sure the tag does not exist
  32. [ -z "$(git tag -l "$tag_name")" ] || fatal "Tag $tag_name already exists"
  33. # Change the version in the configure.ac
  34. sed -i -e "s/^m4_define(\[RELEASE\], $VER_REGEX)/m4_define([RELEASE], $new_ver)/" configure.ac
  35. # And commit the change
  36. git commit -s -m "Release $release_name" configure.ac
  37. # Create new signed tag
  38. echo "Signing tag $tag_name"
  39. git tag -m "$release_name" -s "$tag_name"
  40. # Prepare signed tarball
  41. ./autogen.sh
  42. ./configure --enable-test --enable-unit-tests
  43. make dist-bzip2
  44. mkdir -p "$outdir"
  45. mv "$release_name.tar.bz2" "$outdir"
  46. echo "Signing the tarball"
  47. gpg -o "$outdir/$release_name.tar.bz2.asc" --detach-sign -a "$outdir/$release_name.tar.bz2"
  48. scp_url="casper.infradead.org:/var/ftp/pub/mtd-utils"
  49. ftp_url="ftp://ftp.infradead.org/pub/mtd-utils"
  50. git_url="git://git.infradead.org/mtd-utils.git"
  51. cat <<EOF1
  52. Created $outdir/$release_name.tar.bz2
  53. Please, verify, then push the tag and upload the tarball and the signature
  54. You can use these commands:
  55. ------------------------------------------------------------------------------
  56. git push origin master $tag_name
  57. scp $outdir/$release_name.tar.bz2 $outdir/$release_name.tar.bz2.asc $scp_url
  58. ------------------------------------------------------------------------------
  59. Please, send an announcement, below is the command you may run in your
  60. run. Substitute "me" with your e-mail address if needed, although it is
  61. cleaner to configure 'git send-email' to interpret 'me' as an alias for
  62. your name/email, see 'sendemail.aliasesfile' git configuration option.
  63. ------------------------------------------------------------------------------
  64. mtd_tmpfile=\$(mktemp)
  65. cat > \$mtd_tmpfile <<EOF
  66. Subject: [ANNOUNCE] $release_name is released
  67. Hi,
  68. $release_name is released.
  69. Tarball: $ftp_url/$release_name.tar.bz2
  70. Tarball gpg signature: $ftp_url/$release_name.tar.bz2.asc
  71. Signed git tag: $git_url $tag_name
  72. EOF
  73. git send-email --from me --to 'MTD Mailing List <linux-mtd@lists.infradead.org>' --cc 'Peter Korsgaard (buildroot) <jacmet@sunsite.dk>' --cc 'Josh Boyer (Fedora) <jwboyer@gmail.com>' --cc 'Riku Voipio (Debian) <riku.voipio@linaro.org>' \$mtd_tmpfile
  74. rm \$mtd_tmpfile
  75. ------------------------------------------------------------------------------
  76. EOF1