Skip to content

Commit 694022d

Browse files
committed
feat: create-changelog action
1 parent ced2a09 commit 694022d

File tree

10 files changed

+494
-12
lines changed

10 files changed

+494
-12
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,21 +131,17 @@ jobs:
131131
run:
132132
shell: bash
133133

134-
strategy:
135-
fail-fast: false
136-
matrix:
137-
include:
138-
- { name: 'Docs', os: ubuntu-22.04 }
139-
140-
name: ${{ matrix.name }}
134+
name: Docs and Release
141135
timeout-minutes: 120
142-
runs-on: ${{matrix.os}}
136+
runs-on: ubuntu-22.04
143137
permissions:
144138
contents: write
145139

146140
steps:
147-
- name: Clone Boost.URL
141+
- name: Clone cpp-actions
148142
uses: actions/checkout@v3
143+
with:
144+
fetch-depth: 100
149145

150146
- name: Install Node.js
151147
uses: actions/setup-node@v3
@@ -176,12 +172,29 @@ jobs:
176172
github_token: ${{ secrets.GITHUB_TOKEN }}
177173
publish_dir: docs/build/site
178174

175+
- name: Create release notes
176+
uses: ./create-changelog
177+
with:
178+
output-path: CHANGELOG.md
179+
trace-commands: true
180+
181+
- name: Remove branch release
182+
if: ${{ github.event_name == 'push' && contains(fromJSON('["master", "develop"]'), github.ref_name) }}
183+
uses: dev-drprasad/delete-tag-and-release@v1.0
184+
with:
185+
tag_name: ${{ github.ref_name || github.ref }}-release
186+
github_token: ${{ secrets.GITHUB_TOKEN }}
187+
delete_release: true
188+
179189
- name: Create Release
180190
if: ${{ github.event_name == 'push' && (contains(fromJSON('["master", "develop"]'), github.ref_name) || startsWith(github.ref, 'refs/tags/')) }}
181191
uses: softprops/action-gh-release@v1
182192
with:
183193
files: LICENSE
184194
name: ${{ github.ref_name || github.ref }}
185195
tag_name: ${{ github.ref_name || github.ref }}${{ (!startsWith(github.ref, 'refs/tags/')) && '-release' }}
196+
body_path: CHANGELOG.md
197+
prerelease: false
198+
draft: false
186199
token: ${{ github.token }}
187200

README.adoc

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ NOTE: READ THE DOCS: https://alandefreitas.github.io/cpp-actions/
1414
- <<cmake-workflow>>
1515
- <<boost-clone>>
1616
- <<b2-workflow>>
17+
- <<create-changelog>>
1718

1819
=== Install dependencies [[package-install]]
1920
:reftext: Install dependencies
@@ -440,6 +441,77 @@ steps:
440441
|`trace-commands` |Trace commands executed by the workflow. |`false`
441442
|===
442443

444+
=== Create Changelog [[create-changelog]]
445+
:reftext: Create Changelog
446+
:navtitle: Create Changelog Action
447+
// This create-changelog.adoc file is automatically generated.
448+
// Edit parse_actions.py instead.
449+
450+
This action creates an initial Changelog from the commit history.
451+
452+
The commits considered go from the latest commit up to a commit containing a version
453+
commit pattern specified by version-pattern.
454+
455+
The result can be used as the initial body for an automated release, a CHANGELOG.md file, or a job summary.
456+
457+
Each commit is parsed as a loose variant of a https://www.conventionalcommits.org/en/v1.0.0/[conventional commit]
458+
in the following format:
459+
460+
[source]
461+
----
462+
<type>[optional scope]: <description>
463+
464+
[optional body]
465+
466+
[optional footer(s)]
467+
----
468+
469+
* The body and footer are always ignored.
470+
* If no type is indicated, the description goes to an initial "other" category in the message.
471+
* If no scope is indicated, the description goes to an initial "general" scope in the type messages.
472+
* Breaking changes are indicated.
473+
474+
This action uses the local commit history to generate the notes. Ensure the `fetch-depth` option
475+
is set when cloning your repository in CI. If this option is unset, the checkout action will
476+
perform a shallow clone and the Changelog will only include the latest commit.
477+
478+
[source,yml]
479+
----
480+
- uses: actions/checkout@v3
481+
with:
482+
fetch-depth: 100
483+
----
484+
485+
This parameter can also be used as a limit on the number of commits the action should consider.
486+
487+
488+
==== Example
489+
490+
[source,yml]
491+
----
492+
steps:
493+
- name: Create release notes
494+
uses: alandefreitas/cpp-actions/create-changelog@master
495+
with:
496+
output-path: CHANGELOG.md
497+
trace-commands: 'true'
498+
----
499+
500+
==== Input Parameters
501+
502+
|===
503+
|Parameter |Description |Default
504+
|`source-dir` |The source directory from whose commits will be analyzed
505+
. |`.`
506+
|`version-pattern` |A regex pattern used to identify if a commit is a version delimiter
507+
. |`(Bump\|Set)\s+version`
508+
|`output-path` |The path where the changelog will be stored
509+
. |`CHANGELOG.md`
510+
|`limit` |The limit on the number of commits considered in the Changelog
511+
. |`0`
512+
|`trace-commands` |Trace commands executed by the workflow. |`false`
513+
|===
514+
443515

