Repository navigation
226 lines (191 loc) · 6.64 KB
/
Copy pathrelease.yml
File metadata and controls
226 lines (191 loc) · 6.64 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
name: deploy
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
on:
workflow_dispatch:
push:
tags:
- '*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm'
cache-dependency-path: springdoc-plus-web/pnpm-lock.yaml
- name: Install frontend dependencies
working-directory: ./springdoc-plus-web
run: pnpm install --frozen-lockfile
- name: Check version consistency
shell: pwsh
run: ./scripts/check-version-consistency.ps1
- name: Test frontend with coverage
working-directory: ./springdoc-plus-web
run: pnpm test:coverage
- name: Lint frontend styles
working-directory: ./springdoc-plus-web
run: pnpm lint:style
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Verify Maven modules and sample smoke tests
run: mvn -q -Pfrontend,samples verify jacoco:report
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
*/target/*.jar
*/target/*.pom
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: GPG_PASSPHRASE
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm'
cache-dependency-path: springdoc-plus-web/pnpm-lock.yaml
- name: Install frontend dependencies
working-directory: ./springdoc-plus-web
run: pnpm install --frozen-lockfile
- name: Check version consistency
shell: pwsh
run: ./scripts/check-version-consistency.ps1
- name: Cache Maven dependencies
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Create Maven settings.xml
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$settingsDirectory = Join-Path $HOME '.m2'
$settingsPath = Join-Path $settingsDirectory 'settings.xml'
$settingsContent = @'
<settings>
<servers>
<server>
<id>central</id>
<username>${env.CENTER_USERNAME}</username>
<password>${env.CENTER_PASSWORD}</password>
</server>
</servers>
<profiles>
<profile>
<id>release</id>
<properties>
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
'@
$null = New-Item -ItemType Directory -Path $settingsDirectory -Force
Set-Content -LiteralPath $settingsPath -Value $settingsContent -Encoding UTF8
- name: Deploy to Maven Central
run: mvn -q -Pfrontend,release deploy
env:
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
CENTER_USERNAME: ${{ secrets.CENTER_USERNAME }}
CENTER_PASSWORD: ${{ secrets.CENTER_PASSWORD }}
release:
needs: deploy
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: artifacts
path: release-assets
- name: Extract tag version
id: tag
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$version = $env:GITHUB_REF -replace '^refs/tags/', ''
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Prepare release changelog
id: changelog
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$version = '${{ steps.tag.outputs.version }}'
$normalizedVersion = $version.TrimStart('v')
$changelogFile = 'CHANGELOG.md'
$releaseNotesFile = 'release-notes.md'
if (-not (Test-Path -LiteralPath $changelogFile)) {
Set-Content -LiteralPath $releaseNotesFile -Value '未找到 CHANGELOG.md。' -Encoding UTF8
"path=$releaseNotesFile" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
exit 0
}
$lines = Get-Content -LiteralPath $changelogFile -Encoding UTF8
$capture = $false
$releaseLines = New-Object System.Collections.Generic.List[string]
foreach ($line in $lines) {
$isTargetHeading = $line -match "^## \[($([regex]::Escape($version))|$([regex]::Escape($normalizedVersion)))\]"
$isOtherHeading = $line -match '^## \[' -and -not $isTargetHeading
if ($isTargetHeading) {
$capture = $true
} elseif ($capture -and $isOtherHeading) {
break
}
if ($capture) {
$releaseLines.Add($line)
}
}
if ($releaseLines.Count -eq 0) {
$releaseLines.Add("## $version")
$releaseLines.Add('')
$releaseLines.Add('CHANGELOG.md 中没有匹配的版本记录。')
}
Set-Content -LiteralPath $releaseNotesFile -Value $releaseLines -Encoding UTF8
"path=$releaseNotesFile" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.version }}
name: Release ${{ steps.tag.outputs.version }}
body_path: ${{ steps.changelog.outputs.path }}
files: release-assets/**/*