Automatic releases

brian_d_foy on 2003-01-25T20:08:37

I am working on a (non-technical) project, and although I use all of the trappings of technical projects, including make, CVS, and so on, the other people do not really care about that. They just want to see the results.

Since I have a Makefile, I can easily publish the results.

FILE=foo.txt
USER=joe_user
HOST=foo.example.com
DIR=public_html/project
DEST=${USER}@${HOST}:${DIR}

publish: ${FILE} scp ${FILE} ${DEST} @ touch $@


To send the results to the project web server where everyone can access it, I simply type 'make'.

If I want to automatically publish it, I run make from my crontab. I have not done this sort of thing before, but I figured someone must have thought of doing it before. The trick is to get 'make' to run in the right directory. I can tell it which Makefile to use with -f, but it still needs to be in the right directory. Checking the manual page for 'make' I discover the -C switch.

-C dir
	Change  to directory dir before reading the makefiles
	or doing anything else.  If multiple -C  options  are
	specified, each is interpreted relative to the previ-
	ous one: -C / -C etc is equivalent to -C /etc.   This
	is typically used with recursive invocations of make.


Now I run make from cron every 15 minutes. Since this is make, I only publish the latest stuff if it has changed.

*/15 * * * * make -C ${HOME}/Projects/Foo