Skip to content

Commit

Permalink
[ci] Added changelog.py that does not depend on taichi (taichi-dev#2649)
Browse files Browse the repository at this point in the history
* [python] Added changelog.py that does not depend on taichi

* Auto Format

* resolve conversation

* Auto Format

* minor fixes

* moved make_changelog to misc folder

* Auto Format

* test ti changelog in presubmit ci tests

* revert changes

Co-authored-by: Taichi Gardener <[email protected]>
  • Loading branch information
Leonz5288 and taichi-gardener authored Aug 9, 2021
1 parent 67d6bba commit 10da3cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 35 deletions.
9 changes: 7 additions & 2 deletions python/taichi/make_changelog.py → misc/make_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

def load_pr_tags():
this_dir = os.path.dirname(os.path.abspath(__file__))
json_path = os.path.join(this_dir, '../../misc/prtags.json')
json_path = os.path.join(this_dir, 'prtags.json')
details = {}
with open(json_path) as f:
details = json.load(f)
Expand Down Expand Up @@ -78,5 +78,10 @@ def format(c):

if __name__ == '__main__':
ver = sys.argv[1] if len(sys.argv) > 1 else 'master'
res = main(ver)
repo = sys.argv[2] if len(sys.argv) > 2 else '.'
save = sys.argv[3] if len(sys.argv) > 3 else False
res = main(ver, repo)
if save:
with open('../python/taichi/CHANGELOG.md', 'w') as f:
f.write(res)
print(res)
3 changes: 2 additions & 1 deletion python/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ def build(project_name):
'{} -m pip install --user --upgrade twine setuptools wheel'.format(
get_python_executable()))

os.system(f'{get_python_executable()} -m taichi changelog --save')
os.system(
f'{get_python_executable()} ../misc/make_changelog.py master ../ True')

if get_os_name() == 'linux':
os.system(
Expand Down
35 changes: 3 additions & 32 deletions python/taichi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,38 +223,9 @@ def example(self, arguments: list = sys.argv[2:]):
@register
def changelog(self, arguments: list = sys.argv[2:]):
"""Display changelog of current version"""
parser = argparse.ArgumentParser(
prog='ti changelog', description=f"{self.changelog.__doc__}")
import taichi as ti
if ti.is_release():
args = parser.parse_args(arguments)
changelog_md = os.path.join(ti.package_root(), 'CHANGELOG.md')
with open(changelog_md) as f:
print(f.read())
else:
parser.add_argument(
'version',
nargs='?',
type=str,
default='master',
help="A version (tag) that git can use to compare diff with")
parser.add_argument(
'-s',
'--save',
action='store_true',
help="Save changelog to CHANGELOG.md instead of print to stdout"
)
args = parser.parse_args(arguments)

from . import make_changelog
res = make_changelog.main(args.version, _ti_core.get_repo_dir())
if args.save:
changelog_md = os.path.join(_ti_core.get_repo_dir(),
'CHANGELOG.md')
with open(changelog_md, 'w') as f:
f.write(res)
else:
print(res)
changelog_md = os.path.join(ti.package_root(), 'CHANGELOG.md')
with open(changelog_md) as f:
print(f.read())

@register
def release(self, arguments: list = sys.argv[2:]):
Expand Down

0 comments on commit 10da3cb

Please sign in to comment.