444516

445517
== Contributions

boost-clone/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Distributed under the Boost Software License, Version 1.0.
55
# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
66
#
7-
# Official repository: https://github.com/CPPAlliance/url
7+
# Official repository: https://github.com/alandefreitas/cpp-actions
88
#
99

1010
name: 'Boost Clone'

boost-clone/scan_deps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Distributed under the Boost Software License, Version 1.0.
77
# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
88
#
9-
# Official repository: https://github.com/CPPAlliance/url
9+
# Official repository: https://github.com/alandefreitas/cpp-actions
1010
#
1111

1212
# Adapted from boostorg/boostdep/blob/develop/depinst/depinst.py

create-changelog/action.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#
2+
# Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.com)
3+
#
4+
# Distributed under the Boost Software License, Version 1.0.
5+
# (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
# Official repository: https://github.com/alandefreitas/cpp-actions
8+
#
9+
10+
name: "Create Changelog"
11+
description: |
12+
This action creates an initial Changelog from the commit history.
13+
14+
The commits considered go from the latest commit up to a commit containing a version
15+
commit pattern specified by version-pattern.
16+
17+
The result can be used as the initial body for an automated release, a CHANGELOG.md file, or a job summary.
18+
19+
Each commit is parsed as a loose variant of a https://www.conventionalcommits.org/en/v1.0.0/[conventional commit]
20+
in the following format:
21+
22+
[source]
23+
----
24+
<type>[optional scope]: <description>
25+
26+
[optional body]
27+
28+
[optional footer(s)]
29+
----
30+
31+
* The body and footer are always ignored.
32+
* If no type is indicated, the description goes to an initial "other" category in the message.
33+
* If no scope is indicated, the description goes to an initial "general" scope in the type messages.
34+
* Breaking changes are indicated.
35+
36+
This action uses the local commit history to generate the notes. Ensure the `fetch-depth` option
37+
is set when cloning your repository in CI. If this option is unset, the checkout action will
38+
perform a shallow clone and the Changelog will only include the latest commit.
39+
40+
[source,yml]
41+
----
42+
- uses: actions/checkout@v3
43+
with:
44+
fetch-depth: 100
45+
----
46+
47+
This parameter can also be used as a limit on the number of commits the action should consider.
48+
49+
inputs:
50+
source-dir:
51+
description: |
52+
The source directory from whose commits will be analyzed
53+
required: false
54+
default: '.'
55+
version-pattern:
56+
description: |
57+
A regex pattern used to identify if a commit is a version delimiter
58+
required: false
59+
default: '(Bump|Set)\s+version'
60+
output-path:
61+
description: |
62+
The path where the changelog will be stored
63+
required: false
64+
default: 'CHANGELOG.md'
65+
limit:
66+
description: |
67+
The limit on the number of commits considered in the Changelog
68+
required: false
69+
default: '0'
70+
trace-commands:
71+
description: 'Trace commands executed by the workflow.'
72+
required: false
73+
default: 'false'
74+
75+
runs:
76+
using: "composite"
77+
steps:
78+
- uses: actions/setup-python@v4
79+
id: setup-python
80+
with:
81+
python-version: '>= 3.10'
82+
83+
- name: Generate changelog
84+
shell: bash
85+
run: |
86+
${{ (inputs.trace-commands == 'true' && 'set -xe') || '' }}
87+
python_path="${{ steps.setup-python.outputs.python-path || 'python' }}"
88+
$python_path "$GITHUB_ACTION_PATH/create-changelog.py" --dir "${{ inputs.source-dir }}" --version-pattern "${{ inputs.version-pattern }}" --output "${{ inputs.output-path }}" --limit "${{ inputs.limit }}"

0 commit comments

Comments
 (0)