Automating Package Releases

This is one of these über-geek entry about shell scripting that will only be pertinent to a tiny fraction of this blog’s readership. I just wanted to consign this to the biggest technical library in the world.

Silly as it is, up until recently, I was manually packaging and uploading upgrades for all my WP plugins. Zipping (after removing OS X invisible breadcrumb files if I felt like it), getting my ftp client fired up, browsing to the right location, uploading… The whole process never took more than a minute or so, but was becoming painstakingly repetitive. Especially when you notice you missed a small typo somewhere and have to redo it again 10 seconds later.

I knew there were a thousands way to automate this with a shell script or otherwise, just never bothered… And I probably should have.

This is a typical example of how a small effort could save you a lot of efforts afterward: laziness is a quality in software development, provided it’s used with some foresight.

Anyway, the script turned out to be 4 line long, took 5 minutes to write, and I’m sure it could be of some use for people out there who regularly have to zip and upload a package on a specific website:

cd /path/to/whatever/dir/you/want/to/send/


zip -r your_package/ -x \*/.\*

ftp -u ftp://ftp_username:ftp_password@ftp_server/path/to/destination/ftp/dir/

Replace text in bold with your own values and save as file.
This will work with most Unix shells I can think of, provided you have zip and ftp installed (OS X does, by default).
If you are using OS X, add the .command extension to the script name and you will be able to run it by simply double-clicking it.

Note: don’t forget to make your script executable (run chmod a+x your_script.command).
Note 2: in the script above, mind the space (not a carriage return) between the path and the zip file.


  1. Nice script dave. Nice script.

    I’m not sure about using ftp for upload though. I much prefer scp, and if you use a public/private key pair and something like ssh-agent to manage your pass phrases you get secure upload without leaking your ftp password across the Internet every time you upload.


  2. Westi:
    You are perfectly right, sftp would be better, unfortunately my host doesn’t support it at the moment. That belongs to the long list of things I need to worry about, some day…

    ColdForged: yea. As I said, it really belongs to stupid little things that take 2 minutes and saves hours when you put it together at the end…

Leave a Reply