2021-11-10 17:50:35 +00:00
#!/bin/bash
# Make sure SVN credentials and project slug are set
2022-01-18 16:32:26 +00:00
if [ [ -z " $SVN_USERNAME " ] ] && [ [ $1 != "preview" ] ] ; then
2021-11-10 17:50:35 +00:00
echo "Set the SVN_USERNAME secret"
exit 1
fi
2022-01-18 16:32:26 +00:00
if [ [ -z " $SVN_PASSWORD " ] ] && [ [ $1 != "preview" ] ] ; then
2021-11-10 17:50:35 +00:00
echo "Set the SVN_PASSWORD secret"
exit 1
fi
rm -rf ./deploy
# Look into all the themes we expect to deploy
declare -a THEMES_TO_DEPLOY = (
2023-04-27 07:54:08 +00:00
"adventurer"
2022-03-23 16:43:45 +00:00
"archeo"
2023-03-20 05:55:13 +00:00
"bibimbap"
2023-04-27 07:54:08 +00:00
"bitacora"
2022-05-05 08:31:53 +00:00
"blockbase"
2023-07-07 10:28:51 +00:00
"course"
2023-04-27 07:54:08 +00:00
"ctlg"
2022-08-22 20:45:49 +00:00
"disco"
2021-11-10 17:50:35 +00:00
"geologist"
2023-07-07 09:59:45 +00:00
"george-lois"
2023-05-01 10:44:40 +00:00
"hey"
2023-01-20 02:19:27 +00:00
"lettre"
2023-08-18 10:02:59 +00:00
"lineup"
2022-05-05 08:31:53 +00:00
"livro"
2021-11-10 17:50:35 +00:00
"mayland-blocks"
2023-04-27 07:54:08 +00:00
"paimio"
2022-05-05 08:31:53 +00:00
"pendant"
2022-09-27 08:44:58 +00:00
"pixl"
2023-07-07 09:59:45 +00:00
"poema"
2021-11-10 17:50:35 +00:00
"quadrat"
2022-10-04 15:33:35 +00:00
"rainfall"
2022-04-13 07:22:05 +00:00
"remote"
2022-01-31 16:22:59 +00:00
"seedlet-blocks"
2022-03-07 11:10:04 +00:00
"skatepark"
"stewart"
2023-05-01 10:44:40 +00:00
"storia"
2023-01-30 17:19:35 +00:00
"upsidedown"
2022-07-18 18:04:13 +00:00
"vivre"
2022-05-05 08:31:53 +00:00
"zoologist"
2021-11-10 17:50:35 +00:00
)
for THEME_SLUG in ${ THEMES_TO_DEPLOY [@] } ; do
THEME_VERSION = $( cat ./${ THEME_SLUG } /style.css \
| grep Version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g' \
| sed 's/-wpcom//g' \
| tr -d '[[:space:]]' )
# TODO: This does take into account the -wpcom appended to some theme versions.
# Ideally that can be removed from all of the themes versioning in this repository.
# I'm not convinced it's helpful...
printf " \n\nAttempting to deploy theme ${ THEME_SLUG } version ${ THEME_VERSION } \n "
SVN_URL = " https://themes.svn.wordpress.org/ ${ THEME_SLUG } / "
SVN_DIR = " $PWD /deploy/ ${ THEME_SLUG } "
svn checkout --depth immediates " $SVN_URL " " $SVN_DIR " --no-auth-cache --non-interactive > /dev/null
if [ ! -d " $SVN_DIR " ] ; then
echo "No theme by that slug to be checked out. Probably not a theme. Moving on."
continue ;
fi
if [ -d " $SVN_DIR / $THEME_VERSION " ] ; then
rm -rf $SVN_DIR
echo "Release already exists. Moving on."
continue ;
fi
2022-01-18 16:32:26 +00:00
directories = ( $SVN_DIR /*)
last_directory = ${ directories [ ${# directories [@] } -1] }
echo " ➤ Copying previous version of theme ' ${ THEME_SLUG } ' to svn repository... "
svn update --set-depth infinity ${ last_directory } --non-interactive
svn cp ${ last_directory } $SVN_DIR /$THEME_VERSION
2021-11-10 17:50:35 +00:00
echo " ➤ Copying theme ' ${ THEME_SLUG } ' version ' ${ THEME_VERSION } ' to svn repository... "
2022-01-18 16:32:26 +00:00
rsync -rc --delete --include= theme.json --exclude-from './dotorg-exclude.txt' ./$THEME_SLUG / $SVN_DIR /$THEME_VERSION
2021-11-10 17:50:35 +00:00
# Remove the wpcom-specific tags used in some themes
find $SVN_DIR /$THEME_VERSION /style.css -type f -exec sed -i '' 's/, auto-loading-homepage//g' { } \;
2022-01-18 16:32:26 +00:00
# Remove files from the previous version
svn status $SVN_DIR /$THEME_VERSION | grep "^\!" | sed 's/^\! *//g' | xargs svn rm;
2021-11-10 17:50:35 +00:00
# Add the version to SVN
2022-01-18 16:32:26 +00:00
svn add $SVN_DIR /$THEME_VERSION --force --depth infinity -q > /dev/null
2021-11-10 17:50:35 +00:00
2022-01-18 16:32:26 +00:00
if [ [ $1 = = "preview" ] ] ; then
svn status $SVN_DIR
else
echo "➤ Committing files..."
2022-10-25 13:54:00 +00:00
svn commit $SVN_DIR -m " Update to version ${ THEME_VERSION } from GitHub " --no-auth-cache --non-interactive --username ${ SVN_USERNAME } --password ${ SVN_PASSWORD } 2>& 1 | grep 'svn: E'
if [ [ $? -eq 0 ] ] ; then
echo 'Commit failed.'
exit 1
fi
2022-01-18 16:32:26 +00:00
fi
2022-08-22 20:45:49 +00:00
done