Skip to content

Commit 5e71044

Browse files
committed
build: update GitHub Actions workflows to use changelog generation
1 parent 002bd8b commit 5e71044

File tree

6 files changed

+271
-20
lines changed

6 files changed

+271
-20
lines changed

.github/actions/build-macos-x86_64/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ runs:
5656
shell: bash
5757

5858
- name: Deploy
59+
if: ${{ github.event_name != 'pull_request' }}
5960
env:
6061
MAVEN_USERNAME: ${{ inputs.maven-username }}
6162
MAVEN_TOKEN: ${{ inputs.maven-password }}

.github/actions/build/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ runs:
6363
shell: bash
6464

6565
- name: Deploy
66+
if: ${{ github.event_name != 'pull_request' }}
6667
env:
6768
MAVEN_USERNAME: ${{ inputs.maven-username }}
6869
MAVEN_TOKEN: ${{ inputs.maven-password }}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# git-cliff ~ configuration file
2+
# https://git-cliff.org/docs/configuration
3+
4+
[changelog]
5+
# A Tera template to be rendered as the changelog's header.
6+
# See https://keats.github.io/tera/docs/#introduction
7+
header = """
8+
## What's Changed
9+
"""
10+
# A Tera template to be rendered for each release in the changelog.
11+
# See https://keats.github.io/tera/docs/#introduction
12+
body = """
13+
{%- macro remote_url() -%}
14+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
15+
{%- endmacro -%}
16+
17+
{% for group, commits in commits | group_by(attribute="group") %}
18+
### {{ group | striptags | trim | upper_first }}
19+
{%- for commit in commits %}
20+
- {{ commit.message | split(pat="\n") | first | upper_first | trim }}\
21+
{% if commit.remote.username and commit.remote.pr_number %} by @{{ commit.remote.username }}{%- endif -%}
22+
{% if commit.remote.pr_number %} in \
23+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
24+
{%- endif -%}
25+
{% endfor %}
26+
{% endfor %}
27+
28+
{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
29+
## New Contributors
30+
{%- endif -%}
31+
32+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
33+
* @{{ contributor.username }} made their first contribution
34+
{%- if contributor.pr_number %} in \
35+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
36+
{%- endif %}
37+
{%- endfor %}\n
38+
"""
39+
# A Tera template to be rendered as the changelog's footer.
40+
# See https://keats.github.io/tera/docs/#introduction
41+
footer = """
42+
{%- macro remote_url() -%}
43+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
44+
{%- endmacro -%}
45+
46+
{% for release in releases -%}
47+
{% if release.version -%}
48+
{% if release.previous.version -%}
49+
[{{ release.version | trim_start_matches(pat="v") }}]: \
50+
{{ self::remote_url() }}/compare/{{ release.previous.version }}..{{ release.version }}
51+
{% endif -%}
52+
{% else -%}
53+
[unreleased]: {{ self::remote_url() }}/compare/{{ release.previous.version }}..HEAD
54+
{% endif -%}
55+
{% endfor %}
56+
"""
57+
# Remove leading and trailing whitespaces from the changelog's body.
58+
trim = true
59+
60+
[git]
61+
# Parse commits according to the conventional commits specification.
62+
# See https://www.conventionalcommits.org
63+
conventional_commits = true
64+
# Exclude commits that do not match the conventional commits specification.
65+
filter_unconventional = true
66+
# An array of regex based parsers to modify commit messages prior to further processing.
67+
commit_preprocessors = [
68+
# Remove issue numbers.
69+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
70+
]
71+
# An array of regex based parsers for extracting data from the commit message.
72+
# Assigns commits to groups.
73+
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
74+
commit_parsers = [
75+
{ message = "^feat", group = "<!-- 0 -->Features" },
76+
{ message = "^fix", group = "<!-- 1 -->Bug Fixes" },
77+
{ message = "^doc", group = "<!-- 3 -->Documentation" },
78+
{ message = "^perf", group = "<!-- 4 -->Performance" },
79+
{ message = "^refactor", group = "<!-- 2 -->Refactor" },
80+
{ message = "^style", group = "<!-- 5 -->Styling" },
81+
{ message = "^test", group = "<!-- 6 -->Testing" },
82+
{ message = "^chore\\(release\\): prepare for", skip = true },
83+
{ message = "^chore\\(deps.*\\)", skip = true },
84+
{ message = "^chore\\(pr\\)", skip = true },
85+
{ message = "^chore\\(pull\\)", skip = true },
86+
{ message = "^chore|^ci", group = "<!-- 7 -->Miscellaneous Tasks" },
87+
{ body = ".*security", group = "<!-- 8 -->Security" },
88+
{ message = "^revert", group = "<!-- 9 -->Revert" },
89+
{ message = ".*", group = "Other" },
90+
]
91+
# Exclude commits that are not matched by any commit parser.
92+
filter_commits = false
93+
# Order releases topologically instead of chronologically.
94+
topo_order = false
95+
# Order of commits in each group/release within the changelog.
96+
# Allowed values: newest, oldest
97+
sort_commits = "newest"

