1

I have a private theme and I want to deploy new theme versions of it as smoothly as possible.

I've heard about:

  • hosting the theme somewhere like wp-updates.com
  • using plugins to update theme automatically directly from a repository (using plugins like https://github.com/afragen/github-updater or https://wordpress.org/plugins/revisr/)
  • uploading zip archive with a newer version of the theme (it requires activating another theme, deleting previous theme version and uploading a new zip archive with the new theme version).

So I came up with an idea to update theme using each time a zip file with a different name (for example my-awesome-theme-0.1.zip and so on).

Is it a good idea or am I missing something?

4
  • This seems more of a matter of opinion. Are you selling theme to customers? Do you need to verify license keys or anything? There are different ways because there are different priorities.
    – Rarst
    Dec 2, 2015 at 19:39
  • This is just my own theme. So no licences or anything like this :)
    – chestozo
    Dec 2, 2015 at 21:12
  • Do you have direct access to server? Like upload/rename files?
    – Rarst
    Dec 2, 2015 at 22:02
  • Yes ftp / ssh .
    – chestozo
    Dec 2, 2015 at 23:48

2 Answers 2

1

I've been using this approach for private theme updates using versioned archives and it seems to work for me pretty well. No problems found yet. So I guess for private themes - it is a good one.

Also I came up with a script for building versioned theme archive like this:

#!/bin/bash

echo "======================";
echo "BUILDING THEME ARCHIVE";
echo "======================";

# Get version from style.css and CHANGES.md and compare them.
# If they are the same - proceed.

VER_STYLE="$(cat style.css | grep 'Version: ' | perl -pe "s/Version: (.*)\\n/\1/g")"
VER_CHANGES="$(head -n 1 CHANGES.md | xargs | awk '{ print $2 }')"

if [ $VER_STYLE != $VER_CHANGES ]; then
    printf "\e[31;5;21m%s\e[0m\n" "BUILD FAILED"
    echo "Your version in style.css ($VER_STYLE) differs from version in CHANGES.md ($VER_CHANGES).";
    echo "Please actualize.";
    exit 1;
fi

# Theme archive build.
# Also create a new tag for builded version.

build_name="my-theme_$VER_STYLE.zip"

echo "Building $build_name ...";

zip -r -q \
    --exclude=.* \
    --exclude=sass/* \
    --exclude=*/.DS_Store \
    --exclude=*.md \
    --exclude=*.zip \
    --exclude=*.sh \
    $build_name . && git tag $VER_STYLE && git push --tags && printf "\e[32;5;21m%s\e[0m\n" "done" ;

exit 0;
0

With direct access to server typically people just upload/sync file changes on top. However this leaves possibility that someone is visiting the site just as theme is in the process of being updated.

The way to do it with minimum interruption:

  1. Upload new version to a separate directory (e.g. theme-name-update).
  2. Rename old theme directory ( theme-name > theme-name-old).
  3. Rename update directory (theme-name-update > theme-name).

When you do steps 2 & 3 in one CLI command (or have a script for it) that makes the swap extremely fast and unlikely to cause issues.

5
  • Thank you for your answer. But this is actually what I am trying to avoid. Was playing today with this plugin github.com/afragen/github-updater but it feels that it doesn't work properly with bitbucket ... (
    – chestozo
    Dec 3, 2015 at 15:46
  • Well, that's the best way to do it on your own server, so I am not sure what the "avoiding" is trying to prevent. :)
    – Rarst
    Dec 3, 2015 at 15:56
  • What I am avoiding is: - calculating updated files since last update - uploading these files one by one (if they are in different directories let's say). But maybe your magic script does all this manual work. Is it open sourced? :)
    – chestozo
    Dec 3, 2015 at 22:57
  • But you don't need to with this method?.. You just upload whole current version of the theme.
    – Rarst
    Dec 3, 2015 at 23:00
  • There are deployment tools that implement this principle (nothing I use myself since I don't need this degree of speed and stick with version control), but really it's trivial and can be done by hand with as little as your FTP client of choice.
    – Rarst
    Dec 3, 2015 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.