Skip to content

Commit 80e92a5

Browse files
committed
ci: refactor release process
1 parent 5a5048d commit 80e92a5

5 files changed

Lines changed: 234 additions & 8 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Create releases and tags
2+
on:
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch:
7+
8+
jobs:
9+
unreleased-prs-metadata:
10+
name: Get list of pending release pull requests
11+
permissions:
12+
pull-requests: read
13+
contents: read
14+
uses: equinor/radix-reusable-workflows/.github/workflows/template-unreleased-pr-metadata.yml@v1.0.2
15+
16+
release-pull-request:
17+
name: Release pull request
18+
needs:
19+
- unreleased-prs-metadata
20+
if: needs.unreleased-prs-metadata.outputs.unreleased-pull-request-count > 0
21+
strategy:
22+
matrix:
23+
pull-request-number: ${{ fromJson(needs.unreleased-prs-metadata.outputs.unreleased-pull-requests) }}
24+
permissions:
25+
pull-requests: write
26+
contents: read
27+
issues: write
28+
uses: equinor/radix-reusable-workflows/.github/workflows/template-create-release-from-pr.yml@v1.0.2
29+
with:
30+
pull-request-number: ${{ matrix.pull-request-number }}
31+
use-github-app-token: true
32+
github-app-id: ${{ vars.GH_APP_ID }}
33+
secrets:
34+
github-app-private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
35+

β€Ž.github/workflows/pr.yamlβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
jobs:
88
test:
99
runs-on: ubuntu-latest
10+
permissions:
11+
contents: read
1012
steps:
1113
- uses: actions/checkout@v4
1214

@@ -21,6 +23,8 @@ jobs:
2123
lint:
2224
name: Lint
2325
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
2428
steps:
2529
- uses: actions/checkout@v4
2630
with:
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Prepare release pull request
2+
on:
3+
push:
4+
tags:
5+
- '**'
6+
branches:
7+
- main
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}
12+
13+
jobs:
14+
prepare-release-pr:
15+
name: Prepare release pull request
16+
uses: equinor/radix-reusable-workflows/.github/workflows/template-prepare-release-pr.yml@v1.0.2
17+
permissions:
18+
contents: write
19+
pull-requests: write
20+
issues: write
21+
with:
22+
branch: main
23+
cliff-config-path: cliff.toml
24+
generate-pre-release-pr: false

β€ŽREADME.mdβ€Ž

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,36 @@
44

