Skip to content

Commit 23bd09b

Browse files
committed
use pages to host schema
1 parent 39b21b5 commit 23bd09b

3 files changed

Lines changed: 123 additions & 0 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Publish schemas to GitHub Pages
2+
3+
# Triggered when a schema version tag is pushed (pattern: schemas-vX.Y.Z).
4+
# Checks out the repo at that tag, copies the `schemas/` tree into a versioned
5+
# directory on the `gh-pages` branch, and pushes.
6+
#
7+
# `gh-pages` is the source for GitHub Pages (configure once in Settings -> Pages
8+
# after the first run creates the branch).
9+
#
10+
# Each published tag results in a frozen URL such as:
11+
# https://intersectmbo.github.io/governance-actions/v1.0.0/schemas/info/common.jsonld
12+
#
13+
# A `/latest/` mirror is also refreshed on every publish, for human inspection.
14+
# Do NOT reference `/latest/` from on-chain anchored metadata documents — its
15+
# resolved content drifts as new tags are cut. Use a pinned `/v<version>/` URL.
16+
17+
on:
18+
push:
19+
tags:
20+
- 'schemas-v*'
21+
workflow_dispatch:
22+
inputs:
23+
tag:
24+
description: 'Existing schemas-vX.Y.Z tag to (re)publish'
25+
required: true
26+
27+
permissions:
28+
contents: write
29+
30+
concurrency:
31+
group: gh-pages-publish
32+
cancel-in-progress: false
33+
34+
jobs:
35+
publish:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- name: Resolve tag and version
39+
id: ver
40+
run: |
41+
set -euo pipefail
42+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
43+
tag="${{ inputs.tag }}"
44+
else
45+
tag="${GITHUB_REF#refs/tags/}"
46+
fi
47+
# tag = schemas-v1.0.0 -> version = v1.0.0
48+
version="${tag#schemas-}"
49+
if [[ "$version" != v* ]]; then
50+
echo "Tag '$tag' does not match the expected schemas-vX.Y.Z pattern." >&2
51+
exit 1
52+
fi
53+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
54+
echo "version=$version" >> "$GITHUB_OUTPUT"
55+
56+
- name: Checkout source @ tag
57+
uses: actions/checkout@v4
58+
with:
59+
ref: ${{ steps.ver.outputs.tag }}
60+
path: src
61+
62+
- name: Checkout (or initialise) gh-pages
63+
env:
64+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
run: |
66+
set -euo pipefail
67+
repo_url="https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git"
68+
if git ls-remote --exit-code "$repo_url" gh-pages >/dev/null 2>&1; then
69+
git clone --depth 1 --branch gh-pages "$repo_url" site
70+
else
71+
mkdir site
72+
cd site
73+
git init -b gh-pages
74+
git remote add origin "$repo_url"
75+
fi
76+
77+
- name: Copy schemas into /<version>/ and /latest/
78+
run: |
79+
set -euo pipefail
80+
version="${{ steps.ver.outputs.version }}"
81+
rm -rf "site/${version}/schemas" "site/latest/schemas"
82+
mkdir -p "site/${version}" "site/latest"
83+
cp -r src/schemas "site/${version}/schemas"
84+
cp -r src/schemas "site/latest/schemas"
85+
# Disable Jekyll so files (including dot-prefixed ones, if any) are
86+
# served as-is, and so .jsonld files keep their application/ld+json
87+
# MIME type from the GitHub Pages MIME table.
88+
touch site/.nojekyll
89+
90+
- name: Commit and push
91+
working-directory: site
92+
run: |
93+
set -euo pipefail
94+
git config user.name "github-actions[bot]"
95+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
96+
git add -A
97+
if git diff --cached --quiet; then
98+
echo "No changes to publish."
99+
exit 0
100+
fi
101+
git commit -m "publish ${{ steps.ver.outputs.version }} schemas"
102+
git push origin gh-pages

.nojekyll

Whitespace-only changes.

schemas/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,27 @@ By placing the on-chain effect within the body of the action we facilitate autom
1717

1818
This prevents a malicious actor from being able to replay, a legitimate governance action's metadata and just changing the on-chain effect, i.e. just changing a receiving address in a treasury withdrawal.
1919

20+
## Versioning
21+
22+
Each release of these schemas is published to GitHub Pages under a version-pinned URL, so an `@context` reference in a metadata document continues to resolve to the exact bytes that existed at publish time.
23+
24+
Tag a schema release with a tag named `schemas-vX.Y.Z` (semver). Pushing the tag triggers `.github/workflows/publish-schemas-pages.yml`, which copies this `schemas/` tree onto the `gh-pages` branch under `/vX.Y.Z/schemas/...` and refreshes a convenience `/latest/schemas/...` mirror.
25+
26+
The published URL pattern is:
27+
28+
```
29+
https://intersectmbo.github.io/governance-actions/vX.Y.Z/schemas/<type>/common.jsonld
30+
```
31+
32+
When to bump:
33+
34+
| Change | Action |
35+
|---|---|
36+
| New optional field, new gov_action type, new term mapping | Patch / minor bump (additive — does not invalidate previously anchored documents) |
37+
| Required field removed, type narrowed, term renamed, semantics shifted | Major bump (breaking — old docs continue resolving to the previous version) |
38+
39+
`/latest/` is for human inspection only. Anchored governance-metadata documents must reference a pinned `vX.Y.Z` URL — the `@context` URL string is part of the document's hash.
40+
2041
## Navigation
2142

2243
- [Specification](./specification.md)

0 commit comments

Comments
 (0)