-
Notifications
You must be signed in to change notification settings - Fork 235
135 lines (123 loc) · 4.44 KB
/
deploy.yml
File metadata and controls
135 lines (123 loc) · 4.44 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
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/**