Skip to content

Commit 18bdbfc

Browse files
Split out task
1 parent 3fdaaeb commit 18bdbfc

File tree

4 files changed

+113
-116
lines changed

4 files changed

+113
-116
lines changed

.github/workflows/deploy.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Deploy CodeConverter
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
deployWeb:
7+
description: "Deploy web to GitHub Pages"
8+
required: false
9+
type: boolean
10+
default: false
11+
publishNuget:
12+
description: "Publish NuGet package and dotnet tool"
13+
required: false
14+
type: boolean
15+
default: false
16+
createRelease:
17+
description: "Create GitHub release"
18+
required: false
19+
type: boolean
20+
default: false
21+
nugetApiKey:
22+
description: "NuGet API key (required if Publish NuGet is checked)"
23+
required: false
24+
type: string
25+
26+
jobs:
27+
deploy:
28+
concurrency: deploy-${{ github.ref }}
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: write
32+
steps:
33+
- name: Checkout 🛎️
34+
uses: actions/checkout@v4
35+
36+
- name: Download Web artifact from latest successful build 🔻
37+
if: ${{ inputs.deployWeb }}
38+
uses: dawidd6/action-download-artifact@v6
39+
with:
40+
workflow: dotnet.yml
41+
branch: main
42+
name_pattern: ICSharpCode.CodeConverter.Web.*.zip
43+
path: site
44+
45+
- name: Download release artifacts
46+
if: ${{ inputs.createRelease || inputs.publishNuget }}
47+
uses: dawidd6/action-download-artifact@v6
48+
with:
49+
workflow: dotnet.yml
50+
branch: main
51+
name_pattern: ICSharpCode.CodeConverter*
52+
path: release-artifacts
53+
merge-multiple: true
54+
55+
- name: Extract build version from artifacts
56+
id: get_version
57+
if: ${{ inputs.createRelease }}
58+
shell: pwsh
59+
run: |
60+
$artifact = Get-ChildItem -Path release-artifacts -Filter "*.nupkg" | Select-Object -First 1
61+
if ($artifact) {
62+
$version = $artifact.Name -replace '^ICSharpCode\.CodeConverter\.(.+)\.nupkg$', '$1'
63+
Write-Output "version=$version" >> $env:GITHUB_OUTPUT
64+
} else {
65+
throw "No NuGet packages found in release-artifacts directory"
66+
}
67+
68+
- name: Extract latest changelog section
69+
id: changelog
70+
shell: pwsh
71+
if: ${{ inputs.createRelease }}
72+
run: |
73+
./Get-LatestChangelog.ps1 -Path CHANGELOG.md | Tee-Object -FilePath release-notes.md
74+
"notes<<EOF" >> $env:GITHUB_OUTPUT
75+
Get-Content release-notes.md >> $env:GITHUB_OUTPUT
76+
"EOF" >> $env:GITHUB_OUTPUT
77+
78+
- name: Deploy to GitHub Pages 🚀
79+
if: ${{ inputs.deployWeb }}
80+
uses: JamesIves/github-pages-deploy-action@v4
81+
with:
82+
branch: 'autoupdated/gh-pages'
83+
folder: 'site'
84+
85+
- name: Publish NuGet packages
86+
if: ${{ inputs.publishNuget }}
87+
shell: pwsh
88+
env:
89+
NUGET_API_KEY: ${{ inputs.nugetApiKey }}
90+
run: |
91+
if (-not $env:NUGET_API_KEY) { throw "nugetApiKey input is required when Publish NuGet is checked." }
92+
Write-Output "::add-mask::$env:NUGET_API_KEY"
93+
$source = "https://api.nuget.org/v3/index.json"
94+
$packages = @(
95+
"release-artifacts/ICSharpCode.CodeConverter.*.nupkg",
96+
"release-artifacts/ICSharpCode.CodeConverter.CodeConv.*.nupkg"
97+
)
98+
foreach ($pattern in $packages) {
99+
Get-ChildItem -Path $pattern -File | ForEach-Object {
100+
dotnet nuget push $_.FullName -k $env:NUGET_API_KEY -s $source --skip-duplicate
101+
}
102+
}
103+
104+
- name: Create GitHub release
105+
if: ${{ inputs.createRelease }}
106+
uses: softprops/action-gh-release@v2
107+
with:
108+
tag_name: v${{ steps.get_version.outputs.version }}
109+
name: v${{ steps.get_version.outputs.version }}
110+
body: ${{ steps.changelog.outputs.notes }}
111+
files: release-artifacts/**

.github/workflows/dotnet.yml

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,6 @@ on:
55
branches: [ master, main ]
66
pull_request:
77
branches: [ master, main ]
8-
workflow_dispatch:
9-
inputs:
10-
publishNuget:
11-
description: "Publish NuGet package and dotnet tool"
12-
required: false
13-
type: boolean
14-
default: false
15-
deployWebFunc:
16-
description: "Deploy web/func artifacts"
17-
required: false
18-
type: boolean
19-
default: false
20-
createRelease:
21-
description: "Create GitHub release"
22-
required: false
23-
type: boolean
24-
default: false
25-
nugetApiKey:
26-
description: "NuGet API key (required if Publish NuGet is checked)"
27-
required: false
28-
type: string
298

309
env:
3110
BuildVersion: '10.0.0'
@@ -95,81 +74,10 @@ jobs:
9574
uses: actions/upload-artifact@v4
9675
with:
9776
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
98-
path: web/dist/
77+
path: Web/dist/
9978
- name: Upload Function
10079
uses: actions/upload-artifact@v4
10180
with:
10281
name: ICSharpCode.CodeConverter.Func.${{ env.BuildVersion }}.zip
10382
path: Func/bin/${{ env.BuildTarget }}/publish/
104-
105-
deploy:
106-
if: ${{ github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') }}
107-
concurrency: ci-${{ github.ref }}
108-
needs: [build] # The second job must depend on the first one to complete before running and uses ubuntu-latest instead of windows.
109-
runs-on: ubuntu-latest
110-
permissions:
111-
contents: write
112-
steps:
113-
- name: Checkout 🛎️
114-
uses: actions/checkout@v4
115-
116-
- name: Download web artifact 🔻 # The built project is downloaded into the 'site' folder.
117-
if: ${{ inputs.deployWebFunc }}
118-
uses: actions/download-artifact@v4
119-
with:
120-
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
121-
path: site
122-
123-
- name: Download release artifacts
124-
if: ${{ inputs.createRelease || inputs.publishNuget }}
125-
uses: actions/download-artifact@v4
126-
with:
127-
pattern: ICSharpCode.CodeConverter.*
128-
path: release-artifacts
129-
merge-multiple: true
130-
131-
- name: Extract latest changelog section
132-
id: changelog
133-
shell: pwsh
134-
if: ${{ inputs.createRelease }}
135-
run: |
136-
./Get-LatestChangelog.ps1 -Path CHANGELOG.md | Tee-Object -FilePath release-notes.md
137-
"notes<<EOF" >> $env:GITHUB_OUTPUT
138-
Get-Content release-notes.md >> $env:GITHUB_OUTPUT
139-
"EOF" >> $env:GITHUB_OUTPUT
140-
141-
- name: Deploy 🚀
142-
if: ${{ inputs.deployWebFunc }}
143-
uses: JamesIves/github-pages-deploy-action@v4
144-
with:
145-
branch: 'autoupdated/gh-pages'
146-
folder: 'site/wwwroot'
147-
148-
- name: Publish NuGet packages
149-
if: ${{ inputs.publishNuget }}
150-
shell: pwsh
151-
env:
152-
NUGET_API_KEY: ${{ inputs.nugetApiKey }}
153-
run: |
154-
if (-not $env:NUGET_API_KEY) { throw "nugetApiKey input is required when Publish NuGet is checked." }
155-
Write-Output "::add-mask::$env:NUGET_API_KEY"
156-
$source = "https://api.nuget.org/v3/index.json"
157-
$packages = @(
158-
"release-artifacts/ICSharpCode.CodeConverter.*.nupkg",
159-
"release-artifacts/ICSharpCode.CodeConverter.CodeConv.*.nupkg"
160-
)
161-
foreach ($pattern in $packages) {
162-
Get-ChildItem -Path $pattern -File | ForEach-Object {
163-
dotnet nuget push $_.FullName -k $env:NUGET_API_KEY -s $source --skip-duplicate
164-
}
165-
}
166-
167-
- name: Create GitHub release
168-
if: ${{ inputs.createRelease }}
169-
uses: softprops/action-gh-release@v2
170-
with:
171-
tag_name: v${{ env.BuildVersion }}.${{ github.run_number }}
172-
name: v${{ env.BuildVersion }}.${{ github.run_number }}
173-
body: ${{ steps.changelog.outputs.notes }}
174-
files: release-artifacts/**
17583

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,4 @@ __pycache__/
288288
*.xsd.cs
289289
/.nuget
290290
/web/.vite/
291+
/web/dist/

Web/.gitignore

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)