docs: GitHub Action up the JSON docs
diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml
index 8e79d08..d707cb5 100644
--- a/.github/workflows/website.yml
+++ b/.github/workflows/website.yml
@@ -12,6 +12,9 @@
     paths:
       - docs/**
   workflow_dispatch:
+  release:
+    types:
+      - published
 
 # This job is copy/paster into wrapdb CI, please update it there when doing any
 # change here.
@@ -40,6 +43,7 @@
           cd docs
           ../meson.py setup _build
           ninja -C _build
+          ninja -C _build test
       - name: Update website
         env:
           SSH_AUTH_SOCK: /tmp/ssh_agent.sock
@@ -47,3 +51,11 @@
           cd docs
           ninja -C _build upload
         if: env.HAS_SSH_KEY == 'true'
+      - name: Release the current JSON docs
+        uses: svenstaro/upload-release-action@v2
+        with:
+          repo_token: ${{ secrets.GITHUB_TOKEN }}
+          file: docs/_build/reference_manual.json
+          tag: ${{ github.ref }}
+        if: ${{ github.event_name == 'release' }}
+
diff --git a/docs/meson.build b/docs/meson.build
index c53abcb..a752965 100644
--- a/docs/meson.build
+++ b/docs/meson.build
@@ -15,27 +15,60 @@
     build_by_default: true,
     install: false)
 
-refman_gen = custom_target(
-    'gen_refman',
+genrefman = find_program('./genrefman.py')
+refman_binary = custom_target(
+    'gen_refman_bin',
     input: files('sitemap.txt'),
-    output: ['configured_sitemap.txt', 'refman_links.json'],
+    output: 'reference_manual.bin',
     depfile: 'reman_dep.d',
     command: [
-        find_program('./genrefman.py'),
+        genrefman,
+        '-l', 'yaml',
+        '-g', 'pickle',
+        '-o', '@OUTPUT@',
+        '--depfile', '@DEPFILE@',
+        '--force-color',
+    ]
+)
+
+refman_md = custom_target(
+    'gen_refman_md',
+    input: refman_binary,
+    output: ['configured_sitemap.txt', 'refman_links.json'],
+    command: [
+        genrefman,
+        '-l', 'pickle',
         '-g', 'md',
-        '-s', '@INPUT@',
+        '-s', files('sitemap.txt'),
+        '-i', '@INPUT@',
         '-o', '@OUTPUT0@',
         '--link-defs', '@OUTPUT1@',
-        '--depfile', '@DEPFILE@',
         '--force-color',
         '--no-modules',
     ],
 )
 
+refman_json = custom_target(
+    'gen_refman_json',
+    build_by_default: true,
+    input: refman_binary,
+    output: 'reference_manual.json',
+    command: [
+        genrefman,
+        '-l', 'pickle',
+        '-g', 'json',
+        '-i', '@INPUT@',
+        '-o', '@OUTPUT@',
+        '--force-color',
+    ],
+)
+
+test('validate_docs', find_program('./jsonvalidator.py'), args: [refman_json])
+
 hotdoc = import('hotdoc')
 documentation = hotdoc.generate_doc(meson.project_name(),
     project_version: meson.project_version(),
-    sitemap: refman_gen[0],
+    sitemap: refman_md[0],
     build_by_default: true,
     depends: docs_gen,
     index: 'markdown/index.md',
@@ -49,7 +82,7 @@
     syntax_highlighting_activate: true,
     keep_markup_in_code_blocks: true,
     extra_extension: meson.current_source_dir() / 'extensions' / 'refman_links.py',
-    refman_data_file: refman_gen[1],
+    refman_data_file: refman_md[1],
 )
 
 run_target('upload',