.github/changelog/cliff.toml

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# git-cliff ~ configuration file
2+
# https://git-cliff.org/docs/configuration
3+
4+
[changelog]
5+
# A Tera template to be rendered as the changelog's header.
6+
# See https://keats.github.io/tera/docs/#introduction
7+
header = """
8+
# Changelog\n
9+
All notable changes to this project will be documented in this file.\n
10+
"""
11+
# A Tera template to be rendered for each release in the changelog.
12+
# See https://keats.github.io/tera/docs/#introduction
13+
body = """
14+
{%- macro remote_url() -%}
15+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
16+
{%- endmacro -%}
17+
18+
{% if version -%}
19+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
20+
{% else -%}
21+
## [Unreleased]
22+
{% endif -%}
23+
24+
{% for group, commits in commits | group_by(attribute="group") %}
25+
### {{ group | striptags | trim | upper_first }}
26+
{%- for commit in commits %}
27+
- {{ commit.message | split(pat="\n") | first | upper_first | trim }}\
28+
{% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif -%}
29+
{% if commit.remote.pr_number %} in \
30+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
31+
{%- endif -%}
32+
{% endfor %}
33+
{% endfor %}
34+
35+
{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
36+
## New Contributors
37+
{%- endif -%}
38+
39+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
40+
* @{{ contributor.username }} made their first contribution
41+
{%- if contributor.pr_number %} in \
42+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
43+
{%- endif %}
44+
{%- endfor %}\n
45+
46+
"""
47+
# A Tera template to be rendered as the changelog's footer.
48+
# See https://keats.github.io/tera/docs/#introduction
49+
footer = """
50+
{%- macro remote_url() -%}
51+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
52+
{%- endmacro -%}
53+
"""
54+
# Remove leading and trailing whitespaces from the changelog's body.
55+
trim = true
56+
57+
[git]
58+
# Parse commits according to the conventional commits specification.
59+
# See https://www.conventionalcommits.org
60+
conventional_commits = true
61+
# Exclude commits that do not match the conventional commits specification.
62+
filter_unconventional = false
63+
# An array of regex based parsers to modify commit messages prior to further processing.
64+
commit_preprocessors = [
65+
# Remove issue numbers.
66+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" },
67+
]
68+
# An array of regex based parsers for extracting data from the commit message.
69+
# Assigns commits to groups.
70+
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
71+
commit_parsers = [
72+
{ message = "^feat", group = "<!-- 0 -->Features" },
73+
{ message = "^fix", group = "<!-- 1 -->Bug Fixes" },
74+
{ message = "^doc", group = "<!-- 3 -->Documentation" },
75+
{ message = "^perf", group = "<!-- 4 -->Performance" },
76+
{ message = "^refactor", group = "<!-- 2 -->Refactor" },
77+
{ message = "^style", group = "<!-- 5 -->Styling" },
78+
{ message = "^test", group = "<!-- 6 -->Testing" },
79+
{ message = "^chore\\(release\\): prepare for", skip = true },
80+
{ message = "^chore\\(deps.*\\)", skip = true },
81+
{ message = "^chore\\(pr\\)", skip = true },
82+
{ message = "^chore\\(pull\\)", skip = true },
83+
{ message = "^chore|^ci", group = "<!-- 7 -->Miscellaneous Tasks" },
84+
{ body = ".*security", group = "<!-- 8 -->Security" },
85+
{ message = "^revert", group = "<!-- 9 -->Revert" },
86+
{ message = ".*", group = "Other" },
87+
]
88+
# Exclude commits that are not matched by any commit parser.
89+
filter_commits = false
90+
# Order releases topologically instead of chronologically.
91+
topo_order = false
92+
# Order of commits in each group/release within the changelog.
93+
# Allowed values: newest, oldest
94+
sort_commits = "newest"

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
runs-on: ${{ matrix.platform.runs-on }}
3333
steps:
3434
- name: Checkout code
35-
uses: actions/checkout@v4
35+
uses: actions/checkout@v5
3636

3737
- id: prepare
3838
name: Prepare build
@@ -62,7 +62,7 @@ jobs:
6262
runs-on: ${{ matrix.platform.runs-on }}
6363
steps:
6464
- name: Checkout code
65-
uses: actions/checkout@v4
65+
uses: actions/checkout@v5
6666

6767
- id: prepare
6868
name: Prepare build
@@ -90,7 +90,7 @@ jobs:
9090
runs-on: ${{ matrix.platform.runs-on }}
9191
steps:
9292
- name: Checkout code
93-
uses: actions/checkout@v4
93+
uses: actions/checkout@v5
9494

9595
- id: prepare-build
9696
name: Prepare build

.github/workflows/release.yml

Lines changed: 75 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,51 @@ env:
1414
WEBRTC_INSTALL_FOLDER: webrtc/build
1515

