Skip to content

Convert and publish #30

Convert and publish

Convert and publish #30

# Convert all Windows protocol specs to markdown, build a clean publish tree,
# then force-push it to an orphaned 'publish' branch (e.g. for GitHub Pages).
# Conversion runs in parallel (PowerShell 7) to reduce run time.
name: Convert and publish
on:
workflow_dispatch:
# Required for force-pushing to the orphaned 'publish' branch.
permissions:
contents: write
jobs:
convert-and-publish:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install oxipng
shell: pwsh
run: |
$release = Invoke-RestMethod -Uri 'https://api.github.com/repos/oxipng/oxipng/releases/latest'
$asset = $release.assets | Where-Object { $_.name -match 'x86_64-pc-windows-msvc\.zip$' } | Select-Object -First 1
if (-not $asset) {
throw 'Could not find Windows x86_64 zip asset in latest oxipng release.'
}
$zipPath = Join-Path $env:RUNNER_TEMP $asset.name
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $zipPath
$extractPath = Join-Path $env:RUNNER_TEMP 'oxipng'
if (Test-Path -LiteralPath $extractPath) {
Remove-Item -LiteralPath $extractPath -Recurse -Force
}
Expand-Archive -LiteralPath $zipPath -DestinationPath $extractPath -Force
$binPath = Get-ChildItem -LiteralPath $extractPath -Recurse -File -Filter 'oxipng.exe' | Select-Object -First 1
if (-not $binPath) {
throw 'oxipng.exe was not found after extracting release archive.'
}
$binDir = Split-Path -Path $binPath.FullName -Parent
$env:PATH = "$binDir;$env:PATH"
Add-Content -Path $env:GITHUB_PATH -Value $binDir
& $binPath.FullName --version
- name: Install OpenXML module
shell: pwsh
run: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name OpenXML -Force -Scope CurrentUser
- name: Build publish tree and windows-protocols.zip
shell: pwsh
working-directory: ${{ github.workspace }}
run: .\scripts\Build-Publish.ps1 -ThrottleLimit 4 -AllowPartial
- name: Upload publish artifact
uses: actions/upload-artifact@v4
with:
name: publish
path: windows-protocols.zip
- name: Stage downloadable bundle in publish tree
shell: pwsh
working-directory: ${{ github.workspace }}
run: Copy-Item -LiteralPath .\windows-protocols.zip -Destination .\skills\windows-protocols\windows-protocols.zip -Force
- name: Push to orphaned publish branch
shell: pwsh
working-directory: skills/windows-protocols
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$RemoteRepo = "https://${Env:GITHUB_ACTOR}:${Env:GITHUB_TOKEN}@github.com/${Env:GITHUB_REPOSITORY}.git"
git init
git config user.name "GitHub Actions"
git config user.email "github-actions-bot@users.noreply.github.com"
git add .
git commit -m "Publish converted Open Specs markdown (${Env:GITHUB_REPOSITORY})"
git push --force "${RemoteRepo}" "HEAD:publish"