-
Notifications
You must be signed in to change notification settings - Fork 773
142 lines (118 loc) · 4.08 KB
/
api-docs.yml
File metadata and controls
142 lines (118 loc) · 4.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: Build and publish v2 API docs
on:
push:
branches: [develop]
workflow_dispatch:
inputs:
regenerate-views:
description: Regenerate views.md and view GIF assets
type: boolean
default: true
permissions:
contents: write
id-token: write
pages: write
jobs:
build:
name: Build v2 API docs ${{ github.ref_name }}
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup .NET Core
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.x
dotnet-quality: 'ga'
- name: Detect view docs changes
id: view-docs
shell: pwsh
run: |
$shouldGenerate = $false
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
$shouldGenerate = "${{ inputs.regenerate-views }}" -eq "true"
} else {
$before = "${{ github.event.before }}"
if ($before -match "^0+$") {
$before = "HEAD~1"
}
$changedFiles = git diff --name-only $before "${{ github.sha }}"
$shouldGenerate = [bool]($changedFiles | Where-Object {
$_ -match "^Terminal\.Gui/Views/" -or
$_ -match "^docfx/scripts/OutputView/" -or
$_ -match "^docfx/scripts/generate-views-doc\.ps1$"
} | Select-Object -First 1)
}
"should_generate=$($shouldGenerate.ToString().ToLowerInvariant())" >> $env:GITHUB_OUTPUT
- name: Restore dependencies
run: dotnet restore
- name: Build Terminal.Gui Release
run: dotnet build Terminal.Gui/Terminal.Gui.csproj --configuration Release --no-restore
- name: Build EditorRef (for Terminal.Gui.Editor docs)
run: dotnet build docfx/EditorRef/EditorRef.csproj --configuration Release
- name: Install DocFX
run: |
dotnet tool install -g docfx
- name: Setup Go
if: steps.view-docs.outputs.should_generate == 'true'
uses: actions/setup-go@v6
with:
go-version: stable
- name: Install views docs tools
if: steps.view-docs.outputs.should_generate == 'true'
run: |
go install github.com/gui-cs/tuirec/cmd/tuirec@latest
Add-Content $env:GITHUB_PATH "$(go env GOPATH)\bin"
Install-Module powershell-yaml -Scope CurrentUser -Force
- name: Generate API metadata
working-directory: docfx
run: |
$env:DOCFX_SOURCE_BRANCH_NAME="${{ github.ref_name }}"
docfx metadata
- name: Generate views docs
if: steps.view-docs.outputs.should_generate == 'true'
working-directory: docfx
run: |
./scripts/generate-views-doc.ps1
- name: DocFX Build
working-directory: docfx
run: |
docfx build
continue-on-error: false
- name: Commit regenerated views assets
if: github.event_name == 'workflow_dispatch' && steps.view-docs.outputs.should_generate == 'true'
shell: pwsh
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add docfx/docs/views.md docfx/images/views
if (git diff --cached --quiet) {
Write-Host "No regenerated view assets to commit."
exit 0
}
git commit -m "Regenerate docfx view GIF assets via CI"
git push
- name: Setup Pages
if: github.event_name == 'push' && github.ref_name == 'develop'
uses: actions/configure-pages@v6
- name: Upload artifact
if: github.event_name == 'push' && github.ref_name == 'develop'
uses: actions/upload-pages-artifact@v5
with:
path: docfx/_site
deploy:
name: Deploy v2 API docs to github-pages ${{ github.ref_name }}
if: github.event_name == 'push' && github.ref_name == 'develop'
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: windows-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}