makefile to just

converting this site's Makefile to `just` | back

i recently discovered the lovely little just command runner. it's lovely. for an explanation of why it's lovely, see its readme.

as for why i love it: it replaces make.

make is a very poweful, useful tool. it is also incredibly messy and i by definition use it wrong, since most of my usage of make is as less a build tool and more a general-purpose command runner, which is something it is not designed to do. it works, but lacks a lot of quality of life features which just provides, such as the ability to list recipes from the command line.

converting this site

this was the old Makefile:

site.tar.gz: public
	tar -C public -cvz . > site.tar.gz

public: clean
	zola build

upload: site.tar.gz
	curl --oauth2-bearer $$(bat ~/.srht-token) \
	    -Fcontent=@site.tar.gz https://pages.sr.ht/publish/alterae.srht.site

clean:
	rm -rf public site.tar.gz

serve: clean
	zola serve --interface 0.0.0.0 --base-url $$(hostname -f)

it has some issues, including the fact that it was written before i knew what phonies were.

this is the new justfile:

# Build the site.
build: clean
    zola build

# Compress the built site into a tarball for uploading.
tarball: build
    tar -C public -cvz . > site.tar.gz

# Publish the site to `alterae.srht.site`.
publish: tarball
    @# not very secure, requires that i remember to keep the token file in my 
    @# home dir
    curl \
        --oauth2-bearer $(cat ~/.srht-token) \
        -Fcontent=@site.tar.gz https://pages.sr.ht/publish/alterae.srht.site

# Remove all build artifacts.
clean:
    -rm -rf public site.tar.gz

# Build the site in watch mode and serve it at `hostname:1111.
serve: clean
    zola serve --interface 0.0.0.0 --base-url $(hostname -f)

admittedly the difference is mostly in the names of the recipes, but that alone is an improvement. one of the big features just doesn't have is conditional running based on whether or not files have changed. honestly, that's not something i miss or need much, and here is not really an exception. additionally, without it, we don't need .PHONY targets everywhere.

what we lose in file-update checking, we gain in ease-of-use. running just --list displays all the available recipes, using the comments as documentation.

the transition was really easy, though i should really move the token into a .env file in the project directory at some point.

TL;DR

this site had a Makefile. now it has a justfile instead.