create-release.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. # Setup git
  45. GIT=${GIT:-git}
  46. echo
  47. echo "*****************************************************************"
  48. echo
  49. echo "Hadoop version to create release artifacts: ${HADOOP_VERSION}"
  50. echo
  51. echo "Release Candidate Label: ${RC_LABEL}"
  52. echo
  53. echo "*****************************************************************"
  54. echo
  55. if [[ ! -z ${RC_LABEL} ]]; then
  56. RC_LABEL="-${RC_LABEL}"
  57. fi
  58. # Get Maven command
  59. if [ -z "$MAVEN_HOME" ]; then
  60. MVN=mvn
  61. else
  62. MVN=$MAVEN_HOME/bin/mvn
  63. fi
  64. ARTIFACTS_DIR="target/artifacts"
  65. # git clean to clear any remnants from previous build
  66. run ${GIT} clean -xdf
  67. # mvn clean for sanity
  68. run ${MVN} clean
  69. # Create staging dir for release artifacts
  70. run mkdir -p ${ARTIFACTS_DIR}
  71. # Create RAT report
  72. run ${MVN} apache-rat:check
  73. # Create SRC and BIN tarballs for release,
  74. # Using 'install’ goal instead of 'package' so artifacts are available
  75. # in the Maven local cache for the site generation
  76. run ${MVN} install -Pdist,src,native,yarn-ui -DskipTests -Dtar
  77. # Create site for release
  78. run ${MVN} site site:stage -Pdist -Psrc
  79. run mkdir -p target/staging/hadoop-project/hadoop-project-dist/hadoop-yarn
  80. run mkdir -p target/staging/hadoop-project/hadoop-project-dist/hadoop-mapreduce
  81. run cp ./hadoop-common-project/hadoop-common/src/main/docs/releasenotes.html target/staging/hadoop-project/hadoop-project-dist/hadoop-common/
  82. run cp ./hadoop-common-project/hadoop-common/CHANGES.txt target/staging/hadoop-project/hadoop-project-dist/hadoop-common/
  83. run cp ./hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt target/staging/hadoop-project/hadoop-project-dist/hadoop-hdfs/
  84. run cp ./hadoop-yarn-project/CHANGES.txt target/staging/hadoop-project/hadoop-project-dist/hadoop-yarn/
  85. run cp ./hadoop-mapreduce-project/CHANGES.txt target/staging/hadoop-project/hadoop-project-dist/hadoop-mapreduce/
  86. run mv target/staging/hadoop-project target/r${HADOOP_VERSION}/
  87. run cd target/
  88. run tar czf hadoop-site-${HADOOP_VERSION}.tar.gz r${HADOOP_VERSION}/*
  89. run cd ..
  90. # Stage RAT report
  91. find . -name rat.txt | xargs -I% cat % > ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-rat.txt
  92. # Stage CHANGES.txt files
  93. run cp ./hadoop-common-project/hadoop-common/CHANGES.txt ${ARTIFACTS_DIR}/CHANGES-COMMON-${HADOOP_VERSION}${RC_LABEL}.txt
  94. run cp ./hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt ${ARTIFACTS_DIR}/CHANGES-HDFS-${HADOOP_VERSION}${RC_LABEL}.txt
  95. run cp ./hadoop-mapreduce-project/CHANGES.txt ${ARTIFACTS_DIR}/CHANGES-MAPREDUCE-${HADOOP_VERSION}${RC_LABEL}.txt
  96. run cp ./hadoop-yarn-project/CHANGES.txt ${ARTIFACTS_DIR}/CHANGES-YARN-${HADOOP_VERSION}${RC_LABEL}.txt
  97. # Prepare and stage BIN tarball
  98. run cd hadoop-dist/target/
  99. run tar -xzf hadoop-${HADOOP_VERSION}.tar.gz
  100. run cp -r ../../target/r${HADOOP_VERSION}/* hadoop-${HADOOP_VERSION}/share/doc/hadoop/
  101. run tar -czf hadoop-${HADOOP_VERSION}.tar.gz hadoop-${HADOOP_VERSION}
  102. run cd ../..
  103. run mv hadoop-dist/target/hadoop-${HADOOP_VERSION}.tar.gz ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}.tar.gz
  104. # Stage SRC tarball
  105. run mv hadoop-dist/target/hadoop-${HADOOP_VERSION}-src.tar.gz ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-src.tar.gz
  106. # Stage SITE tarball
  107. run mv target/hadoop-site-${HADOOP_VERSION}.tar.gz ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-site.tar.gz
  108. # MD5 SRC and BIN tarballs
  109. doMD5 ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}.tar.gz
  110. doMD5 ${ARTIFACTS_DIR}/hadoop-${HADOOP_VERSION}${RC_LABEL}-src.tar.gz
  111. run cd ${ARTIFACTS_DIR}
  112. ARTIFACTS_DIR=`pwd`
  113. echo
  114. echo "Congratulations, you have successfully built the release"
  115. echo "artifacts for Apache Hadoop ${HADOOP_VERSION}${RC_LABEL}"
  116. echo
  117. echo "The artifacts for this run are available at ${ARTIFACTS_DIR}:"
  118. run ls -1 ${ARTIFACTS_DIR}
  119. echo
  120. echo "Remember to sign them before staging them on the open"
  121. echo