55
[Radix](https://www.radix.equinor.com) is a PaaS. This document is for Radix developers, or anyone interested in poking around..
66

7-
* `tag` in git repository (in `main` branch)
7+
## Development Process
88

9-
Run following command to set `tag` (with corresponding version)
10-
```
11-
git tag v1.0.0
12-
git push origin v1.0.0
13-
```
9+
The `radix-common` project follows a **trunk-based development** approach.
1410

15-
Want to contribute? Read our [contributing guideline](./contributing.md)
11+
### πŸ” Workflow
1612

17-
[How to handle security issues](./security.md)
13+
- **External contributors** should:
14+
- Fork the repository
15+
- Create a feature branch in their fork
16+
17+
- **Maintainers** may create feature branches directly in the main repository.
18+
19+
### βœ… Merging Changes
20+
21+
All changes must be merged into the `main` branch using **pull requests** with **squash commits**.
22+
23+
The squash commit message must follow the [Conventional Commits](https://www.conventionalcommits.org/en/about/) specification.
24+
25+
## Release Process
26+
27+
Merging a pull request into `main` triggers the **Prepare release pull request** workflow.
28+
This workflow analyzes the commit messages to determine whether the version number should be bumped β€” and if so, whether it's a major, minor, or patch change.
29+
30+
It then creates a pull request for releasing a new stable version (e.g. `1.2.3`):
31+
Merging this requests triggers the **Create releases and tags** workflow, which reads the version stored in `version.txt`, creates a GitHub release, and tags it accordingly.
32+
33+
## Contributing
34+
35+
Want to contribute? Read our [contributing guidelines](./CONTRIBUTING.md)
36+
37+
## Security
38+
39+
[How to handle security issues](./security.md)

β€Žcliff.tomlβ€Ž

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# git-cliff ~ configuration file
2+
# https://git-cliff.org/docs/configuration
3+
4+
5+
[changelog]
6+
# A Tera template to be rendered as the changelog's footer.
7+
# See https://keats.github.io/tera/docs/#introduction
8+
header = """
9+
# Changelog\n
10+
All notable changes to this project will be documented in this file.\n
11+
"""
12+
# A Tera template to be rendered for each release in the changelog.
13+
# See https://keats.github.io/tera/docs/#introduction
14+
body = """
15+
{%- macro remote_url() -%}
16+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
17+
{%- endmacro -%}
18+
19+
{% macro print_commit(commit) -%}
20+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
21+
{% if commit.breaking %}[**breaking**] {% endif %}\
22+
{{ commit.message | upper_first }} - \
23+
([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\
24+
{% if commit.remote.username %} by @{{ commit.remote.username }}{%- endif -%}
25+
{% if commit.remote.pr_number %} in \
26+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
27+
{%- endif %}
28+
{% endmacro -%}
29+
30+
{% if version %}\
31+
{% if previous.version %}\
32+
## [{{ version | trim_start_matches(pat="v") }}]\
33+
({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
34+
{% else %}\
35+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
36+
{% endif %}\
37+
{% else %}\
38+
## [unreleased]
39+
{% endif %}\
40+
41+
{% for group, commits in commits | group_by(attribute="group") %}
42+
### {{ group | striptags | trim | upper_first }}
43+
{% for commit in commits
44+
| filter(attribute="scope")
45+
| sort(attribute="scope") %}
46+
{{ self::print_commit(commit=commit) }}
47+
{%- endfor %}
48+
{% for commit in commits %}
49+
{%- if not commit.scope -%}
50+
{{ self::print_commit(commit=commit) }}
51+
{% endif -%}
52+
{% endfor -%}
53+
{% endfor -%}
54+
{%- if github -%}
55+
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
56+
## New Contributors ❀️
57+
{% endif %}\
58+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
59+
* @{{ contributor.username }} made their first contribution
60+
{%- if contributor.pr_number %} in \
61+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
62+
{%- endif %}
63+
{%- endfor -%}
64+
{%- endif %}
65+
66+
"""
67+
# A Tera template to be rendered as the changelog's footer.
68+
# See https://keats.github.io/tera/docs/#introduction
69+
footer = """
70+
<!-- generated by git-cliff -->
71+
"""
72+
# Remove leading and trailing whitespaces from the changelog's body.
73+
trim = true
74+
# Render body even when there are no releases to process.
75+
render_always = true
76+
# An array of regex based postprocessors to modify the changelog.
77+
postprocessors = [
78+
# Replace the placeholder <REPO> with a URL.
79+
#{ pattern = '<REPO>', replace = "https://github.com/orhun/git-cliff" },
80+
]
81+
# render body even when there are no releases to process
82+
# render_always = true
83+
# output file path
84+
# output = "test.md"
85+
86+
[git]
87+
# Parse commits according to the conventional commits specification.
88+
# See https://www.conventionalcommits.org
89+
conventional_commits = true
90+
# Exclude commits that do not match the conventional commits specification.
91+
filter_unconventional = true
92+
# Require all commits to be conventional.
93+
# Takes precedence over filter_unconventional.
94+
require_conventional = false
95+
# Split commits on newlines, treating each line as an individual commit.
96+
split_commits = false
97+
# An array of regex based parsers to modify commit messages prior to further processing.
98+
commit_preprocessors = [
99+
# Replace issue numbers with link templates to be updated in `changelog.postprocessors`.
100+
#{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
101+
# Check spelling of the commit message using https://github.com/crate-ci/typos.
102+
# If the spelling is incorrect, it will be fixed automatically.
103+
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
104+
]
105+
# Prevent commits that are breaking from being excluded by commit parsers.
106+
protect_breaking_commits = false
107+
# An array of regex based parsers for extracting data from the commit message.
108+
# Assigns commits to groups.
109+
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
110+
commit_parsers = [
111+
{ message = "^feat", group = "<!-- 0 -->πŸš€ Features" },
112+
{ message = "^fix", group = "<!-- 1 -->πŸ› Bug Fixes" },
113+
{ message = "^docs", group = "<!-- 3 -->πŸ“š Documentation" },
114+
{ message = "^perf", group = "<!-- 4 -->⚑ Performance" },
115+
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
116+
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
117+
{ message = "^test", group = "<!-- 6 -->πŸ§ͺ Testing" },
118+
{ message = "^chore\\(release\\): prepare for", skip = true },
119+
{ message = "^chore\\(deps.*\\)", skip = true },
120+
{ message = "^chore\\(pr\\)", skip = true },
121+
{ message = "^chore\\(pull\\)", skip = true },
122+
{ message = "^chore|^ci", group = "<!-- 7 -->βš™οΈ Miscellaneous Tasks" },
123+
{ body = ".*security", group = "<!-- 8 -->πŸ›‘οΈ Security" },
124+
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
125+
{ message = ".*", group = "<!-- 10 -->πŸ’Ό Other" },
126+
]
127+
# Exclude commits that are not matched by any commit parser.
128+
filter_commits = false
129+
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
130+
link_parsers = []
131+
# Include only the tags that belong to the current branch.
132+
use_branch_tags = false
133+
# Order releases topologically instead of chronologically.
134+
topo_order = false
135+
# Order releases topologically instead of chronologically.
136+
topo_order_commits = true
137+
# Order of commits in each group/release within the changelog.
138+
# Allowed values: newest, oldest
139+
sort_commits = "oldest"
140+
# Process submodules commits
141+
recurse_submodules = false

0 commit comments

Comments
Β (0)