1616
jobs:
17+
changelog:
18+
name: Generate changelog
19+
runs-on: ubuntu-latest
20+
outputs:
21+
release_body: ${{ steps.git-cliff.outputs.content }}
22+
release_version: ${{ steps.git-cliff.outputs.version }}
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v5
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Git config
31+
run: |
32+
git config user.name "github-actions[bot]"
33+
git config user.email "github-actions[bot]@users.noreply.github.com"
34+
35+
- name: Generate changelog for the current build
36+
uses: orhun/git-cliff-action@v4
37+
id: git-cliff
38+
with:
39+
config: .github/changelog/cliff-release.toml
40+
args: -v -u --strip footer --bump --use-branch-tags
41+
42+
- name: Update CHANGELOG.md
43+
uses: orhun/git-cliff-action@v4
44+
with:
45+
config: .github/changelog/cliff.toml
46+
args: -v --bump --use-branch-tags
47+
env:
48+
OUTPUT: CHANGELOG.md
49+
50+
- name: Commit CHANGELOG.md
51+
run: |
52+
git add CHANGELOG.md
53+
git commit -m "chore(release): Update CHANGELOG.md for ${{ steps.git-cliff.outputs.version }}"
54+
git push
55+
1756
prepare-release:
57+
name: Prepare release
58+
needs: changelog
59+
outputs:
60+
release_body: ${{ needs.changelog.outputs.release_body }}
61+
release_version: ${{ needs.changelog.outputs.release_version }}
1862
strategy:
1963
fail-fast: false
2064
matrix:
@@ -24,7 +68,9 @@ jobs:
2468
runs-on: ${{ matrix.platform.runs-on }}
2569
steps:
2670
- name: Checkout code
27-
uses: actions/checkout@v4
71+
uses: actions/checkout@v5
72+
with:
73+
ref: master
2874
- run: |
2975
git config --global user.name "${{ github.actor }}"
3076
git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
@@ -45,7 +91,9 @@ jobs:
4591
gpg-passphrase: MAVEN_GPG_PASSPHRASE
4692

4793
- name: Update development version
48-
uses: actions/checkout@v4
94+
uses: actions/checkout@v5
95+
with:
96+
ref: master
4997
env:
5098
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
5199
MAVEN_TOKEN: ${{ secrets.MAVEN_TOKEN }}
@@ -71,6 +119,9 @@ jobs:
71119
72120
build-windows:
73121
needs: prepare-release
122+
outputs:
123+
release_body: ${{ needs.prepare-release.outputs.release_body }}
124+
release_version: ${{ needs.prepare-release.outputs.release_version }}
74125
strategy:
75126
fail-fast: false
76127
matrix:
@@ -81,7 +132,7 @@ jobs:
81132
runs-on: ${{ matrix.platform.runs-on }}
82133
steps:
83134
- name: Checkout code
84-
uses: actions/checkout@v4
135+
uses: actions/checkout@v5
85136
with:
86137
fetch-tags: true
87138

@@ -125,7 +176,7 @@ jobs:
125176
runs-on: ${{ matrix.platform.runs-on }}
126177
steps:
127178
- name: Checkout code
128-
uses: actions/checkout@v4
179+
uses: actions/checkout@v5
129180
with:
130181
fetch-tags: true
131182

@@ -141,17 +192,6 @@ jobs:
141192
name: Prepare release build
142193
uses: ./.github/actions/prepare-linux
143194

144-
- name: Create Release # Create the release only once on Linux
145-
if: ${{ matrix.platform.name == 'linux_x86-64' }}
146-
uses: actions/create-release@v1
147-
env:
148-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149-
with:
150-
tag_name: ${{ steps.tag-selector.outputs.tag }}
151-
release_name: Release ${{ steps.tag-selector.outputs.tag }}
152-
draft: false
153-
prerelease: false
154-
155195
- id: maven-build
156196
name: Maven build
157197
uses: ./.github/actions/release
@@ -177,7 +217,7 @@ jobs:
177217
runs-on: ${{ matrix.platform.runs-on }}
178218
steps:
179219
- name: Checkout code
180-
uses: actions/checkout@v4
220+
uses: actions/checkout@v5
181221
with:
182222
fetch-tags: true
183223

@@ -215,4 +255,22 @@ jobs:
215255
maven-username: ${{ secrets.MAVEN_USERNAME }}
216256
maven-password: ${{ secrets.MAVEN_TOKEN }}
217257
maven-gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
218-
maven-gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
258+
maven-gpg-passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
259+
260+
publish-release:
261+
name: Publish GitHub release
262+
needs: [build-windows, build-linux, build-macos]
263+
runs-on: ubuntu-latest
264+
265+
steps:
266+
- name: Checkout code
267+
uses: actions/checkout@v5
268+
269+
- name: Publish
270+
env:
271+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
272+
run: |
273+
version="${{ needs.build-windows.outputs.release_version }}"
274+
body="${{ needs.build-windows.outputs.release_body }}"
275+
276+
gh release create $version -d -t "Release $version" -n "$body"

0 commit comments

Comments
 (0)