GitHub Action for publishing to opam?

I am trying to automate release process for an opam package

I’m using the setup-ocaml action from my action and then running opam publish from that

But it fails here:

You will be shown the patch before submitting.
Please confirm the above data. Continue ?  [Y/n] n
Error: Process completed with exit code 10.

I’m not sure why n gets auto-filled rather than Y, but the publish tool doesn’t seem to have a no-input option to get round this.

Does anyone have a recipe for this task?

1 Like

so… the base opam cli command has a -y option

but opam -y publish ... still answers n to this prompt :frowning:

Perhaps you will have better luck with https://github.com/ocamllabs/dune-release ? I’ve found it to be quite reliable. Although to be honest I haven’t tried to script it in batch mode.

EDIT: they have --yes: https://github.com/ocamllabs/dune-release/blob/1d8f0edfbefb0be88748759055ea121722da1e71/bin/cli.mli#L72

first impression was that dune-release does too much/too opinionated… I wasn’t super keen to maintain a changelog, though I suppose it would be good practice

dune-release opam submit

[-] Submitting
dune-release: [ERROR] No change log specified in the package description.

I’ll see if I can get this working

I definitely don’t maintain a changelog (in a file, I do treat release tags as changelogs), iirc there’s a way to force it to go ahead without one.

I can’t find anything in dune-release opam submit --help except:

       --change-log=FILE
           The change log to use. If absent, provided by the package
           description.

I can’t see any key for mypackage.opam that looks like a changelog in opam - Manual so I guess it means the description value? not sure what the content needs to look like to be recognised as a changelog though

actually… looking at https://github.com/ocamllabs/dune-release/blob/71bdccf4765939c29cfd85e17df90a87fd1c1182/lib/pkg.ml#L66 it seems by “package description” it really just means “files in the project repo”

In case there is some way via the package description I tried creating a mypackage.opam.template file:

changelog: "n/a"

so that Dune will add this key to the generated .opam file

but when I dune-release distrib I see:

[-] Performing lint for package spectrum in _build/mypackage-8d10ec7
[ OK ] File README is present.
[ OK ] File LICENSE is present.
[FAIL] File CHANGES is missing.
[ OK ] File opam is present.
[FAIL] lint opam file mypackage.opam:
       opam lint -s messages:
       /Users/anentropic/Dev/mypackage/_build/mypackage-8d10ec7/mypackage.opam: Errors.
                    error  3: File format error in 'changelog' at line 39, column 0: Invalid field changelog

and if I then dune-release opam pkg and dune-release opam submit I still get:

[-] Submitting
dune-release: [ERROR] No change log specified in the package description.

Finally I got rid of the opam template and created a dummy CHANGES file that just said “see git commit history”

That linted ok but I got:

dune-release opam submit

[-] Submitting
dune-release: [ERROR] ./CHANGES: Could not parse change log.

So it seems like I have to have a CHANGES file formatted in the way that dune-release expects

Fyi this is what I did https://github.com/yawaramin/ocaml-decimal/blob/main/CHANGES

1 Like

If I remember correctly the changelog file is only checked when --pkg-version and --message are not provided.