Skip to content

Commit 8f0b649

Browse files
Copilotpetesramek
andauthored
fix: make publish-documentation generate versioned API docs correctly for v1.0 release
- Add workflow-level env dotnet-sdk-version: '10.x' - Fix versioning job output bug: steps.versioning.outputs.friendly-version was always empty because the extract-version action outputs 'version', not 'friendly-version' - Rewrite generate-docs job: - Run 'docfx metadata' to regenerate fresh API YAML for the current version - Discover all version dirs in api-reference/ to support future multi-version builds - Patch api-reference.json with content section + group for each version (dynamically) - Patch versions.json with the discovered versions list and latest - Patch toc.yml with a Reference dropdown listing all versions (newest first) - Inline docfx build (removed docfx-build action call which would overwrite changes) - Fix docfx-build action: - Remove internal checkout step (caller's responsibility, would overwrite changes) - Fix dotnet setup to use inputs.dotnet_sdk_version instead of env.dotnet-sdk-version Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/2dc77f60-d041-415f-ba0b-e00c9f76ff58 Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com>
1 parent ca8ea2c commit 8f0b649

2 files changed

Lines changed: 78 additions & 9 deletions

File tree

.github/actions/documentation/docfx-build/action.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ inputs:
2121
runs:
2222
using: composite
2323
steps:
24-
- name: 'Checkout ${{ github.head_ref || github.ref }}'
25-
uses: actions/checkout@v6
2624
- name: Dotnet Setup
2725
uses: actions/setup-dotnet@v4
2826
with:
29-
dotnet-version: ${{ env.dotnet-sdk-version }}
27+
dotnet-version: ${{ inputs.dotnet_sdk_version }}
3028
- name: 'testing variables'
3129
shell: bash
3230
run: |

.github/workflows/publish-documentation.yml

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ concurrency:
1818
group: publish-docs-${{ github.head_ref || github.ref }}
1919
cancel-in-progress: true
2020

21+
env:
22+
dotnet-sdk-version: '10.x'
23+
2124
jobs:
2225
validate-branch:
2326
name: 'Validate branch'
@@ -49,7 +52,7 @@ jobs:
4952
needs: [workflow-variables]
5053
runs-on: ubuntu-latest
5154
outputs:
52-
friendly-version: ${{ steps.versioning.outputs.friendly-version }}
55+
friendly-version: ${{ steps.versioning.outputs.version }}
5356

5457
steps:
5558
- name: 'Checkout ${{ github.head_ref || github.ref }}'
@@ -76,12 +79,80 @@ jobs:
7679
- name: 'Checkout ${{ github.head_ref || github.ref }}'
7780
uses: actions/checkout@v6
7881

79-
- name: 'Generate documentation'
80-
uses: ./.github/actions/documentation/docfx-build
82+
- name: 'Setup .NET ${{ env.dotnet-sdk-version }}'
83+
uses: actions/setup-dotnet@v5
8184
with:
82-
artifact-name: 'documentation'
83-
docfx-json-manifest: './api-reference/api-reference.json'
84-
output-directory: './api-reference/_docs'
85+
dotnet-version: ${{ env.dotnet-sdk-version }}
86+
87+
- name: 'Install docfx'
88+
shell: bash
89+
run: dotnet tool update -g docfx
90+
91+
- name: 'Regenerate API metadata for v${{ env.friendly-version }}'
92+
shell: bash
93+
run: |
94+
rm -rf api-reference/${{ env.friendly-version }}
95+
cd api-reference
96+
docfx metadata assembly-metadata.json
97+
mv temp ${{ env.friendly-version }}
98+
99+
- name: 'Discover all versions'
100+
id: discover-versions
101+
shell: bash
102+
run: |
103+
versions=$(ls api-reference/ | grep -E '^\d+\.\d+$' | sort -V | paste -sd ',' -)
104+
latest=$(ls api-reference/ | grep -E '^\d+\.\d+$' | sort -V | tail -1)
105+
echo "versions=$versions" >> $GITHUB_OUTPUT
106+
echo "latest=$latest" >> $GITHUB_OUTPUT
107+
108+
- name: 'Update versions.json'
109+
shell: bash
110+
run: |
111+
versions_array=$(echo "${{ steps.discover-versions.outputs.versions }}" | tr ',' '\n' | jq -R . | jq -s .)
112+
jq --arg latest "${{ steps.discover-versions.outputs.latest }}" \
113+
--argjson versions "$versions_array" \
114+
'.latest = $latest | .versions = $versions' \
115+
api-reference/versions.json > /tmp/versions.json
116+
mv /tmp/versions.json api-reference/versions.json
117+
118+
- name: 'Update api-reference.json with version groups'
119+
shell: bash
120+
run: |
121+
cp api-reference/api-reference.json /tmp/api-reference.json
122+
for ver in $(echo "${{ steps.discover-versions.outputs.versions }}" | tr ',' ' '); do
123+
jq --arg ver "$ver" --arg group "v${ver}" \
124+
'.build.content += [{"dest": "", "files": ["*.yml"], "group": $group, "src": $ver, "rootTocPath": "~/toc.html"}] |
125+
.build.groups = (.build.groups // {}) |
126+
.build.groups[$group] = {"dest": $ver}' \
127+
/tmp/api-reference.json > /tmp/api-reference-new.json
128+
mv /tmp/api-reference-new.json /tmp/api-reference.json
129+
done
130+
mv /tmp/api-reference.json api-reference/api-reference.json
131+
132+
- name: 'Update toc.yml with Reference dropdown'
133+
shell: bash
134+
run: |
135+
latest="${{ steps.discover-versions.outputs.latest }}"
136+
{
137+
echo "### YamlMime:TableOfContent"
138+
echo "- name: Guide"
139+
echo " href: guide/"
140+
echo "- name: Reference"
141+
echo " dropdown: true"
142+
echo " items:"
143+
for ver in $(echo "${{ steps.discover-versions.outputs.versions }}" | tr ',' '\n' | sort -Vr); do
144+
if [ "$ver" = "$latest" ]; then
145+
echo " - name: v${ver} (latest)"
146+
else
147+
echo " - name: v${ver}"
148+
fi
149+
echo " href: ${ver}/PolylineAlgorithm.html"
150+
done
151+
} > api-reference/toc.yml
152+
153+
- name: 'Build documentation'
154+
shell: bash
155+
run: docfx build api-reference/api-reference.json
85156

86157
- name: 'Upload artifact'
87158
uses: actions/upload-pages-artifact@v4

0 commit comments

Comments
 (0)