Skip to content

Commit 2682205

Browse files
Try to have a single deploy step with a couple of options
1 parent 787070e commit 2682205

File tree

2 files changed

+48
-52
lines changed

2 files changed

+48
-52
lines changed

.github/workflows/dotnet.yml

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@ on:
66
pull_request:
77
branches: [ master, main ]
88
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
929

1030
env:
1131
BuildVersion: '10.0.0'
@@ -93,33 +113,59 @@ jobs:
93113
- name: Checkout 🛎️
94114
uses: actions/checkout@v4
95115

96-
- name: Download Artifacts 🔻 # The built project is downloaded into the 'site' folder.
116+
- name: Download web artifact 🔻 # The built project is downloaded into the 'site' folder.
117+
if: ${{ inputs.deployWebFunc }}
97118
uses: actions/download-artifact@v4
98119
with:
99120
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
100121
path: site
101122

102-
- name: Download all release artifacts
123+
- name: Download release artifacts
124+
if: ${{ inputs.createRelease || inputs.publishNuget }}
103125
uses: actions/download-artifact@v4
104126
with:
127+
pattern: ICSharpCode.CodeConverter.*
105128
path: release-artifacts
129+
merge-multiple: true
106130

107131
- name: Extract latest changelog section
108132
id: changelog
109133
shell: pwsh
134+
if: ${{ inputs.createRelease }}
110135
run: |
111136
./Get-LatestChangelog.ps1 -Path CHANGELOG.md | Tee-Object -FilePath release-notes.md
112137
"notes<<EOF" >> $env:GITHUB_OUTPUT
113138
Get-Content release-notes.md >> $env:GITHUB_OUTPUT
114139
"EOF" >> $env:GITHUB_OUTPUT
115140
116141
- name: Deploy 🚀
142+
if: ${{ inputs.deployWebFunc }}
117143
uses: JamesIves/github-pages-deploy-action@v4
118144
with:
119145
branch: 'autoupdated/gh-pages'
120146
folder: 'site/wwwroot'
121147

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+
122167
- name: Create GitHub release
168+
if: ${{ inputs.createRelease }}
123169
uses: softprops/action-gh-release@v2
124170
with:
125171
tag_name: v${{ env.BuildVersion }}.${{ github.run_number }}

.github/workflows/publish-nuget.yml

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

0 commit comments

Comments
 (0)