deploy-dotorg.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. # Make sure SVN credentials and project slug are set
  3. if [[ -z "$SVN_USERNAME" ]]; then
  4. echo "Set the SVN_USERNAME secret"
  5. exit 1
  6. fi
  7. if [[ -z "$SVN_PASSWORD" ]]; then
  8. echo "Set the SVN_PASSWORD secret"
  9. exit 1
  10. fi
  11. rm -rf ./deploy
  12. # Look into all the themes we expect to deploy
  13. declare -a THEMES_TO_DEPLOY=(
  14. "blockbase"
  15. "zoologist"
  16. "geologist"
  17. "mayland-blocks"
  18. "quadrat"
  19. "skatepark"
  20. "seedlet-blocks"
  21. )
  22. for THEME_SLUG in ${THEMES_TO_DEPLOY[@]} ; do
  23. THEME_VERSION=$(cat ./${THEME_SLUG}/style.css \
  24. | grep Version \
  25. | head -1 \
  26. | awk -F: '{ print $2 }' \
  27. | sed 's/[",]//g' \
  28. | sed 's/-wpcom//g' \
  29. | tr -d '[[:space:]]')
  30. # TODO: This does take into account the -wpcom appended to some theme versions.
  31. # Ideally that can be removed from all of the themes versioning in this repository.
  32. # I'm not convinced it's helpful...
  33. printf "\n\nAttempting to deploy theme ${THEME_SLUG} version ${THEME_VERSION}\n"
  34. SVN_URL="https://themes.svn.wordpress.org/${THEME_SLUG}/"
  35. SVN_DIR="$PWD/deploy/${THEME_SLUG}"
  36. svn checkout --depth immediates "$SVN_URL" "$SVN_DIR" --no-auth-cache --non-interactive > /dev/null
  37. if [ ! -d "$SVN_DIR" ]; then
  38. echo "No theme by that slug to be checked out. Probably not a theme. Moving on."
  39. continue;
  40. fi
  41. if [ -d "$SVN_DIR/$THEME_VERSION" ]; then
  42. rm -rf $SVN_DIR
  43. echo "Release already exists. Moving on."
  44. continue;
  45. fi
  46. echo "➤ Copying theme '${THEME_SLUG}' version '${THEME_VERSION}' to svn repository... "
  47. rsync -rc --include=theme.json --exclude-from './dotorg-exclude.txt' ./$THEME_SLUG/ $SVN_DIR/$THEME_VERSION
  48. # Remove -wpcom from versoning
  49. find $SVN_DIR/$THEME_VERSION/style.css -type f -exec sed -i '' 's/-wpcom//g' {} \;
  50. # Remove the wpcom-specific tags used in some themes
  51. find $SVN_DIR/$THEME_VERSION/style.css -type f -exec sed -i '' 's/, auto-loading-homepage//g' {} \;
  52. find $SVN_DIR/$THEME_VERSION/style.css -type f -exec sed -i '' 's/, jetpack-global-styles//g' {} \;
  53. # Add the version to SVN
  54. svn add $SVN_DIR --force > /dev/null
  55. echo "➤ Committing files..."
  56. svn commit $SVN_DIR -m "Update to version ${THEME_VERSION} from GitHub" --no-auth-cache --non-interactive --username ${SVN_USERNAME} --password ${SVN_PASSWORD}
  57. done