Skip to content

Deploy CodeConverter #8

Deploy CodeConverter

Deploy CodeConverter #8

Workflow file for this run

name: Deploy CodeConverter
on:
workflow_dispatch:
inputs:
deployWeb:
description: "Deploy web to GitHub Pages"
required: false
type: boolean
default: false
publishNuget:
description: "Publish NuGet package and dotnet tool"
required: false
type: boolean
default: false
createRelease:
description: "Create GitHub release"
required: false
type: boolean
default: false
nugetApiKey:
description: "NuGet API key (required if Publish NuGet is checked)"
required: false
type: string
jobs:
deploy:
concurrency: deploy-${{ github.ref }}
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
- name: Download Web artifact to site directory
if: ${{ inputs.deployWeb }}
uses: dawidd6/action-download-artifact@v6
with:
workflow: dotnet.yml
branch: master
name_is_regexp: true
name: ICSharpCode\.CodeConverter\.Web\..*\.zip
path: site-temp
- name: Move web files to site root
if: ${{ inputs.deployWeb }}
shell: pwsh
run: |
$subDir = Get-ChildItem -Path site-temp -Directory | Select-Object -First 1
if ($subDir) {
Move-Item -Path "$($subDir.FullName)/*" -Destination site/
Remove-Item $subDir.FullName
}
- name: Download NuGet and VSIX artifacts
if: ${{ inputs.createRelease || inputs.publishNuget }}
uses: dawidd6/action-download-artifact@v6
with:
workflow: dotnet.yml
branch: master
name_is_regexp: true
name: ICSharpCode\.CodeConverter.*\.(nupkg|vsix)$
path: release-artifacts
skip_unpack: false
- name: Download ZIP artifacts
if: ${{ inputs.createRelease }}
uses: dawidd6/action-download-artifact@v6
with:
workflow: dotnet.yml
branch: master
name_is_regexp: true
name: ICSharpCode\.CodeConverter.*\.zip$
path: release-artifacts
skip_unpack: true
- name: Rename ZIP files
if: ${{ inputs.createRelease }}
shell: pwsh
run: |
Get-ChildItem -Path release-artifacts -Filter "*.zip.zip" | ForEach-Object {
$newName = $_.Name -replace '\.zip\.zip$', '.zip'
Rename-Item -Path $_.FullName -NewName $newName
}
- name: Extract build version from artifacts
id: get_version
if: ${{ inputs.createRelease }}
shell: pwsh
run: |
$artifact = Get-ChildItem -Path release-artifacts -Filter "ICSharpCode.CodeConverter.*.nupkg" | Select-Object -First 1
if ($artifact) {
$version = $artifact.Name -replace '^ICSharpCode\.CodeConverter\.(.+)\.nupkg$', '$1'
Write-Output "version=$version" >> $env:GITHUB_OUTPUT
} else {
throw "No NuGet packages found in release-artifacts directory"
}
- name: Extract latest changelog section
id: changelog
shell: pwsh
if: ${{ inputs.createRelease }}
run: |
./Get-LatestChangelog.ps1 -Path CHANGELOG.md | Tee-Object -FilePath release-notes.md
- name: Deploy to GitHub Pages 🚀
if: ${{ inputs.deployWeb }}
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: 'autoupdated/gh-pages'
folder: 'site'
- name: Publish NuGet packages
if: ${{ inputs.publishNuget }}
shell: pwsh
env:
NUGET_API_KEY: ${{ inputs.nugetApiKey }}
run: |
if (-not $env:NUGET_API_KEY) { throw "nugetApiKey input is required when Publish NuGet is checked." }
Write-Output "::add-mask::$env:NUGET_API_KEY"
$source = "https://api.nuget.org/v3/index.json"
$packages = Get-ChildItem -Path release-artifacts -Filter "*.nupkg"
foreach ($package in $packages) {
dotnet nuget push $package.FullName -k $env:NUGET_API_KEY -s $source --skip-duplicate
}
- name: Create GitHub release
if: ${{ inputs.createRelease }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get_version.outputs.version }}
name: v${{ steps.get_version.outputs.version }}
body_path: release-notes.md
files: release-artifacts/**