forked from IgniteUI/igniteui-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
344 lines (297 loc) · 14.8 KB
/
Copy pathbuild-docs-en.yml
File metadata and controls
344 lines (297 loc) · 14.8 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
name: angular-docs-en
# Equivalent to Azure DevOps CI trigger: refs/tags/*
on:
push:
tags:
- '*'
# Allows manual runs with optional isLatest override (equivalent to ADO queue-time variable)
workflow_dispatch:
inputs:
isLatest:
description: 'Override isLatest flag (leave empty to auto-detect)'
required: false
default: ''
skipDeployment:
description: 'Skip deployment (for testing only)'
required: false
type: boolean
default: false
jobs:
build-docs:
runs-on: ubuntu-latest
outputs:
productionDeployment: ${{ steps.check-deployment.outputs.productionDeployment }}
runDeployment: ${{ steps.set-deploy-flag.outputs.runDeployment }}
steps:
# -----------------------------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v4
with:
# Full history needed for git ls-remote tag sorting and git describe
fetch-depth: 0
# -----------------------------------------------------------------------
# Resolve whether deployment should run.
# On a tag push, inputs is empty so skipDeployment is '' — deploy runs.
# On workflow_dispatch, deploy runs unless skipDeployment checkbox is checked.
- name: Set deployment flag
id: set-deploy-flag
shell: pwsh
run: |
$skip = '${{ inputs.skipDeployment }}' -eq 'true'
$run = if ($skip) { 'false' } else { 'true' }
Write-Host "runDeployment: $run"
echo "runDeployment=$run" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
# -----------------------------------------------------------------------
# Equivalent to: NodeTool@0 — Use Node 20.19.x
- name: Use Node 20.19.x
uses: actions/setup-node@v4
with:
node-version: '20.19.x'
# -----------------------------------------------------------------------
# Generate a build version once, before NuGet pack steps.
# ADO used build.buildnumber (e.g. "AngularDocs_20240101.1") and split on '_'.
# GitHub Actions equivalent uses a date + run_number format.
- name: Set BuildVersion
shell: pwsh
run: |
$buildDate = Get-Date -Format "yyyyMMdd"
$version = "$buildDate.${{ github.run_number }}"
Write-Host "BuildVersion: $version"
echo "BuildVersion=$version" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# -----------------------------------------------------------------------
# Equivalent to: DeleteFiles@1 — Delete *.nupkg and dist
- name: Delete files (*.nupkg, dist)
shell: pwsh
run: |
Get-ChildItem -Path '${{ github.workspace }}' -Filter '*.nupkg' -File |
Remove-Item -Force -ErrorAction SilentlyContinue
if (Test-Path '${{ github.workspace }}/dist') {
Remove-Item '${{ github.workspace }}/dist' -Recurse -Force
}
# -----------------------------------------------------------------------
# Equivalent to: 'Extract the tag from repo' powershell step.
# When triggered by a tag push, github.ref_name already contains the tag name,
# so git describe is not needed.
- name: Extract the tag from repo
shell: pwsh
run: |
$fullTag = '${{ github.ref_name }}'
$split = $fullTag -split '-'
$tag = $split[0]
Write-Host "curTag: $tag"
Write-Host "fullTag: $fullTag"
echo "curTag=$tag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "fullTag=$fullTag" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# -----------------------------------------------------------------------
# Equivalent to: 'Set the isLatest flag based on current tag version'
# condition: eq(variables['isLatest'], '') → only runs when not already set.
# The workflow_dispatch input lets you override isLatest at queue time (same as ADO).
- name: Propagate manual isLatest override
if: github.event_name == 'workflow_dispatch' && inputs.isLatest != ''
shell: pwsh
run: |
echo "isLatest=${{ inputs.isLatest }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Set the isLatest flag based on current tag version
if: env.isLatest == ''
shell: pwsh
run: |
git ls-remote --tags --sort=-v:refname origin | Out-File currentBranch.txt -Encoding utf8
$content = [System.IO.File]::ReadAllLines('currentBranch.txt')
# Each line is: "<sha>\trefs/tags/<tag>" — take the ref part and strip the prefix
$latestTagRef = ($content[0] -split '\s+')[1] # refs/tags/18.5.0
Write-Host "latestTagRef: $latestTagRef"
$currentTag = "$env:curTag"
$fullTagText = "$env:fullTag"
Write-Host "currentTag: $currentTag"
Write-Host "fullTagText: $fullTagText"
###STAGING isLatest###
$latestStaging = $latestTagRef -like "*$currentTag*"
Write-Host "latestTagRef -like *currentTag*: $latestStaging"
Write-Host "isLatest staging value: $latestStaging"
echo "isLatest=$latestStaging" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
###PRODUCTION isLatest###
$isOfficialTag = -not ($fullTagText -like "*-*")
$indexOfCurrentTag = -1
for ($i = 0; $i -lt $content.Length; $i++) {
$lineRef = ($content[$i] -split '\s+')[1]
Write-Host "refs/tags/ $lineRef"
if ($lineRef -and $lineRef.TrimEnd() -eq "refs/tags/$fullTagText") {
$indexOfCurrentTag = $i
break
}
}
$allTagsBeta = $false
Write-Host "indexOfCurrentTag: $indexOfCurrentTag"
Write-Host "full tag: $fullTagText"
Write-Host "isOfficialTag: $isOfficialTag"
if ($indexOfCurrentTag -ge 1) {
$allT = $true
for ($j = $indexOfCurrentTag - 1; $j -ge 0; $j--) {
$allT = $allT -and ($content[$j] -like '*-*')
}
$allTagsBeta = $allT
}
Write-Host "allTagsBeta: $allTagsBeta"
$latestProd = ($latestStaging -or $allTagsBeta) -and $isOfficialTag
Write-Host "isLatest prod value: $latestProd"
echo "isLatestProd=$latestProd" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# -----------------------------------------------------------------------
# Equivalent to: 'Get the MajorMinor from the tag'
- name: Get the MajorMinor from the tag
shell: pwsh
run: |
$tag = "$env:curTag".TrimStart('v')
Write-Host "Tag version is $tag"
$split = $tag.split('.')
$num = $split[0] + '.' + $split[1]
Write-Host "Num is $num"
[double]$d = [double]::Parse($num)
echo "MajorMinor=$d" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# -----------------------------------------------------------------------
# Equivalent to: DutchWorkzToolsAllVariables@1 — show all build variables
- name: Show all build variables
shell: pwsh
run: |
Write-Host '=== Environment Variables ==='
Get-ChildItem Env: | Sort-Object Name | Format-Table Name, Value -AutoSize
# -----------------------------------------------------------------------
# Equivalent to: Npm@1 — npm cache clean --force
- name: npm cache clean --force
run: npm cache clean --force
working-directory: ${{ github.workspace }}
# Equivalent to: Npm@1 — npm ci
- name: npm ci
run: npm ci --force
working-directory: ${{ github.workspace }}
# Equivalent to: Npm@1 — npm run build:lib
- name: npm run build:lib
run: npm run build:lib
working-directory: ${{ github.workspace }}
# -----------------------------------------------------------------------
# ---- STAGING DOCS BUILD ---------------------------------------------
# -----------------------------------------------------------------------
# Equivalent to: Npm@1 — npm run build:typedoc:en:staging
- name: npm run build:typedoc (staging)
run: npm run build:typedoc:en:staging
working-directory: ${{ github.workspace }}
# Equivalent to: Npm@1 — npm run build:sassdoc:en:staging
- name: npm run build:sassdoc (staging)
run: npm run build:sassdoc:en:staging
working-directory: ${{ github.workspace }}
# Equivalent to: CopyFiles@2 — Copy angularDocsPostDeploy.ps1 to dist
- name: Copy angularDocsPostDeploy.ps1 to dist (staging)
shell: pwsh
run: |
$targetDir = '${{ github.workspace }}/dist/igniteui-angular/docs'
New-Item -ItemType Directory -Force -Path $targetDir | Out-Null
Copy-Item -Path '${{ github.workspace }}/angularDocsPostDeploy.ps1' -Destination $targetDir -Force
# Equivalent to: powershell — Update PostDeploy.ps1 vars (staging)
- name: Update PostDeploy.ps1 vars (staging)
shell: pwsh
run: |
$filePath = '${{ github.workspace }}/dist/igniteui-angular/docs/angularDocsPostDeploy.ps1'
((Get-Content -Path $filePath -Raw) -replace 'VariableValue', "$env:curTag") |
Set-Content -Path $filePath
((Get-Content -Path $filePath -Raw) -replace 'VariableIsLatest', "$env:isLatest") |
Set-Content -Path $filePath
# Equivalent to: script — rename angularDocsPostDeploy.ps1 PostDeploy.ps1
- name: Rename PostDeploy.ps1 (staging)
shell: pwsh
run: |
Rename-Item -Path '${{ github.workspace }}/dist/igniteui-angular/docs/angularDocsPostDeploy.ps1' `
-NewName 'PostDeploy.ps1'
# Upload the staging docs as a workflow artifact for the deploy job
- name: Upload staging artifact
uses: actions/upload-artifact@v4
with:
name: angularDocsEN-staging
path: dist/igniteui-angular/docs/
# -----------------------------------------------------------------------
# ---- PRODUCTION DOCS BUILD ------------------------------------------
# -----------------------------------------------------------------------
# Equivalent to: Npm@1 — npm run build:typedoc:en:production
- name: npm run build:typedoc (production)
run: npm run build:typedoc:en:production
working-directory: ${{ github.workspace }}
# Equivalent to: Npm@1 — npm run build:sassdoc:en:production
- name: npm run build:sassdoc (production)
run: npm run build:sassdoc:en:production
working-directory: ${{ github.workspace }}
# Equivalent to: DeleteFiles@1 — Delete PostDeploy.ps1 from dist
- name: Delete PostDeploy.ps1 from dist folder
shell: pwsh
run: |
Remove-Item -Path '${{ github.workspace }}/dist/igniteui-angular/docs/PostDeploy.ps1' `
-Force -ErrorAction SilentlyContinue
# Equivalent to: CopyFiles@2 — Copy angularDocsPostDeploy.ps1 to dist (prod)
- name: Copy angularDocsPostDeploy.ps1 to dist (production)
shell: pwsh
run: |
Copy-Item -Path '${{ github.workspace }}/angularDocsPostDeploy.ps1' `
-Destination '${{ github.workspace }}/dist/igniteui-angular/docs' -Force
# Equivalent to: powershell — Update PostDeploy.ps1 vars (production)
- name: Update PostDeploy.ps1 vars (production)
shell: pwsh
run: |
$filePath = '${{ github.workspace }}/dist/igniteui-angular/docs/angularDocsPostDeploy.ps1'
((Get-Content -Path $filePath -Raw) -replace 'VariableValue', "$env:curTag") |
Set-Content -Path $filePath
((Get-Content -Path $filePath -Raw) -replace 'VariableIsLatest', "$env:isLatestProd") |
Set-Content -Path $filePath
# Equivalent to: script — rename angularDocsPostDeploy.ps1 PostDeploy.ps1 (prod)
- name: Rename PostDeploy.ps1 (production)
shell: pwsh
run: |
Rename-Item -Path '${{ github.workspace }}/dist/igniteui-angular/docs/angularDocsPostDeploy.ps1' `
-NewName 'PostDeploy.ps1'
# Upload the production docs as a workflow artifact for the deploy job
- name: Upload production artifact
uses: actions/upload-artifact@v4
with:
name: angularDocsEN-production
path: dist/igniteui-angular/docs/
# -----------------------------------------------------------------------
# Determine whether this tag is production-eligible (no alpha/beta/rc suffix).
# Result is exposed as a job output so the deploy-production job can condition on it.
- name: Check tag and set ProductionDeployment variable
id: check-deployment
shell: pwsh
run: |
$branchName = "${{ github.ref_name }}".ToLower()
$shouldDeploy = -not $branchName.Contains('alpha') `
-and -not $branchName.Contains('beta') `
-and -not $branchName.Contains('rc')
Write-Host "ProductionDeployment: $shouldDeploy"
echo "productionDeployment=$shouldDeploy" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
# ---------------------------------------------------------------------------
# Deploy staging docs to IIS via MSDeploy.
# TODO: restore 'uses: IgniteUI/igniteui-actions/.github/workflows/deploy.yml@master'
# once cross-repo access is confirmed.
deploy-staging:
needs: build-docs
if: needs.build-docs.outputs.runDeployment == 'true'
runs-on: ubuntu-latest
steps:
- name: Download staging artifact
uses: actions/download-artifact@v4
with:
name: angularDocsEN-staging
path: dist/igniteui-angular/docs/
- name: Deploy staging (placeholder)
run: echo "TODO - deploy staging artifact to IIS (run-id ${{ github.run_id }})"
# ---------------------------------------------------------------------------
# Deploy production docs — only on CI push of a non-pre-release tag.
# TODO: restore 'uses: IgniteUI/igniteui-actions/.github/workflows/deploy.yml@master'
# once cross-repo access is confirmed.
deploy-production:
needs: build-docs
if: github.event_name == 'push' && needs.build-docs.outputs.productionDeployment == 'True'
runs-on: ubuntu-latest
steps:
- name: Download production artifact
uses: actions/download-artifact@v4
with:
name: angularDocsEN-production
path: dist/igniteui-angular/docs/
- name: Deploy production (placeholder)
run: echo "TODO - deploy production artifact to IIS (run-id ${{ github.run_id }})"