RELEASE.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #! /bin/sh
  2. #
  3. # Release script for Calamares
  4. #
  5. # This attempts to perform the different steps of the RELEASE.md
  6. # document automatically. It's not tested on other machines or
  7. # setups other than [ade]'s development VM.
  8. #
  9. # Assumes that the version in CMakeLists.txt has been bumped,
  10. # and that a release of that version is desired.
  11. #
  12. # None of the "update stuff" is done by this script; in preparation
  13. # for the release, you should have already done:
  14. # - updating the version
  15. # - pulling translations
  16. # - updating the language list
  17. # - switching to the right branch
  18. #
  19. # You can influence the script a little with environment variables:
  20. # - BUILD_DEFAULT set to false to avoid first build with gcc
  21. # - BUILD_CLANG set to false to avoid second build with clang
  22. # - BUILD_ONLY set to true to break after building
  23. test -d .git || { echo "Not at top-level." ; exit 1 ; }
  24. test -d src/modules || { echo "No src/modules." ; exit 1 ; }
  25. which cmake > /dev/null 2>&1 || { echo "No cmake(1) available." ; exit 1 ; }
  26. test -z "$BUILD_DEFAULT" && BUILD_DEFAULT=true
  27. test -z "$BUILD_CLANG" && BUILD_CLANG=true
  28. test -z "$BUILD_ONLY" && BUILD_ONLY=false
  29. ### Setup
  30. #
  31. #
  32. BUILDDIR=$(mktemp -d --suffix=-build --tmpdir=.)
  33. ### Build with default compiler
  34. #
  35. #
  36. if test "x$BUILD_DEFAULT" = "xtrue" ; then
  37. rm -rf "$BUILDDIR"
  38. mkdir "$BUILDDIR" || { echo "Could not create build directory." ; exit 1 ; }
  39. ( cd "$BUILDDIR" && cmake .. && make -j4 ) || { echo "Could not perform test-build in $BUILDDIR." ; exit 1 ; }
  40. ( cd "$BUILDDIR" && make test ) || { echo "Tests failed in $BUILDDIR." ; exit 1 ; }
  41. fi
  42. ### Build with clang
  43. #
  44. #
  45. if test "x$BUILD_CLANG" = "xtrue" ; then
  46. if which clang++ > /dev/null 2>&1 ; then
  47. # Do build again with clang
  48. rm -rf "$BUILDDIR"
  49. mkdir "$BUILDDIR" || { echo "Could not create build directory." ; exit 1 ; }
  50. ( cd "$BUILDDIR" && CC=clang CXX=clang++ cmake .. && make -j4 ) || { echo "Could not perform test-build in $BUILDDIR." ; exit 1 ; }
  51. ( cd "$BUILDDIR" && make test ) || { echo "Tests failed in $BUILDDIR." ; exit 1 ; }
  52. fi
  53. fi
  54. if test "x$BUILD_ONLY" = "xtrue" ; then
  55. echo "Builds completed, release stopped. Build remains in $BUILDDIR."
  56. exit 1
  57. fi
  58. ### Get version number for this release
  59. #
  60. #
  61. V=$( cd "$BUILDDIR" && make show-version | grep ^CALAMARES_VERSION | sed s/^[A-Z_]*=// )
  62. test -n "$V" || { echo "Could not obtain version." ; exit 1 ; }
  63. ### Create signed tag
  64. #
  65. # This is the signing key ID associated with the GitHub account adriaandegroot,
  66. # which is used to create all "verified" tags in the Calamares repo.
  67. KEY_ID="128F00873E05AF1D"
  68. git tag -u "$KEY_ID" -m "Release v$V" "v$V" || { echo "Could not sign tag v$V." ; exit 1 ; }
  69. ### Create the tarball
  70. #
  71. #
  72. TAR_V="calamares-$V"
  73. TAR_FILE="$TAR_V.tar.gz"
  74. git archive -o "$TAR_FILE" --prefix "$TAR_V/" "v$V" || { echo "Could not create tarball." ; exit 1 ; }
  75. test -f "$TAR_FILE" || { echo "Tarball was not created." ; exit 1 ; }
  76. SHA256=$(sha256sum "$TAR_FILE" | cut -d" " -f1)
  77. ### Build the tarball
  78. #
  79. #
  80. D=$(date +%Y%m%d-%H%M%S)
  81. TMPDIR=$(mktemp -d --suffix="-calamares-$D")
  82. test -d "$TMPDIR" || { echo "Could not create tarball-build directory." ; exit 1 ; }
  83. tar xzf "$TAR_FILE" -C "$TMPDIR" || { echo "Could not unpack tarball." ; exit 1 ; }
  84. test -d "$TMPDIR/$TAR_V" || { echo "Tarball did not contain source directory." ; exit 1 ; }
  85. ( cd "$TMPDIR/$TAR_V" && cmake . && make -j4 && make test ) || { echo "Tarball build failed." ; exit 1 ; }
  86. ### Cleanup
  87. #
  88. rm -rf "$BUILDDIR" # From test-builds
  89. rm -rf "$TMPDIR" # From tarball
  90. ### Print subsequent instructions
  91. #
  92. #
  93. cat <<EOF
  94. # Next steps for this release:
  95. git push --tags
  96. gpg -s -u $KEY_ID --detach --armor $TAR_FILE # Sign the tarball
  97. # Upload tarball $TAR_FILE and the signature $TAR_FILE.asc
  98. # Announce via https://github.com/calamares/calamares/releases/new
  99. # SHA256: $SHA256
  100. EOF
  101. exit 0