diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 1839d5e0f308094a4ca26d39fe47829510a98284..b95930977455c7ac2502355e00f1e5a773d971f7 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -8,7 +8,7 @@ set -eo # Provide a basic version identifier, particularly since this script # is usually accessed via CDN. -echo "ℹ︎ WP-ORG-PLUGIN-DEPLOY VERSION: 2019041401" +echo "ℹ︎ WP-ORG-PLUGIN-DEPLOY VERSION: 2019041402" if [[ -z "$CI" ]]; then echo "ð˜…︎ Script is only to be run by GitLab CI" 1>&2 @@ -43,14 +43,15 @@ if [[ -z "$WP_ORG_ASSETS_DIR" ]]; then WP_ORG_ASSETS_DIR=".wordpress-org" fi -echo "ℹ︎ PLUGIN_SLUG: $PLUGIN_SLUG" -echo "ℹ︎ PLUGIN_VERSION: $PLUGIN_VERSION" -echo "ℹ︎ WP_ORG_RELEASE_REF: $WP_ORG_RELEASE_REF" -echo "ℹ︎ WP_ORG_ASSETS_DIR: $WP_ORG_ASSETS_DIR" +echo "ℹ︎ PLUGIN_SLUG: ${PLUGIN_SLUG}" +echo "ℹ︎ PLUGIN_VERSION: ${PLUGIN_VERSION}" +echo "ℹ︎ WP_ORG_RELEASE_REF: ${WP_ORG_RELEASE_REF}" +echo "ℹ︎ WP_ORG_ASSETS_DIR: ${WP_ORG_ASSETS_DIR}" SVN_URL="https://plugins.svn.wordpress.org/${PLUGIN_SLUG}/" -SVN_DIR="$CI_BUILDS_DIR/svn-${PLUGIN_SLUG}" -TMP_DIR="$CI_BUILDS_DIR/git-archive" +SVN_DIR="${CI_BUILDS_DIR}/svn-${PLUGIN_SLUG}" +SVN_TAG_DIR="${SVN_DIR}/tags/${PLUGIN_VERSION}" +TMP_DIR="${CI_BUILDS_DIR}/git-archive" # Limit checkouts for efficiency echo "➤ Checking out dotorg repository..." @@ -58,7 +59,7 @@ svn checkout --depth immediates "$SVN_URL" "$SVN_DIR" cd "$SVN_DIR" svn update --set-depth infinity assets svn update --set-depth infinity trunk -svn update --set-depth infinity "tags/${PLUGIN_VERSION}" +svn update --set-depth infinity "$SVN_TAG_DIR" # Ensure we are in the $CI_PROJECT_DIR directory, just in case echo "➤ Copying files..." @@ -68,8 +69,8 @@ git config --global user.email "git-contrib+ci@ethitter.com" git config --global user.name "Erick Hitter (GitLab CI)" # If there's no .gitattributes file, write a default one into place -if [[ ! -e "$CI_PROJECT_DIR/.gitattributes" ]]; then - cat > "$CI_PROJECT_DIR/.gitattributes" <<-EOL +if [[ ! -e "${CI_PROJECT_DIR}/.gitattributes" ]]; then + cat > "${CI_PROJECT_DIR}/.gitattributes" <<-EOL /${WP_ORG_ASSETS_DIR} export-ignore /.gitattributes export-ignore /.gitignore export-ignore @@ -91,6 +92,13 @@ cd "$SVN_DIR" # The --delete flag will delete anything in destination that no longer exists in source rsync -r "$TMP_DIR/" trunk/ --delete +# If tag already exists, update from trunk. +# Generally, this applies when bumping WP version compatibility. +if [[ -d "$SVN_TAG_DIR" ]]; then + echo "➤ Updating existing tag..." + rsync -r trunk/ "$SVN_TAG_DIR" --delete +fi + # Copy dotorg assets to /assets rsync -r "${CI_PROJECT_DIR}/${WP_ORG_ASSETS_DIR}/" assets/ --delete @@ -104,9 +112,11 @@ svn add . --force > /dev/null # Also suppress stdout here svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % > /dev/null -# Copy tag locally to make this a single commit -echo "➤ Copying tag..." -svn cp "trunk" "tags/$PLUGIN_VERSION" +# Copy new tag locally to make this a single commit +if [[ ! -d "$SVN_TAG_DIR" ]]; then + echo "➤ Copying tag..." + svn cp "trunk" "$SVN_TAG_DIR" +fi svn status