Skip to content

Update API Docs

Update API Docs #63

Workflow file for this run

name: Update API Docs
on:
workflow_dispatch:
inputs:
skiasharp-branch:
description: 'SkiaSharp branch to generate docs from'
type: string
default: 'main'
schedule:
- cron: '0 6 * * *' # daily at 6 AM UTC
permissions:
contents: write
pull-requests: write
jobs:
update-docs:
runs-on: windows-latest
steps:
- name: Checkout SkiaSharp
uses: actions/checkout@v4
with:
repository: mono/SkiaSharp
ref: ${{ inputs.skiasharp-branch || 'main' }}
fetch-depth: 1
- name: Checkout docs
uses: actions/checkout@v4
with:
path: docs
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: Install GTK# 2
shell: pwsh
run: |
$msiUrl = "https://github.com/mono/gtk-sharp/releases/download/2.12.45/gtk-sharp-2.12.45.msi"
$msiPath = "$env:RUNNER_TEMP\gtk-sharp.msi"
Invoke-WebRequest -Uri $msiUrl -OutFile $msiPath
Start-Process msiexec.exe -ArgumentList "/i", $msiPath, "/quiet", "/norestart" -Wait -NoNewWindow
- name: Patch missing mdoc assembly search path dependencies
shell: pwsh
run: |
# Fix: Samsung.Tizen.Ref 10.0.109 only has ref/net8.0/ but AddDep now requests net10.0.
# 10.0.122 is the first version with ref/net10.0/. (mono/SkiaSharp#3824)
$versFile = "scripts/VERSIONS.txt"
$content = Get-Content $versFile -Raw
$content = $content -replace 'Samsung\.Tizen\.Ref(\s+release\s+)10\.0\.109', 'Samsung.Tizen.Ref$110.0.122'
if ($content -notmatch 'GirCore\.Gdk-4\.0') {
$content = $content -replace '(AtkSharp\s+release\s+\S+)',
"`$1`nGirCore.Gdk-4.0 release 0.7.0`nGirCore.Gtk-4.0 release 0.7.0"
}
[System.IO.File]::WriteAllText((Resolve-Path $versFile), $content)
# Add GirCore AddDep calls so mdoc can resolve Gdk-4.0 and Gtk-4.0 for SkiaSharp.Views.Gtk4.
$cakeFile = "scripts/cake/UpdateDocs.cake"
$cake = Get-Content $cakeFile -Raw
if ($cake -notmatch 'GirCore\.Gdk-4\.0') {
$cake = $cake -replace '(await AddDep\("Samsung\.Tizen\.Ref", "net10\.0"\);)',
"`$1`n await AddDep(`"GirCore.Gdk-4.0`", `"net10.0`");`n await AddDep(`"GirCore.Gtk-4.0`", `"net10.0`");"
[System.IO.File]::WriteAllText((Resolve-Path $cakeFile), $cake)
}
- name: Restore tools
run: dotnet tool restore
- name: Download latest NuGet packages
run: dotnet cake --target=docs-download-output
- name: Regenerate API docs
run: dotnet cake --target=update-docs
- name: Create pull request
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
run: |
cd docs
git add -A
git diff --cached --quiet
if ($LASTEXITCODE -eq 0) {
Write-Host "No documentation changes detected"
exit 0
}
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -B automation/update-api-docs
git commit -m "Update API docs from latest CI build"
git push origin automation/update-api-docs --force
# Create PR if one doesn't already exist
$existing = gh pr list --head automation/update-api-docs --state open --json number --jq '.[0].number'
if ($existing) {
Write-Host "PR #$existing already exists, force-pushed updates"
} else {
gh pr create --base main --head automation/update-api-docs `
--title "Update API docs from latest CI build" `
--body "Automated update of XML API documentation generated from the latest CI NuGet packages.`n`nThis PR was created by the [Update API Docs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) workflow."
}