Having just updated all my projects to jbuilder
and topkg
, I’m happy to report that this is a very much worthwhile step to take and encourage everyone to consider doing the same.
My previous approach employed Oasis
and ocamlbuild
. This mostly worked fine, but the development process, e.g. ease of specification and configuration, compilation speed, complexity of the release process, etc., clearly had room for improvement.
Neither topkg
nor jbuilder
initially seemed compelling enough to warrant rewriting my build and packaging process, which I had already mostly automated by shell scripts. But their integration with topkg-jbuilder
provides such strong synergistic effects, it would be hard to argue for any other approach right now.
Among the biggest advantages:
- Considerably improved compilation / package installation speed
- Much lower effort specifying the build process and packages due to elimination of redundancies
- Much shorter and less error-prone release process. Releasing a new package (including API documentation) and upload to GitHub and OPAM, now typically takes me around 2 minutes.
I usually take great care to make my packages as uniform as possible in the way they are structured for building and packaging and have liberally copied the best ideas from other users. Feel free to do the same by using my projects as a template for your own.
Here are the steps I usually take when making a new release:
- Make sure everything is committed and pushed to GitHub, including the definitive version of the
CHANGES.md
file, from which the version information of the release is derived automatically. topkg tag -s
to tag and GPG sign the releasegit push --tags
to push the new tag to GitHubCONDUIT_TLS=native topkg bistro
- See this opam-publish issue whether
CONDUIT_TLS=native
is still necessary. - The above
topkg bistro
command is equivalent to:topkg distrib
builds the distributiontopkg publish
publishes it and its API documentation on GitHub by combining the following sub-commands:topkg publish distrib
topkg publish doc
topkg opam pkg
creates an OPAM packagetopkg opam submit
submits it to the public repository, opening a browser window with the pull request
- See this opam-publish issue whether
make clean
to remove the_build
directory created by the steps above.git checkout gh-pages
for updating theREADME.md
used by GitHub Pages (more fancy looking project page).git pull
in case new API documentation was submitted earlier.sync_github_readme.sh
- this script contains:#!/bin/bash
git show master:README.md > index.md
git commit -m "Synced master README.md to index.md" index.md
git push
in case the last step introduced changes.git checkout master
to switch back to the master branch.
These ten steps are obviously trivial and could in principle be automated further. But I generally prefer some caution before e.g. committing changes or pushing things to remote repositories. Please feel free to suggest further improvements to the packaging approach and release process!
Thanks to Daniel Bünzli and Jeremie Dimino and their contributors for Topkg and Jbuilder!