-
-
Notifications
You must be signed in to change notification settings - Fork 0
413 lines (364 loc) · 20.4 KB
/
changelog.yml
File metadata and controls
413 lines (364 loc) · 20.4 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
name: Changelog Automation
on:
workflow_call:
inputs:
changelog-file:
description: Path to the managed changelog file.
required: false
type: string
default: CHANGELOG.md
project:
description: Optional GitHub Project V2 number for consumer repositories. When omitted, php-fast-forward repositories default to the first organization project.
required: false
type: string
default: ''
version:
description: Optional version to promote during manual release preparation.
required: false
type: string
default: ''
release-branch-prefix:
description: Prefix used for release-preparation branches.
required: false
type: string
default: release/v
workflow_dispatch:
inputs:
changelog-file:
description: Path to the managed changelog file.
required: false
type: string
default: CHANGELOG.md
project:
description: Optional GitHub Project V2 number for consumer repositories. Leave empty to use the configured repository variable or the php-fast-forward default.
required: false
type: string
default: ''
version:
description: Optional version to promote. Leave empty to infer from Unreleased.
required: false
type: string
default: ''
release-branch-prefix:
description: Prefix used for release-preparation branches.
required: false
type: string
default: release/v
pull_request:
types: [opened, reopened, synchronize]
pull_request_target:
types: [closed]
permissions:
actions: write
contents: write
pull-requests: write
repository-projects: write
concurrency:
group: ${{ github.event.pull_request.number && format('changelog-pr-{0}', github.event.pull_request.number) || format('changelog-{0}', github.ref) }}
cancel-in-progress: ${{ github.event.pull_request.merged != true }}
env:
FORCE_COLOR: '1'
jobs:
resolve_php:
name: Resolve PHP Version
runs-on: ubuntu-latest
outputs:
php-version: ${{ steps.resolve.outputs.php-version }}
steps:
- uses: actions/checkout@v6
- name: Checkout dev-tools workflow action source
uses: actions/checkout@v6
with:
repository: php-fast-forward/dev-tools
ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }}
path: .dev-tools-actions
sparse-checkout: |
.github/actions
- name: Resolve workflow PHP version
id: resolve
uses: ./.dev-tools-actions/.github/actions/php/resolve-version
validate_pull_request:
name: Validate PR Changelog
needs: resolve_php
if: ${{ github.event.pull_request.number && github.event.pull_request.merged != true && !startsWith(github.event.pull_request.head.ref, inputs.release-branch-prefix || 'release/v') }}
runs-on: ubuntu-latest
env:
CHANGELOG_FILE: ${{ inputs.changelog-file || 'CHANGELOG.md' }}
CHANGELOG_ROOT_VERSION: ${{ github.event.pull_request.head.ref && format('dev-{0}', github.event.pull_request.head.ref) || 'dev-main' }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Checkout dev-tools workflow action source
uses: actions/checkout@v6
with:
repository: php-fast-forward/dev-tools
ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }}
path: .dev-tools-actions
- name: Setup PHP and install dependencies
uses: ./.dev-tools-actions/.github/actions/php/setup-composer
with:
php-version: ${{ needs.resolve_php.outputs.php-version }}
root-version: ${{ env.CHANGELOG_ROOT_VERSION }}
install-options: --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
- name: Fetch base branch reference
run: git fetch --no-tags --depth=1 origin "+refs/heads/${BASE_REF}:refs/remotes/origin/${BASE_REF}"
- name: Create Dependabot changelog entry when missing
id: dependabot_entry
if: ${{ (github.event.pull_request.user.login == 'dependabot[bot]' || github.event.pull_request.user.login == 'app/dependabot' || startsWith(github.event.pull_request.head.ref, 'dependabot/')) && github.event.pull_request.head.repo.full_name == github.repository }}
uses: ./.dev-tools-actions/.github/actions/changelog/create-dependabot-entry
with:
changelog-file: ${{ env.CHANGELOG_FILE }}
base-ref: ${{ env.BASE_REF }}
head-ref: ${{ env.HEAD_REF }}
pull-request-number: ${{ env.PULL_REQUEST_NUMBER }}
pull-request-title: ${{ env.PULL_REQUEST_TITLE }}
- name: Verify changelog update
run: dev-tools changelog:check --file="${CHANGELOG_FILE}" --against="origin/${BASE_REF}"
- uses: ./.dev-tools-actions/.github/actions/summary/write
with:
markdown: |
## Changelog Validation Summary
- Changelog file: `${{ env.CHANGELOG_FILE }}`
- Compared base ref: `origin/${{ env.BASE_REF }}`
- Dependabot fallback status: `${{ steps.dependabot_entry.outputs.status || 'not needed' }}`
- Dependabot fallback entry created: `${{ steps.dependabot_entry.outputs.created || 'false' }}`
- Dependabot fallback generated message: `${{ steps.dependabot_entry.outputs.message || 'not needed' }}`
- Validation result: success
changelog_validation:
name: Changelog Validation
needs:
- resolve_php
- validate_pull_request
if: ${{ always() && github.event.pull_request.number && github.event.pull_request.merged != true }}
runs-on: ubuntu-latest
env:
RELEASE_BRANCH_PREFIX: ${{ inputs.release-branch-prefix || 'release/v' }}
VALIDATION_RESULT: ${{ needs.validate_pull_request.result }}
steps:
- name: Require changelog validation result
env:
HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
if [[ "${HEAD_REF}" == "${RELEASE_BRANCH_PREFIX}"* ]]; then
echo "Release preparation branch detected; changelog validation is intentionally skipped."
exit 0
fi
if [ "${VALIDATION_RESULT}" = "success" ]; then
echo "Changelog validation passed."
exit 0
fi
echo "::error::Changelog validation did not pass for this pull request."
echo "Validation result: ${VALIDATION_RESULT}"
exit 1
prepare_release_pull_request:
name: Prepare Release Pull Request
needs: resolve_php
if: ${{ !github.event.pull_request.number }}
runs-on: ubuntu-latest
env:
CHANGELOG_FILE: ${{ inputs.changelog-file || 'CHANGELOG.md' }}
RELEASE_BRANCH_PREFIX: ${{ inputs.release-branch-prefix || 'release/v' }}
CHANGELOG_ROOT_VERSION: ${{ format('dev-{0}', github.event.repository.default_branch) }}
steps:
- uses: actions/checkout@v6
with:
token: ${{ github.token }}
ref: ${{ github.event.repository.default_branch }}
fetch-depth: 0
- name: Checkout dev-tools workflow action source
uses: actions/checkout@v6
with:
repository: php-fast-forward/dev-tools
ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }}
path: .dev-tools-actions
- name: Setup PHP and install dependencies
uses: ./.dev-tools-actions/.github/actions/php/setup-composer
with:
php-version: ${{ needs.resolve_php.outputs.php-version }}
root-version: ${{ env.CHANGELOG_ROOT_VERSION }}
install-options: --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
- name: Resolve release version
id: version
uses: ./.dev-tools-actions/.github/actions/changelog/resolve-version
with:
changelog-file: ${{ env.CHANGELOG_FILE }}
version: ${{ inputs.version || '' }}
- name: Promote changelog release
env:
RELEASE_VERSION: ${{ steps.version.outputs.value }}
run: |
release_date="$(date -u +%F)"
dev-tools changelog:promote "${RELEASE_VERSION}" --file="${CHANGELOG_FILE}" --date="${release_date}"
- name: Render release notes preview
uses: ./.dev-tools-actions/.github/actions/changelog/render-release-notes
with:
changelog-file: ${{ env.CHANGELOG_FILE }}
version: ${{ steps.version.outputs.value }}
- name: Create release preparation pull request
id: create_pr
uses: peter-evans/create-pull-request@v8
with:
token: ${{ github.token }}
branch: ${{ env.RELEASE_BRANCH_PREFIX }}${{ steps.version.outputs.value }}
delete-branch: false
base: ${{ github.event.repository.default_branch }}
add-paths: |
${{ env.CHANGELOG_FILE }}
commit-message: Prepare release v${{ steps.version.outputs.value }}
title: Prepare release v${{ steps.version.outputs.value }}
body: |
## Summary
- promote `Unreleased` into `${{ steps.version.outputs.value }}`
- prepare the GitHub release body from `${{ env.CHANGELOG_FILE }}`
## Version Resolution
- source: `${{ steps.version.outputs.source }}`
- name: Checkout release branch
if: ${{ steps.create_pr.outputs.pull-request-number != '' }}
uses: actions/checkout@v6
with:
token: ${{ github.token }}
ref: ${{ env.RELEASE_BRANCH_PREFIX }}${{ steps.version.outputs.value }}
fetch-depth: 0
submodules: recursive
- name: Checkout dev-tools workflow action source
if: ${{ steps.create_pr.outputs.pull-request-number != '' }}
uses: actions/checkout@v6
with:
repository: php-fast-forward/dev-tools
ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }}
path: .dev-tools-actions
- name: Setup PHP and install dependencies
if: ${{ steps.create_pr.outputs.pull-request-number != '' }}
uses: ./.dev-tools-actions/.github/actions/php/setup-composer
with:
php-version: ${{ needs.resolve_php.outputs.php-version }}
root-version: ${{ format('dev-{0}{1}', env.RELEASE_BRANCH_PREFIX, steps.version.outputs.value) }}
install-options: --prefer-dist --no-progress --no-interaction --no-scripts
safe-directories: |
${{ github.workspace }}/.github/wiki
- name: Refresh wiki preview pointer for release pull request
if: ${{ steps.create_pr.outputs.pull-request-number != '' }}
id: refresh_release_preview
uses: ./.dev-tools-actions/.github/actions/wiki/refresh-preview-pointer
with:
preview-branch: pr-${{ steps.create_pr.outputs.pull-request-number }}
commit-message: Update wiki docs for PR #${{ steps.create_pr.outputs.pull-request-number }}
- name: Commit release pull request wiki submodule pointer
if: ${{ steps.create_pr.outputs.pull-request-number != '' && steps.refresh_release_preview.outputs.pointer-changed == 'true' }}
id: release_wiki_pointer_commit
uses: EndBug/add-and-commit@v10
with:
add: .github/wiki
message: Update wiki submodule pointer for PR #${{ steps.create_pr.outputs.pull-request-number }}
default_author: github_actions
pull: "--rebase --autostash"
push: true
- name: Dispatch required tests for release pull request
if: ${{ steps.create_pr.outputs.pull-request-number != '' }}
env:
GH_TOKEN: ${{ github.token }}
RELEASE_BRANCH: ${{ env.RELEASE_BRANCH_PREFIX }}${{ steps.version.outputs.value }}
run: gh workflow run tests.yml --ref "${RELEASE_BRANCH}" -f publish-required-statuses=true
- uses: actions/checkout@v6
- name: Checkout dev-tools workflow action source
uses: actions/checkout@v6
with:
repository: php-fast-forward/dev-tools
ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }}
path: .dev-tools-actions
sparse-checkout: |
.github/actions
- uses: ./.dev-tools-actions/.github/actions/project-board/transition-status
with:
project: ${{ inputs.project || vars.PROJECT || '' }}
from-status: Merged
to-status: Release Prepared
- uses: ./.dev-tools-actions/.github/actions/summary/write
with:
markdown: |
## Release Preparation Summary
- Changelog file: `${{ env.CHANGELOG_FILE }}`
- Release version: `${{ steps.version.outputs.value }}`
- Version source: `${{ steps.version.outputs.source }}`
- Pull request operation: `${{ steps.create_pr.outputs.pull-request-operation || 'none' }}`
- Pull request URL: ${{ steps.create_pr.outputs.pull-request-url || 'not created' }}
- Wiki preview refresh: `${{ steps.create_pr.outputs.pull-request-number != '' && (steps.refresh_release_preview.outputs.published == 'true' && 'published' || 'unchanged') || 'not needed' }}`
- Wiki pointer update: `${{ steps.create_pr.outputs.pull-request-number != '' && (steps.refresh_release_preview.outputs.pointer-changed == 'true' && 'updated' || 'unchanged') || 'not needed' }}`
- Required test dispatch: `${{ steps.create_pr.outputs.pull-request-number != '' && 'requested' || 'not needed' }}`
publish_merged_release:
name: Publish Merged Release
needs: resolve_php
if: ${{ github.event.pull_request.merged == true && github.event.pull_request.base.ref == github.event.repository.default_branch && github.event.pull_request.head.repo.full_name == github.repository && startsWith(github.event.pull_request.head.ref, inputs.release-branch-prefix || 'release/v') }}
runs-on: ubuntu-latest
env:
CHANGELOG_FILE: ${{ inputs.changelog-file || 'CHANGELOG.md' }}
RELEASE_BRANCH_PREFIX: ${{ inputs.release-branch-prefix || 'release/v' }}
CHANGELOG_ROOT_VERSION: ${{ format('dev-{0}', github.event.repository.default_branch) }}
steps:
- uses: actions/checkout@v6
with:
token: ${{ github.token }}
ref: ${{ github.event.pull_request.base.ref }}
fetch-depth: 0
- name: Checkout dev-tools workflow action source
uses: actions/checkout@v6
with:
repository: php-fast-forward/dev-tools
ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }}
path: .dev-tools-actions
- name: Setup PHP and install dependencies
uses: ./.dev-tools-actions/.github/actions/php/setup-composer
with:
php-version: ${{ needs.resolve_php.outputs.php-version }}
root-version: ${{ env.CHANGELOG_ROOT_VERSION }}
install-options: --prefer-dist --no-progress --no-interaction --no-plugins --no-scripts
- name: Resolve merged release version
id: version
uses: ./.dev-tools-actions/.github/actions/changelog/resolve-merged-version
with:
head-ref: ${{ github.event.pull_request.head.ref }}
release-branch-prefix: ${{ env.RELEASE_BRANCH_PREFIX }}
- name: Render release notes
uses: ./.dev-tools-actions/.github/actions/changelog/render-release-notes
with:
changelog-file: ${{ env.CHANGELOG_FILE }}
version: ${{ steps.version.outputs.value }}
- name: Publish GitHub release
id: publish_release
uses: ./.dev-tools-actions/.github/actions/changelog/publish-release
with:
version: ${{ steps.version.outputs.value }}
target: ${{ github.event.pull_request.merge_commit_sha || github.sha }}
- uses: actions/checkout@v6
- name: Checkout dev-tools workflow action source
uses: actions/checkout@v6
with:
repository: php-fast-forward/dev-tools
ref: ${{ github.repository == 'php-fast-forward/dev-tools' && (github.event_name == 'pull_request_target' && github.event.pull_request.base.sha || github.sha) || 'main' }}
path: .dev-tools-actions
sparse-checkout: |
.github/actions
- id: release_project_status
uses: ./.dev-tools-actions/.github/actions/project-board/transition-status
with:
project: ${{ inputs.project || vars.PROJECT || '' }}
from-statuses: Release Prepared,Merged
to-status: Released
include-current-pull-request: 'true'
- uses: ./.dev-tools-actions/.github/actions/summary/write
with:
markdown: |
## Release Publication Summary
- Changelog file: `${{ env.CHANGELOG_FILE }}`
- Published tag: `v${{ steps.version.outputs.value }}`
- Release operation: `${{ steps.publish_release.outputs.operation }}`
- Release URL: ${{ steps.publish_release.outputs.url }}
- Wiki publication: `delegated to wiki-maintenance from pr-${{ github.event.pull_request.number }}`
- Project items released: `${{ steps.release_project_status.outputs.moved-count }}`
- Project items skipped: `${{ steps.release_project_status.outputs.skipped-count }}`
- Project source statuses: `${{ steps.release_project_status.outputs.source-statuses }}`