Skip to content

Commit bea0230

Browse files
author
sevastian.zhukov
committed
Assemble changelog only by the script executing
1 parent 8322e43 commit bea0230

File tree

3 files changed

+24
-67
lines changed

3 files changed

+24
-67
lines changed

.github/workflows/assemble_changelog.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

changelog/README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ If you have implemented several features or bugfixes you should describe all of
2626
You can choose any name for your changelog files because the GitHub action will rename files in
2727
`changelog/unreleased/features` and `changelog/unreleased/bugfixes` directories to `${PR_NUMBER}.md` when you open a PR.
2828

29-
Every push to the main or release branch Assemble changelog GitHub action will be executed:
30-
31-
* collect all files from `changelog/unreleased`
32-
* assemble the changelog like:
29+
To view the changelog for the current branch, run the command `python3 scripts/changelog/assemble_changelog.py`.
30+
This script will collect all the files in the `changelog/unreleased` directory and generate a changelog in the following format:
3331

3432
```
3533
#### Features
@@ -47,11 +45,11 @@ Every push to the main or release branch Assemble changelog GitHub action will b
4745
Some other changes
4846
```
4947

50-
* write the changelog to the `changelog/unreleased/CHANGELOG.md` file
48+
To view the changelog for the android auto project, run the command `python3 scripts/changelog/assemble_changelog.py --auto`.
5149

5250
Every release the release train app will:
5351

54-
* get changelog from `changelog/unreleased/CHANGELOG.md` file
52+
* assemble the changelog by the script `python3 scripts/changelog/assemble_changelog.py`
5553
* add information about dependencies and compile changelog like:
5654
```
5755
## Mapbox Navigation SDK 1.1.1 - 13 December, 2022
Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
import argparse
12
import os
23

3-
import git
4-
54

65
def get_changes(path):
76
changes = ''
@@ -25,36 +24,27 @@ def get_changes(path):
2524
return changes.strip()
2625

2726

28-
bugfixes = get_changes('changelog/unreleased/bugfixes/')
29-
features = get_changes('changelog/unreleased/features/')
30-
issues = get_changes('changelog/unreleased/issues/')
31-
other = get_changes('changelog/unreleased/other/')
32-
33-
changelog = '#### Features\n' + features + '\n\n' + \
34-
'#### Bug fixes and improvements\n' + bugfixes + '\n\n' + \
35-
'#### Known issues :warning:\n' + issues + '\n\n' + \
36-
'#### Other changes\n' + other
37-
38-
old_changelog = open('changelog/unreleased/CHANGELOG.md', 'r').read()
27+
parser = argparse.ArgumentParser(description='Assemble changelog')
28+
parser.add_argument('--auto', action='store_true', help='To assemble android auto changelog')
29+
args = parser.parse_args()
3930

40-
if changelog != old_changelog:
41-
open('changelog/unreleased/CHANGELOG.md', 'w').write(changelog)
42-
repository = git.Repo('.')
43-
repository.git.add('changelog/unreleased')
44-
repository.index.commit('Assemble changelog file [skip ci]')
45-
repository.remotes.origin.push().raise_if_error()
31+
if args.auto:
32+
auto_bugfixes = get_changes('libnavui-androidauto/changelog/unreleased/bugfixes/')
33+
auto_features = get_changes('libnavui-androidauto/changelog/unreleased/features/')
4634

47-
auto_bugfixes = get_changes('libnavui-androidauto/changelog/unreleased/bugfixes/')
48-
auto_features = get_changes('libnavui-androidauto/changelog/unreleased/features/')
35+
auto_changelog = '#### Features\n' + auto_features + '\n\n' + \
36+
'#### Bug fixes and improvements\n' + auto_bugfixes
4937

50-
auto_changelog = '#### Features\n' + auto_features + '\n\n' + \
51-
'#### Bug fixes and improvements\n' + auto_bugfixes
38+
print(auto_changelog)
39+
else:
40+
bugfixes = get_changes('changelog/unreleased/bugfixes/')
41+
features = get_changes('changelog/unreleased/features/')
42+
issues = get_changes('changelog/unreleased/issues/')
43+
other = get_changes('changelog/unreleased/other/')
5244

53-
auto_old_changelog = open('libnavui-androidauto/changelog/unreleased/CHANGELOG.md', 'r').read()
45+
changelog = '#### Features\n' + features + '\n\n' + \
46+
'#### Bug fixes and improvements\n' + bugfixes + '\n\n' + \
47+
'#### Known issues :warning:\n' + issues + '\n\n' + \
48+
'#### Other changes\n' + other
5449

55-
if auto_changelog != auto_old_changelog:
56-
open('libnavui-androidauto/changelog/unreleased/CHANGELOG.md', 'w').write(auto_changelog)
57-
repository = git.Repo('.')
58-
repository.git.add('libnavui-androidauto/changelog/unreleased')
59-
repository.index.commit('Assemble auto changelog file [skip ci]')
60-
repository.remotes.origin.push().raise_if_error()
50+
print(changelog)

0 commit comments

Comments
 (0)