Publish Script

I got around to creating a publish script to handle regenerating the static site and publishing to IPFS. Here is the script:

# Build the static site
hugo

# Publish to IPFS
ID=/ipns/$(ipfs id -f="<id>\n")
OLD_HASH=$( ipfs name resolve $ID )
NEW_HASH=/ipfs/$( ipfs add -r public | tail -n1 | cut -d' ' -f2 )
if [[ "$OLD_HASH" != "$NEW_HASH" ]]; then
	ipfs name publish $NEW_HASH && ipfs pin rm $OLD_HASH
fi

Pretty straight forward. Generate the static site, find the old published hash, add the new static site data, publish, and remove the old site data from the pinset to keep the pinset from growing without bound.

Comments