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.mdfile, from which the version information of the release is derived automatically. topkg tag -sto tag and GPG sign the releasegit push --tagsto push the new tag to GitHubCONDUIT_TLS=native topkg bistro- See this opam-publish issue whether
CONDUIT_TLS=nativeis still necessary. - The above
topkg bistrocommand is equivalent to:topkg distribbuilds the distributiontopkg publishpublishes it and its API documentation on GitHub by combining the following sub-commands:topkg publish distribtopkg publish doc
topkg opam pkgcreates an OPAM packagetopkg opam submitsubmits it to the public repository, opening a browser window with the pull request
- See this opam-publish issue whether
make cleanto remove the_builddirectory created by the steps above.git checkout gh-pagesfor updating theREADME.mdused by GitHub Pages (more fancy looking project page).git pullin case new API documentation was submitted earlier.sync_github_readme.sh- this script contains:#!/bin/bashgit show master:README.md > index.md
git commit -m "Synced master README.md to index.md" index.mdgit pushin case the last step introduced changes.git checkout masterto 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!