Skip to content

Commit 96eafec

Browse files
committed
chore(ci): "Prepare release PR" Github workflow
1 parent 6fa9070 commit 96eafec

4 files changed

Lines changed: 198 additions & 3 deletions

File tree

.github/HOWTO.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
You can test GitHub Actions workflows locally using [`act`](https://nektosact.com/) and [Docker](https://www.docker.com/):
2+
3+
```shell
4+
act --container-architecture linux/amd64
5+
```

.github/cliff.toml

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 for each release in the changelog.
6+
# See https://keats.github.io/tera/docs/#introduction
7+
body = """\
8+
{% macro commit_ref(commit) %}\
9+
{% if get_env(name="CHANGELOG_MD", default="false") == "true" %}\
10+
[`{{ commit.id | truncate(length=7, end="") }}`](<REPO_URL>/commit/{{ commit.id }})\
11+
{% else %}\
12+
{{ commit.id | truncate(length=7, end="") }}\
13+
{% endif %}\
14+
{% endmacro %}\
15+
\
16+
{%if commits | length > 0 %}\
17+
{% if version %}\
18+
{% if version is matching("^\\d+\\.\\d+\\.\\d+-\\d+-\\d+$") %}\
19+
## {{ version | trim_start_matches(pat="v") }}\
20+
{% else %}\
21+
## {{ version }} - {{ timestamp | date(format="%Y-%m-%d") }}\
22+
{% endif %}\
23+
{% else %}\
24+
## [unreleased]\
25+
{% endif %}\
26+
{% endif %}\
27+
{% for group, commits in commits | group_by(attribute="group") %}
28+
29+
### {{ group | striptags | trim | upper_first }}
30+
{% for commit in commits %}
31+
- {% if commit.breaking %}[**BREAKING**] {% endif %}\
32+
{{ commit.message | upper_first }} ({{ self::commit_ref(commit=commit) }})\
33+
{% endfor %}\
34+
{% endfor %}
35+
{% if previous.version %}
36+
{% endif %}
37+
"""
38+
# Remove leading and trailing whitespaces from the changelog's body.
39+
trim = true
40+
# Render body even when there are no releases to process.
41+
render_always = true
42+
# An array of regex based postprocessors to modify the changelog.
43+
postprocessors = [
44+
{ pattern = '<REPO_URL>', replace = "https://github.com/FoenixRetro/f256-superbasic" },
45+
]
46+
# render body even when there are no releases to process
47+
# render_always = true
48+
# output file path
49+
# output = "test.md"
50+
51+
[git]
52+
# Parse commits according to the conventional commits specification.
53+
# See https://www.conventionalcommits.org
54+
conventional_commits = true
55+
# Exclude commits that do not match the conventional commits specification.
56+
filter_unconventional = true
57+
# Require all commits to be conventional.
58+
# Takes precedence over filter_unconventional.
59+
require_conventional = false
60+
# Split commits on newlines, treating each line as an individual commit.
61+
split_commits = false
62+
# An array of regex based parsers to modify commit messages prior to further processing.
63+
commit_preprocessors = [
64+
# Replace issue/PR numbers with link templates, to be updated in `changelog.postprocessors`.
65+
{ pattern = '#([0-9]+)', replace = "[#${1}](<REPO_URL>/issues/${1})" },
66+
# Check spelling of the commit message using https://github.com/crate-ci/typos.
67+
# If the spelling is incorrect, it will be fixed automatically.
68+
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
69+
]
70+
# Prevent commits that are breaking from being excluded by commit parsers.
71+
protect_breaking_commits = false
72+
# An array of regex based parsers for extracting data from the commit message.
73+
# Assigns commits to groups.
74+
# Optionally sets the commit's scope and can decide to exclude commits from further processing.
75+
commit_parsers = [
76+
{ message = "^feat", group = "<!-- 0 -->Features" },
77+
{ message = "^fix", group = "<!-- 1 -->Bug fixes" },
78+
{ message = "^refmanual", group = "<!-- 3 -->Documentation" },
79+
{ message = "^perf", group = "<!-- 4 -->Performance" },
80+
{ message = "^chore:\\s+new release\\s*$", skip = true },
81+
{ message = ".*", group = "<!-- 5 -->Internal" },
82+
]
83+
# Exclude commits that are not matched by any commit parser.
84+
filter_commits = false
85+
# An array of link parsers for extracting external references, and turning them into URLs, using regex.
86+
link_parsers = []
87+
# Include only the tags that belong to the current branch.
88+
use_branch_tags = false
89+
# Order releases topologically instead of chronologically.
90+
topo_order = false
91+
# Order releases topologically instead of chronologically.
92+
topo_order_commits = true
93+
# Order of commits in each group/release within the changelog.
94+
# Allowed values: newest, oldest
95+
sort_commits = "oldest"
96+
# Process submodules commits
97+
recurse_submodules = false
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
name: Prepare release PR
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
prepare-release-pr:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0 # Need full history for changelog
19+
20+
- name: Install dependencies
21+
run: |
22+
sudo apt-get update
23+
sudo apt-get install -y \
24+
make \
25+
python3 python3-pip
26+
27+
- name: Install git-cliff
28+
run: pip install git-cliff
29+
30+
- name: Determine release version
31+
id: version
32+
run: |
33+
BASE_VERSION=$(cd source && make -B baseversion)
34+
DATE=$(TZ="America/Chicago" date +'%Y-%m-%d')
35+
36+
git fetch --tags
37+
COUNT=$(git tag --list "${BASE_VERSION}.${DATE}*" | wc -l)
38+
if [ "$COUNT" -gt 0 ]; then
39+
VERSION="${BASE_VERSION}.${DATE}.$((COUNT+1))"
40+
else
41+
VERSION="${BASE_VERSION}.${DATE}"
42+
fi
43+
44+
echo "$VERSION" > VERSION
45+
echo "version=$VERSION" >> $GITHUB_OUTPUT
46+
47+
- name: Generate changelog
48+
run: |
49+
CHANGELOG_MD=true git cliff --config .github/cliff.toml \
50+
--tag ${{ steps.version.outputs.version }} \
51+
--output CHANGELOG.md
52+
53+
- name: Generate changelog preview
54+
id: changelog_preview
55+
run: |
56+
{
57+
echo 'output<<EOF'
58+
git cliff --config .github/cliff.toml \
59+
--tag ${{ steps.version.outputs.version }} \
60+
--unreleased
61+
echo 'EOF'
62+
} >> $GITHUB_OUTPUT
63+
64+
- name: Create or update release PR
65+
uses: peter-evans/create-pull-request@v6
66+
with:
67+
branch: release/next
68+
delete-branch: true
69+
commit-message: 'chore(release): v${{ steps.version.outputs.version }}'
70+
title: 'Release v${{ steps.version.outputs.version }}'
71+
body: >
72+
This PR was created by the [prepare-release-pr](/${{ github.repository }}/blob/main/.github/workflows/prepare-release-pr.yml)
73+
GitHub action. When you're ready to release, simply merge it — the corresponding GitHub release will be
74+
published automatically.
75+
76+
77+
If you're not ready yet, no problem. This PR will continue to update as you push changes to `main`,
78+
and you can merge it whenever you're ready.
79+
80+
81+
# Release notes
82+
83+
${{ steps.changelog_preview.outputs.output }}
84+
labels: release
85+
token: ${{ secrets.GITHUB_TOKEN }}

source/Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ else
1515
include ../documents/common.make
1616
endif
1717
#
18-
# Current version. (In Beta from 01/03/23)
18+
# Current version
1919
#
20-
VERSION = 1
20+
MAJOR_VERSION = 1
21+
MINOR_VERSION = 1
2122

2223
HARDWARE = 0 # 0 = F256
2324
HARDWARE_GEN ?= 1 # 1 = J/K, 2 = J2/K2
@@ -162,7 +163,14 @@ prelim:
162163
python $(SCRIPTDIR)makebuild.py $(MODULES)
163164
python $(SCRIPTDIR)tokens.py
164165
python $(SCRIPTDIR)constants.py
165-
python $(SCRIPTDIR)timestamp.py $(VERSION)
166+
python $(SCRIPTDIR)timestamp.py $(MAJOR_VERSION)
167+
168+
#
169+
# Print base version to console
170+
#
171+
baseversion:
172+
@echo $(MAJOR_VERSION).$(MINOR_VERSION)
173+
166174
#
167175
# Create a working release.
168176
#

0 commit comments

Comments
 (0)