Skip to content

Instantly share code, notes, and snippets.

@anmonteiro
Created June 3, 2023 23:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anmonteiro/abd9275456888740758aa9f772d1992a to your computer and use it in GitHub Desktop.
Save anmonteiro/abd9275456888740758aa9f772d1992a to your computer and use it in GitHub Desktop.

Using dune-release to release OCaml packages

Originally written 2020-05-16

dune-release is a good improvement over the old opam-publish, but releasing software is still clearly not a solved problem, and I find it hard to remember the exact steps involved in releasing an opam package, especially if some time has passed since the last release. This note is an attempt at having a place that I can refer to when occasionally releasing my software to opam.

  1. First things first: lint your opam files:
$ dune-release lint
  1. (Optional) Build a distribution archive to check that the project builds (optionally pass -p pkg1,pkg2) to build just a few packages. I've also found --skip-tests useful here for repos that have e.g. submodules.
$ dune-release distrib
  1. Tag a VCS release in your repository:
$ dune-release tag x.y.z
  1. Distribute the release archive and upload it to GitHub (don't forget to point dune-release at your changelog -- I've found the algorithm for finding the changes file is a little clunky):
$ dune-release distrib && dune-release publish distrib --change-log=./CHANGES.md
  1. Package the opam release:
$ dune-release opam pkg -p pkg1,pkg2 --change-log=./CHANGES.md
  1. Submit the release to the opam repository:
$ dune-release opam submit --change-log=./CHANGES.md
@jchavarri
Copy link

Thanks for this guide!

Just a small note: step 5 requires the DUNE_RELEASE_GITHUB_TOKEN env var to be available in the current session, to make it available:

export DUNE_RELEASE_GITHUB_TOKEN="ghp_<your_GitHub_token>"

@davesnx
Copy link

davesnx commented Feb 10, 2024

Found the same issue but didn't had the env var, but the token was stored: ~/.config/dune/github.token change it and run again

@jchavarri
Copy link

jchavarri commented Feb 16, 2024

the only permission needed for the token is just repo -> public_repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment