create-release.sh 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #!/bin/bash
  2. # Licensed to the Apache Software Foundation (ASF) under one or more
  3. # contributor license agreements. See the NOTICE file distributed with
  4. # this work for additional information regarding copyright ownership.
  5. # The ASF licenses this file to You under the Apache License, Version 2.0
  6. # (the "License"); you may not use this file except in compliance with
  7. # the License. You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. # Function to probe the exit code of the script commands,
  17. # and stop in the case of failure with an contextual error
  18. # message.
  19. run() {
  20. echo "\$ ${@}"
  21. "${@}"
  22. exitCode=$?
  23. if [[ $exitCode != 0 ]]; then
  24. echo
  25. echo "Failed! running ${@} in `pwd`"
  26. echo
  27. exit $exitCode
  28. fi
  29. }
  30. doMD5() {
  31. MD5CMD="md5sum"
  32. which $MD5CMD
  33. if [[ $? != 0 ]]; then
  34. MD5CMD="md5"
  35. fi
  36. run $MD5CMD ${1} > ${1}.md5
  37. }
  38. # If provided, the created release artifacts will be tagged with it
  39. # (use RC#, i.e: RC0). Do not use a label to create the final release
  40. # artifact.
  41. RC_LABEL=$1
  42. # Extract Hadoop version from POM
  43. HADOOP_VERSION=`cat pom.xml | grep "<version>" | head -1 | sed 's|^ *<version>||' | sed 's|</version>.*$||'`
  44. echo
  45. echo "*****************************************************************"
  46. echo
  47. echo "Hadoop version to create release artifacts: ${HADOOP_VERSION}"
  48. echo
  49. echo "Release Candidate Label: ${RC_LABEL}"
  50. echo
  51. echo "*****************************************************************"
  52. echo
  53. if [[ ! -z ${RC_LABEL} ]]; then
  54. RC_LABEL="-${RC_LABEL}"
  55. fi
  56. # Get Maven command
  57. if [ -z "$MAVEN_HOME" ]; then
  58. MVN=mvn
  59. else
  60. MVN=$MAVEN_HOME/bin/mvn
  61. fi
  62. ARTIFACTS_DIR="target/artifacts"
  63. # Create staging dir for release artifacts
  64. run mkdir -p ${ARTIFACTS_DIR}
  65. # Create RAT report
  66. run ${MVN} apache-rat:check
  67. # Create SRC and BIN tarballs for release,
  68. # Using 'install’ goal instead of 'package' so artifacts are available
  69. # in the Maven local cache for the site generation
  70. run ${MVN} install -Pdist,docs,src,native -DskipTests -Dtar
  71. # Create site for release
  72. run ${MVN} site site:stage -Pdist -Psrc
  73. run mv target/staging/hadoop-project target/r${HADOOP_VERSION}/
  74. run cd target/
  75. run tar czf hadoop-site-${HADOOP_VERSION}.tar.gz r${HADOOP_VERSION}/*
  76. run cd ..
  77. # Stage RAT report
  78. find . -name rat.txt | xargs -I% cat % > ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-rat.txt
  79. # Stage CHANGES.txt files
  80. run cp ./hadoop-common-project/hadoop-common/CHANGES.txt ${ARTIFACTS_DIR}/CHANGES-COMMON-${HADOOP_VERSION}${RC_LABEL}.txt
  81. run cp ./hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ${ARTIFACTS_DIR}/CHANGES-HDFS--${HADOOP_VERSION}${RC_LABEL}.txt
  82. run cp ./hadoop-mapreduce-project/CHANGES.txt ${ARTIFACTS_DIR}/CHANGES-MAPREDUCE-${HADOOP_VERSION}${RC_LABEL}.txt
  83. run cp ./hadoop-yarn-project/CHANGES.txt ${ARTIFACTS_DIR}/CHANGES-YARN-${HADOOP_VERSION}${RC_LABEL}.txt
  84. # Stage BIN tarball
  85. run mv hadoop-dist/target/hadoop-${HADOOP_VERSION}.tar.gz ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}.tar.gz
  86. # State SRC tarball
  87. run mv hadoop-dist/target/hadoop-${HADOOP_VERSION}-src.tar.gz ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-src.tar.gz
  88. # Stage SITE tarball
  89. run mv target/hadoop-site-${HADOOP_VERSION}.tar.gz ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-site.tar.gz
  90. # MD5 SRC and BIN tarballs
  91. doMD5 ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}.tar.gz
  92. doMD5 ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-src.tar.gz
  93. run cd ${ARTIFACTS_DIR}
  94. ARTIFACTS_DIR=`pwd`
  95. echo
  96. echo "Congratulations, you have successfully built the release"
  97. echo "artifacts for Apache Hadoop ${HADOOP_VERSION}${RC_LABEL}"
  98. echo
  99. echo "The artifacts for this run are available at ${ARTIFACTS_DIR}:"
  100. run ls -1 ${ARTIFACTS_DIR}
  101. echo
  102. echo "Remember to sign them before staging them on the open"
  103. echo