Commit f19724f7 authored by Erick Hitter's avatar Erick Hitter

Merge branch 'fix/tag-updates' into 'master'

Support tag updates

See merge request !8
parents 8a122704 9b992faa
Pipeline #813 passed with stage
in 13 seconds
...@@ -8,7 +8,7 @@ set -eo ...@@ -8,7 +8,7 @@ set -eo
# Provide a basic version identifier, particularly since this script # Provide a basic version identifier, particularly since this script
# is usually accessed via CDN. # is usually accessed via CDN.
echo "ℹ︎ WP-ORG-PLUGIN-DEPLOY VERSION: 2019041401" echo "ℹ︎ WP-ORG-PLUGIN-DEPLOY VERSION: 2019041402"
if [[ -z "$CI" ]]; then if [[ -z "$CI" ]]; then
echo "𝘅︎ Script is only to be run by GitLab CI" 1>&2 echo "𝘅︎ Script is only to be run by GitLab CI" 1>&2
...@@ -43,14 +43,15 @@ if [[ -z "$WP_ORG_ASSETS_DIR" ]]; then ...@@ -43,14 +43,15 @@ if [[ -z "$WP_ORG_ASSETS_DIR" ]]; then
WP_ORG_ASSETS_DIR=".wordpress-org" WP_ORG_ASSETS_DIR=".wordpress-org"
fi fi
echo "ℹ︎ PLUGIN_SLUG: $PLUGIN_SLUG" echo "ℹ︎ PLUGIN_SLUG: ${PLUGIN_SLUG}"
echo "ℹ︎ PLUGIN_VERSION: $PLUGIN_VERSION" echo "ℹ︎ PLUGIN_VERSION: ${PLUGIN_VERSION}"
echo "ℹ︎ WP_ORG_RELEASE_REF: $WP_ORG_RELEASE_REF" echo "ℹ︎ WP_ORG_RELEASE_REF: ${WP_ORG_RELEASE_REF}"
echo "ℹ︎ WP_ORG_ASSETS_DIR: $WP_ORG_ASSETS_DIR" echo "ℹ︎ WP_ORG_ASSETS_DIR: ${WP_ORG_ASSETS_DIR}"
SVN_URL="https://plugins.svn.wordpress.org/${PLUGIN_SLUG}/" SVN_URL="https://plugins.svn.wordpress.org/${PLUGIN_SLUG}/"
SVN_DIR="$CI_BUILDS_DIR/svn-${PLUGIN_SLUG}" SVN_DIR="${CI_BUILDS_DIR}/svn-${PLUGIN_SLUG}"
TMP_DIR="$CI_BUILDS_DIR/git-archive" SVN_TAG_DIR="${SVN_DIR}/tags/${PLUGIN_VERSION}"
TMP_DIR="${CI_BUILDS_DIR}/git-archive"
# Limit checkouts for efficiency # Limit checkouts for efficiency
echo "➤ Checking out dotorg repository..." echo "➤ Checking out dotorg repository..."
...@@ -58,7 +59,7 @@ svn checkout --depth immediates "$SVN_URL" "$SVN_DIR" ...@@ -58,7 +59,7 @@ svn checkout --depth immediates "$SVN_URL" "$SVN_DIR"
cd "$SVN_DIR" cd "$SVN_DIR"
svn update --set-depth infinity assets svn update --set-depth infinity assets
svn update --set-depth infinity trunk 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 # Ensure we are in the $CI_PROJECT_DIR directory, just in case
echo "➤ Copying files..." echo "➤ Copying files..."
...@@ -68,8 +69,8 @@ git config --global user.email "git-contrib+ci@ethitter.com" ...@@ -68,8 +69,8 @@ git config --global user.email "git-contrib+ci@ethitter.com"
git config --global user.name "Erick Hitter (GitLab CI)" git config --global user.name "Erick Hitter (GitLab CI)"
# If there's no .gitattributes file, write a default one into place # If there's no .gitattributes file, write a default one into place
if [[ ! -e "$CI_PROJECT_DIR/.gitattributes" ]]; then if [[ ! -e "${CI_PROJECT_DIR}/.gitattributes" ]]; then
cat > "$CI_PROJECT_DIR/.gitattributes" <<-EOL cat > "${CI_PROJECT_DIR}/.gitattributes" <<-EOL
/${WP_ORG_ASSETS_DIR} export-ignore /${WP_ORG_ASSETS_DIR} export-ignore
/.gitattributes export-ignore /.gitattributes export-ignore
/.gitignore export-ignore /.gitignore export-ignore
...@@ -91,6 +92,13 @@ cd "$SVN_DIR" ...@@ -91,6 +92,13 @@ cd "$SVN_DIR"
# The --delete flag will delete anything in destination that no longer exists in source # The --delete flag will delete anything in destination that no longer exists in source
rsync -r "$TMP_DIR/" trunk/ --delete 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 # Copy dotorg assets to /assets
rsync -r "${CI_PROJECT_DIR}/${WP_ORG_ASSETS_DIR}/" assets/ --delete rsync -r "${CI_PROJECT_DIR}/${WP_ORG_ASSETS_DIR}/" assets/ --delete
...@@ -104,9 +112,11 @@ svn add . --force > /dev/null ...@@ -104,9 +112,11 @@ svn add . --force > /dev/null
# Also suppress stdout here # Also suppress stdout here
svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % > /dev/null svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % > /dev/null
# Copy tag locally to make this a single commit # Copy new tag locally to make this a single commit
echo "➤ Copying tag..." if [[ ! -d "$SVN_TAG_DIR" ]]; then
svn cp "trunk" "tags/$PLUGIN_VERSION" echo "➤ Copying tag..."
svn cp "trunk" "$SVN_TAG_DIR"
fi
svn status svn status
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment