I think Twitter is a nice way to keep people up to date with your software projects. It’s a nice, easy way to send out an executive summary of what is happening in real time.
Following in that vein we decided to do a tweet for each build we do for FarCry Core. Since I am lazy, I decided to find a way to make it automated. The solution we started using is a combination of cURL and Ant.
We initially tried to use the <post> ant task, but that turned out to be more complicated and error prone than just calling cURL via the <exec> task.
Since I develop on OS X, the first pass is Unixy and should work perfectly on Linux. However, our build servers are currently Windows so I had to do a bit of porting to get it to work on Windows. I’ll reiterate my usual complaint here: Windows needs a real shell cmd.exe is an abomination (powershell is from mars and unusable unless you want to only understand some random MS product) – include bash, it’s not hard. Diatribe aside, my main point being that this process should work on Mac, Linux, and Windows.
For the people who don’t care how it works, but just want to use it, you can download a working example here. If you know how to use Ant, it should be quite obvious how it works.
For those who do care about the under-workings, the main work horse for this came from a modified version of code found on this post on Linux Journal. The script is an abstraction layer just above cURL which is a swiss army knife of network tinkering (leaving out netcat of course).
Curl comes pre-installed on most modern OSs, and windows users can download the exe from that above link. The “tweet” shell script should work find on Mac OS X and Linux (you might need to chmod u+x), and the tweet.bat is the windows equivalent.
(Compare tweet to tweet.bat to see why cmd.exe is horrible. Also, The windows version is limited to a tweet of 27 words.)
The Ant task just calls whichever tweet script you specify, and you’re off.
I should note the example download also includes the windows exe of cURL to make it easier for tinkering. I only making it available as is with no warranty of any kind. You might want to download your own version, and possibly get the SSH enabled one.
If you are not a fan of Ant, but instead prefer make or a custom shell script, you can follow the instructions in the tweet shell script to make the script callable anywhere on the system.
Happy Build Tweeting.