release 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #!/usr/bin/env bash
  2. set -o errexit
  3. set -o nounset
  4. set -o pipefail
  5. help() {
  6. echo "$(basename $0) [version]"
  7. echo "Release etcd using the same approach as the etcd-release-runbook (https://goo.gl/Gxwysq)"
  8. echo ""
  9. echo "WARNING: This does not perform the 'Add API capabilities', 'Performance testing' "
  10. echo " or 'Documentation' steps. These steps must be performed manually BEFORE running this tool."
  11. echo ""
  12. echo "WARNING: This script does not sign releases, publish releases to github or sent announcement"
  13. echo " emails. These steps must be performed manually AFTER running this tool."
  14. echo ""
  15. echo " args:"
  16. echo " version: version of etcd to release, e.g. '3.2.18'"
  17. }
  18. main() {
  19. VERSION=$1
  20. if [[ ! "${VERSION}" =~ [0-9]+.[0-9]+.[0-9]+ ]]; then
  21. echo "Expected 'version' param of the form '<major-version>.<minor-version>.<patch-version>' but got '${VERSION}'"
  22. exit 1
  23. fi
  24. RELEASE_VERSION="v${VERSION}"
  25. MINOR_VERSION=$(echo "${VERSION}" | cut -d. -f 1-2)
  26. BRANCH="release-${MINOR_VERSION}"
  27. # Check go version.
  28. local go_version="go$(yq -r ".go[0]" .travis.yml)"
  29. local current_go_version=$(go version | awk '{ print $3 }')
  30. if [[ "${current_go_version}" != "${go_version}" ]]; then
  31. echo "Current go version is ${current_go_version}, but etcd ${RELEASE_VERSION} requires ${go_version} (see .travis.yml)."
  32. exit 1
  33. fi
  34. # Make a temp directory
  35. cd $(mktemp -d)
  36. git clone git@github.com:coreos/etcd.git --branch "${BRANCH}"
  37. cd etcd
  38. KEYID=$(gpg --list-keys --with-colons| awk -F: '/^pub:/ { print $5 }')
  39. if [[ -z "${KEYID}" ]]; then
  40. echo "Failed to load gpg key. Is gpg set up correctly for etcd releases?"
  41. exit 1
  42. fi
  43. # Bump version/version.go to release version.
  44. local source_version=$(egrep "\s+Version\s*=" version/version.go | sed -e "s/.*\"\(.*\)\".*/\1/g")
  45. if [[ "${source_version}" != "${VERSION}" ]]; then
  46. source_minor_version=$(echo "${source_version}" | cut -d. -f 1-2)
  47. if [[ "${source_minor_version}" != "${MINOR_VERSION}" ]]; then
  48. echo "Wrong etcd minor version in version/version.go. Expected ${MINOR_VERSION} but got ${source_minor_version}. Aborting."
  49. exit 1
  50. fi
  51. echo "Updating version from ${source_version} to ${VERSION} in version/version.go"
  52. sed -i.bak "s/${source_version}/${VERSION}/g" version/version.go
  53. echo "Building etcd with updated version"
  54. ./build
  55. fi
  56. local etcd_version=$(bin/etcd --version | grep "etcd Version" | awk '{ print $3 }')
  57. if [[ "${etcd_version}" != "${VERSION}" ]]; then
  58. echo "Wrong etcd version in version/version.go. Expected ${etcd_version} but got ${VERSION}. Aborting."
  59. exit 1
  60. fi
  61. git add version/version.go
  62. git commit -m "version: bump up to ${VERSION}"
  63. git diff --staged
  64. read -p "Push version bump up to ${VERSION} to github.com/coreos/etcd [y/N]? " confirm
  65. [[ "${confirm,,}" == "y" ]] || exit 1
  66. git push
  67. echo "Tagging release..."
  68. git tag --local-user "${KEYID}" --sign "${RELEASE_VERSION}" --message "${RELEASE_VERSION}"
  69. git tag --list | grep "{VERSION}"
  70. read -p "Push etcd ${RELEASE_VERSION} tag [y/N]? " confirm
  71. [[ "${confirm,,}" == "y" ]] || exit 1
  72. git push origin "tags/${RELEASE_VERSION}"
  73. echo "Building release..."
  74. ./scripts/release.sh "${RELEASE_VERSION}"
  75. # TODO: validate output of checks
  76. ./release/etcd-${RELEASE_VERSION}-linux-amd64/etcd --version
  77. ETCDCTL_API=3 ./release/etcd-${RELEASE_VERSION}-linux-amd64/etcdctl version
  78. read -p "Upload etcd ${RELEASE_VERSION} release artifacts to gs://etcd [y/N]? " confirm
  79. [[ "${confirm,,}" == "y" ]] || exit 1
  80. gsutil -m cp ./release/*.zip gs://etcd/${RELEASE_VERSION}/
  81. gsutil -m cp ./release/*.tar.gz gs://etcd/${RELEASE_VERSION}/
  82. gsutil -m cp ./release/*.aci gs://etcd/${RELEASE_VERSION}/
  83. gsutil -m acl ch -u allUsers:R -r gs://etcd/${RELEASE_VERSION}/
  84. read -p "Publish etcd ${RELEASE_VERSION} docker images to quay.io [y/N]? " confirm
  85. [[ "${confirm,,}" == "y" ]] || exit 1
  86. docker login quay.io
  87. gcloud docker -- login -u _json_key -p "$(cat /etc/gcp-key-etcd-development.json)" https://gcr.io
  88. for TARGET_ARCH in "-arm64" "-ppc64le" ""; do
  89. docker push quay.io/coreos/etcd:${RELEASE_VERSION}${TARGET_ARCH}
  90. gcloud docker -- push gcr.io/etcd-development/etcd:${RELEASE_VERSION}${TARGET_ARCH}
  91. done
  92. gsutil -m acl ch -u allUsers:R -r gs://artifacts.etcd-development.appspot.com
  93. docker tag quay.io/coreos/etcd:${RELEASE_VERSION} quay.io/coreos/etcd:${MINOR_VERSION}
  94. docker push quay.io/coreos/etcd:${MINOR_VERSION}
  95. gcloud docker -- tag gcr.io/etcd-development/etcd:${RELEASE_VERSION} gcr.io/etcd-development/etcd:${MINOR_VERSION}
  96. gcloud docker -- push gcr.io/etcd-development/etcd:${MINOR_VERSION}
  97. # TODO: test
  98. # docker run --rm --name etcd-gcr-${RELEASE_VERSION} gcr.io/etcd-development/etcd:${RELEASE_VERSION};
  99. # docker exec etcd-gcr-${RELEASE_VERSION} /bin/sh -c "/usr/local/bin/etcd --version"
  100. # docker exec etcd-gcr-${RELEASE_VERSION} /bin/sh -c "ETCDCTL_API=3 /usr/local/bin/etcdctl version"
  101. # docker exec etcd-gcr-${RELEASE_VERSION} /bin/sh -c "ETCDCTL_API=3 /usr/local/bin/etcdctl put foo bar"
  102. # docker exec etcd-gcr-${RELEASE_VERSION} /bin/sh -c "ETCDCTL_API=3 /usr/local/bin/etcdctl get foo"
  103. echo "Updating version from ${VERSION} to ${VERSION}+git in version/version.go"
  104. sed -i.bak "s/${VERSION}/${VERSION}+git/g" version/version.go
  105. echo "Building etcd with ${VERSION}+git in version/version.go"
  106. git add version/version.go
  107. git commit -m "version: bump up to ${VERSION}+git"
  108. git diff --staged
  109. read -p "Push version bump up to ${VERSION}+git to github.com/coreos/etcd [y/N]? " confirm
  110. [[ "${confirm,,}" == "y" ]] || exit 1
  111. git push
  112. # TODO: signing process
  113. echo "WARNING: The release has not been signed and published to github. This must be done manually."
  114. echo "WARNING: version/version.go has not been updated to ${RELEASE_VERSION}+git. This must be done manually."
  115. echo "Success."
  116. exit 0
  117. }
  118. POSITIONAL=()
  119. while test $# -gt 0; do
  120. case "$1" in
  121. -h|--help)
  122. shift
  123. help
  124. exit 0
  125. ;;
  126. *)
  127. POSITIONAL+=("$1") # save it in an array for later
  128. shift # past argument
  129. ;;
  130. esac
  131. done
  132. set -- "${POSITIONAL[@]}" # restore positional parameters
  133. if [[ ! $# -eq 1 ]]; then
  134. help
  135. exit 1
  136. fi
  137. main $1