Skip to content

Commit e67b1ab

Browse files
Push release artifacts
1 parent e8cd756 commit e67b1ab

2 files changed

Lines changed: 83 additions & 19 deletions

File tree

.github/workflows/dotnet.yml

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ on:
55
branches: [ master, main ]
66
pull_request:
77
branches: [ master, main ]
8+
workflow_dispatch:
89

910
env:
1011
BuildVersion: '10.0.0'
1112

1213
jobs:
13-
build:
14+
build:
1415
runs-on: windows-2022
1516
env:
1617
BuildPlatform: Any CPU
@@ -81,24 +82,48 @@ jobs:
8182
name: ICSharpCode.CodeConverter.Func.${{ env.BuildVersion }}.zip
8283
path: Func/bin/${{ env.BuildTarget }}/publish/
8384

84-
deploy:
85-
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
86-
concurrency: ci-${{ github.ref }}
87-
needs: [build] # The second job must depend on the first one to complete before running and uses ubuntu-latest instead of windows.
88-
runs-on: ubuntu-latest
89-
steps:
90-
- name: Checkout 🛎️
91-
uses: actions/checkout@v4
85+
deploy:
86+
if: ${{ github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') }}
87+
concurrency: ci-${{ github.ref }}
88+
needs: [build] # The second job must depend on the first one to complete before running and uses ubuntu-latest instead of windows.
89+
runs-on: ubuntu-latest
90+
permissions:
91+
contents: write
92+
steps:
93+
- name: Checkout 🛎️
94+
uses: actions/checkout@v4
9295

93-
- name: Download Artifacts 🔻 # The built project is downloaded into the 'site' folder.
94-
uses: actions/download-artifact@v4
95-
with:
96-
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
97-
path: site
96+
- name: Download Artifacts 🔻 # The built project is downloaded into the 'site' folder.
97+
uses: actions/download-artifact@v4
98+
with:
99+
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
100+
path: site
101+
102+
- name: Download all release artifacts
103+
uses: actions/download-artifact@v4
104+
with:
105+
path: release-artifacts
106+
107+
- name: Extract latest changelog section
108+
id: changelog
109+
shell: pwsh
110+
run: |
111+
./Get-LatestChangelog.ps1 -Path CHANGELOG.md | Tee-Object -FilePath release-notes.md
112+
"notes<<EOF" >> $env:GITHUB_OUTPUT
113+
Get-Content release-notes.md >> $env:GITHUB_OUTPUT
114+
"EOF" >> $env:GITHUB_OUTPUT
98115
99-
- name: Deploy 🚀
100-
uses: JamesIves/github-pages-deploy-action@v4
101-
with:
102-
branch: 'autoupdated/gh-pages'
103-
folder: 'site/wwwroot'
116+
- name: Deploy 🚀
117+
uses: JamesIves/github-pages-deploy-action@v4
118+
with:
119+
branch: 'autoupdated/gh-pages'
120+
folder: 'site/wwwroot'
121+
122+
- name: Create GitHub release
123+
uses: softprops/action-gh-release@v2
124+
with:
125+
tag_name: v${{ env.BuildVersion }}.${{ github.run_number }}
126+
name: v${{ env.BuildVersion }}.${{ github.run_number }}
127+
body: ${{ steps.changelog.outputs.notes }}
128+
files: release-artifacts/**
104129

Get-LatestChangelog.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
Param(
2+
[string]$Path = 'CHANGELOG.md'
3+
)
4+
5+
if (-not [System.IO.Path]::IsPathRooted($Path)) {
6+
$Path = Join-Path $PSScriptRoot $Path
7+
}
8+
9+
if (-not (Test-Path -Path $Path)) {
10+
throw "Changelog not found at '$Path'."
11+
}
12+
13+
$lines = Get-Content -Path $Path
14+
$inSection = $false
15+
$collected = New-Object System.Collections.Generic.List[string]
16+
17+
foreach ($line in $lines) {
18+
if ($line -match '^## \[') {
19+
if (-not $inSection) {
20+
if ($line -match '^## \[Unreleased\]') {
21+
continue
22+
}
23+
$inSection = $true
24+
}
25+
elseif ($inSection) {
26+
break
27+
}
28+
}
29+
30+
if ($inSection) {
31+
$collected.Add($line) | Out-Null
32+
}
33+
}
34+
35+
if (-not $inSection -or $collected.Count -eq 0) {
36+
throw "No released changelog section found in '$Path'."
37+
}
38+
39+
$collected | Write-Output

0 commit comments

Comments
 (0)