You are here

release.sh in Lightning Core 8.4

#!/bin/bash

set -e

# Tags and pushes a release to origin and drupal.org.
# Example usage: ./release.sh 2.2.0

DRUPAL_VERSION=8.x-${1%.0}

PROJECT=${PWD##*/}
RELEASE_BRANCH=release/$1

MARKDOWN=`command -v markdown`

# Since this script does things that are pretty permanent, give the user 5
# seconds to cancel without consequences.
echo "Tagging $DRUPAL_VERSION from $RELEASE_BRANCH in 5 seconds..."
sleep 5

# Ensure we are on a mainline release branch.
BRANCH=$(git rev-parse --abbrev-ref HEAD)

if [[ $BRANCH =~ ^8\.x\-[0-9]+\.x$ ]]; then
  git merge --squash $RELEASE_BRANCH
  git commit --all --quiet --message "$1 Release"
  git push --quiet origin
  git push --quiet drupal-org
  echo "Merged $RELEASE_BRANCH and pushed to origin and drupal.org."

  git branch -D $RELEASE_BRANCH
  git push origin :$RELEASE_BRANCH

  git tag $1
  git push --quiet origin $1
  echo "Tagged $1 and pushed to origin."

  git tag $DRUPAL_VERSION
  git push --quiet drupal-org $DRUPAL_VERSION
  echo "Tagged $DRUPAL_VERSION and pushed to drupal.org."

  if [[ $MARKDOWN ]]; then
    markdown logs/$1.md | pbcopy
    echo "The change log has been copied to the clipboard as HTML."
  else
    pbcopy < logs/$1.md
    echo "The change log has been copied to the clipboard as Markdown. You will need to manually convert it to HTML when creating the release."
    echo "If you want to skip this step next time, install markdown-to-html from https://github.com/cwjohan/markdown-to-html."
  fi

  echo "Go ahead and create the release at https://drupal.org/project/$PROJECT"
  exit 0
else
  echo "This can only be done from a mainline release branch, e.g. 8.x-4.x."
  exit 1
fi

File

release.sh
View source
  1. #!/bin/bash
  2. set -e
  3. # Tags and pushes a release to origin and drupal.org.
  4. # Example usage: ./release.sh 2.2.0
  5. DRUPAL_VERSION=8.x-${1%.0}
  6. PROJECT=${PWD##*/}
  7. RELEASE_BRANCH=release/$1
  8. MARKDOWN=`command -v markdown`
  9. # Since this script does things that are pretty permanent, give the user 5
  10. # seconds to cancel without consequences.
  11. echo "Tagging $DRUPAL_VERSION from $RELEASE_BRANCH in 5 seconds..."
  12. sleep 5
  13. # Ensure we are on a mainline release branch.
  14. BRANCH=$(git rev-parse --abbrev-ref HEAD)
  15. if [[ $BRANCH =~ ^8\.x\-[0-9]+\.x$ ]]; then
  16. git merge --squash $RELEASE_BRANCH
  17. git commit --all --quiet --message "$1 Release"
  18. git push --quiet origin
  19. git push --quiet drupal-org
  20. echo "Merged $RELEASE_BRANCH and pushed to origin and drupal.org."
  21. git branch -D $RELEASE_BRANCH
  22. git push origin :$RELEASE_BRANCH
  23. git tag $1
  24. git push --quiet origin $1
  25. echo "Tagged $1 and pushed to origin."
  26. git tag $DRUPAL_VERSION
  27. git push --quiet drupal-org $DRUPAL_VERSION
  28. echo "Tagged $DRUPAL_VERSION and pushed to drupal.org."
  29. if [[ $MARKDOWN ]]; then
  30. markdown logs/$1.md | pbcopy
  31. echo "The change log has been copied to the clipboard as HTML."
  32. else
  33. pbcopy < logs/$1.md
  34. echo "The change log has been copied to the clipboard as Markdown. You will need to manually convert it to HTML when creating the release."
  35. echo "If you want to skip this step next time, install markdown-to-html from https://github.com/cwjohan/markdown-to-html."
  36. fi
  37. echo "Go ahead and create the release at https://drupal.org/project/$PROJECT"
  38. exit 0
  39. else
  40. echo "This can only be done from a mainline release branch, e.g. 8.x-4.x."
  41. exit 1
  42. fi