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/

rm your_package.zip

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

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

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.

Filed under: Geek

4 comments

  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.

    westi

  2. *Sigh*

    I hang my head in shame that I have — like you it seems, until recently — been doing everything by hand. And it is pure laziness. I got about >

  3. 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…

Comments are closed.