|
1 | 1 | name: update-schema-docs |
2 | 2 |
|
3 | | -# Regenerate bundle/schema/jsonschema_for_docs.json after every release and |
4 | | -# publish it to the `docgen` branch. |
| 3 | +# Regenerate the bundle docs JSON schema after every release and publish it to |
| 4 | +# the `docgen` branch. The docs schema is NOT kept on main — `docgen` is its |
| 5 | +# only home (downstream docs tooling reads it from there). |
5 | 6 | # |
6 | 7 | # bundle/internal/schema/since_version.go derives `x-since-version` annotations |
7 | 8 | # from the list of `v*` git tags that exist when the schema is generated. The |
@@ -68,43 +69,27 @@ jobs: |
68 | 69 | echo "tag=$tag" >> "$GITHUB_OUTPUT" |
69 | 70 | echo "Publishing for tag $tag" |
70 | 71 |
|
71 | | - - name: Regenerate jsonschema_for_docs.json |
72 | | - run: go tool -modfile=tools/task/go.mod task --force generate-schema-docs |
73 | | - |
74 | | - # Fail loudly if regeneration touches anything other than the docs schema. |
75 | | - # Anything else (annotations.yml, untracked files, ...) is a bug in the |
76 | | - # generator, not something we want to silently publish. |
77 | | - - name: Assert only jsonschema_for_docs.json changed on main |
78 | | - run: | |
79 | | - changed=$(git status --porcelain) |
80 | | - expected=" M bundle/schema/jsonschema_for_docs.json" |
81 | | - if [ -z "$changed" ]; then |
82 | | - echo "Regeneration produced no diff against main." |
83 | | - exit 0 |
84 | | - fi |
85 | | - if [ "$changed" != "$expected" ]; then |
86 | | - echo "Expected only bundle/schema/jsonschema_for_docs.json to be modified." |
87 | | - echo "Actual git status --porcelain:" |
88 | | - echo "$changed" |
89 | | - exit 1 |
90 | | - fi |
91 | | -
|
92 | | - - name: Capture regenerated file |
93 | | - run: | |
94 | | - mkdir -p "$RUNNER_TEMP/regen" |
95 | | - cp bundle/schema/jsonschema_for_docs.json "$RUNNER_TEMP/regen/jsonschema_for_docs.json" |
96 | | -
|
97 | 72 | - name: Check out docgen worktree |
98 | 73 | run: | |
99 | 74 | git fetch origin docgen |
100 | 75 | git worktree add "$RUNNER_TEMP/docgen" origin/docgen |
101 | 76 |
|
| 77 | + # The docs schema is not kept on main; generate it straight into the docgen |
| 78 | + # worktree and publish from there. |
| 79 | + - name: Regenerate docs schema into the docgen worktree |
| 80 | + run: | |
| 81 | + # since_version.go reads `git tag --list 'v*'` (and `git show <tag>:...`) |
| 82 | + # to stamp x-since-version. The checkout above already fetches tags |
| 83 | + # (fetch-depth: 0 + fetch-tags: true); fetch them explicitly too so the |
| 84 | + # annotations are never silently dropped if that ever changes. |
| 85 | + git fetch origin 'refs/tags/v*:refs/tags/v*' |
| 86 | + mkdir -p "$RUNNER_TEMP/docgen/bundle/schema" |
| 87 | + go run ./bundle/internal/schema ./bundle/internal/schema \ |
| 88 | + "$RUNNER_TEMP/docgen/bundle/schema/jsonschema_for_docs.json" .codegen/cli.json --docs |
| 89 | +
|
102 | 90 | - name: Stage regenerated file on docgen |
103 | 91 | working-directory: ${{ runner.temp }}/docgen |
104 | | - run: | |
105 | | - mkdir -p bundle/schema |
106 | | - cp "$RUNNER_TEMP/regen/jsonschema_for_docs.json" bundle/schema/jsonschema_for_docs.json |
107 | | - git add bundle/schema/jsonschema_for_docs.json |
| 92 | + run: git add bundle/schema/jsonschema_for_docs.json |
108 | 93 |
|
109 | 94 | - name: Commit and push to docgen |
110 | 95 | working-directory: ${{ runner.temp }}/docgen |
|
0 commit comments