Generating Artifact.toml hashes

Hi there,

I’m in the process of making my package relocatable, and the first steps for that are to create my shared libraries (actually, just library wrappers of C++ libraries) as artifacts. However, I’m finding the documentation to be quite light here! (ie.

I need to annotate the Artifacts.toml file with a ‘git-tree-sha1’ hash, as well as a SHA256 hash for the downloaded file itself.

So what I’ve done:

  1. compiled the library
  2. gzipped it (not documented, but appears that gz or some other compression is required)
  3. uploaded online
  4. used SHA256sum to calculate the hash of the gz file
  5. used git hash-object to calculate the hash of the un-gzipped file
  6. And entered these into the Artifacts.toml file

The SHA256 is correct, and the file is downloaded and un-gzipped. However the git-tree-sha1 hash fails - which is what I expected because I have no idea what a git-tree-sha1 is, and the phrase only appears online in relation to the Julia Pkg system itself!

So what is this second hash, and how do I generate it? And am I doing this correctly - or is there an automagic way I should be artifacting these libraries?

You can compute the git tree hash with Pkg.GitTools.tree_hash. You can see artifacts documentation about how to automatically generate an Artifacts.toml file.

Since you want to distribute a shared library, have you considered using BinaryBuilder.jl instead? If you need some inspiration, there are hundreds of recipes already available in Yggdrasil


Thank you, I didn’t realise that the documentation there was to build the artifacts file (I thought it was to use it).

I would say that it should be clearer that artifacts must be tar archives.

You can open a pull request to clarify this point and avoid confusion to the next user :wink:

1 Like