From 1d12f8dc5d8630f74972abce81317ab2abf4eed1 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 23 May 2023 13:54:11 -0400 Subject: [PATCH 01/43] Initial Commit --- .../pipeline_release/README.md | 1 + .../pipeline_release/__main__.py | 108 ++++++++++++++++++ .../pipeline_release/setup.py | 31 +++++ 3 files changed, 140 insertions(+) create mode 100644 scripts/pipeline-release/pipeline_release/README.md create mode 100644 scripts/pipeline-release/pipeline_release/__main__.py create mode 100644 scripts/pipeline-release/pipeline_release/setup.py diff --git a/scripts/pipeline-release/pipeline_release/README.md b/scripts/pipeline-release/pipeline_release/README.md new file mode 100644 index 00000000..8054ed4e --- /dev/null +++ b/scripts/pipeline-release/pipeline_release/README.md @@ -0,0 +1 @@ +Pipeline release is a script to package addons in the pipeline repo. \ No newline at end of file diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py new file mode 100644 index 00000000..73251d9a --- /dev/null +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -0,0 +1,108 @@ +# ***** BEGIN GPL LICENSE BLOCK ***** +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# ***** END GPL LICENCE BLOCK ***** +# +# (c) 2021, Blender Foundation + + +import argparse +import sys +import os +import subprocess +import argparse +import re +from pathlib import Path +from typing import List +import shutil + +def subprocess_capture_command(command:str): + output = subprocess.run(command.split(' '), capture_output=True, encoding="utf-8") + return output + +# Command line arguments. +def cancel_program(message: str): + print(message) + sys.exit(0) + +def clean_str(string:str): + return string.replace('\n', '').replace("'", "").replace('"','') + +def find_commit_via_message(folder:Path, commit_message:str): + last_version_commit = None + commits_in_folder =subprocess_capture_command(f'git log --format=format:"%H" {folder}/*').stdout.split('\n') # TODO Fix this so it ouputs all commits not just latest + # Find Last Version + for commit in commits_in_folder: + commit = clean_str(commit) + commit_msg = subprocess_capture_command(f'git log --format=%B -n 1 {commit}') + if commit_message in commit_msg.stdout: + last_version_commit = commit + print(last_version_commit) + if last_version_commit is None: + print("no commit found") + return + + commits_since_lastest_release = subprocess_capture_command(f'git log {last_version_commit} --format=format:"%H"').stdout.split('\n') + new_commit_hashes_in_folder = [] + + for commit in commits_in_folder : + if any(commit in x for x in commits_since_lastest_release): + new_commit_hashes_in_folder.append(clean_str(commit)) + + change_log = '' + for commit in new_commit_hashes_in_folder: + change_log += (commit) + return get_commit_msg(change_log) + +def get_commit_msg(commit:str): + output = subprocess_capture_command(f'git log --format=%B -n 1 {commit}').stdout + return output + + +def addon_folder_exec(addon_to_package:Path, version:str): + #bump_addon_version(addon_to_package) # TODO DEBUG + # TODO COMMIT CHANGE AND BUMP VERSION BEFORE GENERATING CHANGELOG & PACKAGE + name = addon_to_package.name + change_log = find_commit_via_message(addon_to_package, '[Blender Kitsu] Improve `Publish Edit as Revision` UI and Feedback') + output_zips_path = Path(__file__).parent.parent.parent.parent #TODO CHANGE THIS + shutil.make_archive(output_zips_path.joinpath(f"{name}{version}addon_test_pkg"), 'zip' ,addon_to_package) + return change_log + +def bump_addon_version(addon_to_package): + init_file = addon_to_package.joinpath("__init__.py") + with open(init_file, 'r') as file: + content = file.read() + content = content.replace("'version :'", "'version' : (2, 0, 1)") + with open(init_file, 'w') as file: + file.write(content) + +def main() -> int: + import sys + # Parse arguments. + main_dir = Path(__file__).parent.parent.parent.parent + addon_folder = main_dir.joinpath(main_dir, "scripts-blender/addons") + print(addon_folder) + # PREPARE LOOP + addon_to_package = addon_folder.joinpath(addon_folder, "blender_kitsu") + # GENERATE COMMIT LOG AND VRESION BUMP + change_log = addon_folder_exec(addon_to_package, "1.0.1") + print("OPENING CHANGE LOG") + print(change_log) + print("DONE SCRIPT") + return 0 + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/scripts/pipeline-release/pipeline_release/setup.py b/scripts/pipeline-release/pipeline_release/setup.py new file mode 100644 index 00000000..6ddf65d5 --- /dev/null +++ b/scripts/pipeline-release/pipeline_release/setup.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +"""The setup script for pipeline-release.""" + +from setuptools import setup + +with open("README.md") as readme_file: + readme = readme_file.read() + + +setup( + author="Nick Alberelli", + author_email="nick@blender.org", + python_requires=">=3.5", + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Natural Language :: English", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + ], + description="Command line tool to perform recursive crawl blend files from the console", + long_description=readme, + keywords="pipeline_release", + name="pipeline_release", + packages=["pipeline_release", "pipeline_release.default_scripts",], + version="0.1.1", + entry_points={"console_scripts": ["pipeline_release = pipeline_release.__main__:main"]}, +) -- 2.30.2 From f7ef403563196d9542f8c76b21ba03246d82ee0b Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 23 May 2023 14:45:58 -0400 Subject: [PATCH 02/43] Release System: Fix Changelog Generation Logic --- .../pipeline_release/__main__.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 73251d9a..964fce64 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -55,28 +55,28 @@ def find_commit_via_message(folder:Path, commit_message:str): print("no commit found") return - commits_since_lastest_release = subprocess_capture_command(f'git log {last_version_commit} --format=format:"%H"').stdout.split('\n') + commits_since_lastest_release = subprocess_capture_command(f'git rev-list {clean_str(last_version_commit)[0:9]}^..HEAD').stdout.split('\n') new_commit_hashes_in_folder = [] for commit in commits_in_folder : - if any(commit in x for x in commits_since_lastest_release): + if any(clean_str(commit) in x for x in commits_since_lastest_release): new_commit_hashes_in_folder.append(clean_str(commit)) change_log = '' for commit in new_commit_hashes_in_folder: - change_log += (commit) - return get_commit_msg(change_log) + change_log += get_commit_msg(commit) + return change_log def get_commit_msg(commit:str): output = subprocess_capture_command(f'git log --format=%B -n 1 {commit}').stdout return output -def addon_folder_exec(addon_to_package:Path, version:str): +def create_new_addon_release(addon_to_package:Path, commit_msg_to_find:str, version:str,): #bump_addon_version(addon_to_package) # TODO DEBUG # TODO COMMIT CHANGE AND BUMP VERSION BEFORE GENERATING CHANGELOG & PACKAGE name = addon_to_package.name - change_log = find_commit_via_message(addon_to_package, '[Blender Kitsu] Improve `Publish Edit as Revision` UI and Feedback') + change_log = find_commit_via_message(addon_to_package,commit_msg_to_find) output_zips_path = Path(__file__).parent.parent.parent.parent #TODO CHANGE THIS shutil.make_archive(output_zips_path.joinpath(f"{name}{version}addon_test_pkg"), 'zip' ,addon_to_package) return change_log @@ -98,10 +98,9 @@ def main() -> int: # PREPARE LOOP addon_to_package = addon_folder.joinpath(addon_folder, "blender_kitsu") # GENERATE COMMIT LOG AND VRESION BUMP - change_log = addon_folder_exec(addon_to_package, "1.0.1") - print("OPENING CHANGE LOG") + change_log = create_new_addon_release(addon_to_package,'Restructure repo content' , "1.0.1", ) + print("CREATED NEW CHANGE LOG") print(change_log) - print("DONE SCRIPT") return 0 if __name__ == "__main__": -- 2.30.2 From fecb700f3650ef1cfc2cd7328bf70f04a42ede2c Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 23 May 2023 15:41:36 -0400 Subject: [PATCH 03/43] Release System: Commit Version Bump --- .../pipeline_release/__main__.py | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 964fce64..c6f1d7e6 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -73,21 +73,33 @@ def get_commit_msg(commit:str): def create_new_addon_release(addon_to_package:Path, commit_msg_to_find:str, version:str,): - #bump_addon_version(addon_to_package) # TODO DEBUG - # TODO COMMIT CHANGE AND BUMP VERSION BEFORE GENERATING CHANGELOG & PACKAGE + file_path = bump_addon_version(addon_to_package, version) # TODO DEBUG + subprocess_capture_command(f'git stage {file_path}') + subprocess_capture_command(f'git commit -m "Version Bump: {addon_to_package.name} {version}"') name = addon_to_package.name change_log = find_commit_via_message(addon_to_package,commit_msg_to_find) - output_zips_path = Path(__file__).parent.parent.parent.parent #TODO CHANGE THIS + output_zips_path = Path(__file__).parent.parent.parent.parent.parent #TODO CHANGE THIS shutil.make_archive(output_zips_path.joinpath(f"{name}{version}addon_test_pkg"), 'zip' ,addon_to_package) return change_log -def bump_addon_version(addon_to_package): +def bump_addon_version(addon_to_package, version:str): + num = None + str_find = ' "version":' + repl_str = f' "version": ({version.replace(".",", ")}),\n' init_file = addon_to_package.joinpath("__init__.py") - with open(init_file, 'r') as file: - content = file.read() - content = content.replace("'version :'", "'version' : (2, 0, 1)") - with open(init_file, 'w') as file: - file.write(content) + with open(init_file,'r') as myFile: + for num, line in enumerate(myFile, 1): + if str_find in line and line[0] != "#": + line = num + break + + file = open(init_file,) + lines = file.readlines() + lines[num-1] = repl_str + out = open(init_file, 'w') + out.writelines(lines) + out.close() + return init_file def main() -> int: import sys @@ -98,9 +110,9 @@ def main() -> int: # PREPARE LOOP addon_to_package = addon_folder.joinpath(addon_folder, "blender_kitsu") # GENERATE COMMIT LOG AND VRESION BUMP - change_log = create_new_addon_release(addon_to_package,'Restructure repo content' , "1.0.1", ) + change_log = create_new_addon_release(addon_to_package,'Restructure repo content' , "0.1.1", ) print("CREATED NEW CHANGE LOG") - print(change_log) + #print(change_log) return 0 if __name__ == "__main__": -- 2.30.2 From 2007152dd40074d7bb91c3dc36a77ede6d4e42ee Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 23 May 2023 15:50:13 -0400 Subject: [PATCH 04/43] Release System: Fix Commit Version Bump Syntax --- scripts/pipeline-release/pipeline_release/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index c6f1d7e6..e1cee7cb 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -75,7 +75,7 @@ def get_commit_msg(commit:str): def create_new_addon_release(addon_to_package:Path, commit_msg_to_find:str, version:str,): file_path = bump_addon_version(addon_to_package, version) # TODO DEBUG subprocess_capture_command(f'git stage {file_path}') - subprocess_capture_command(f'git commit -m "Version Bump: {addon_to_package.name} {version}"') + subprocess.run(['git', 'commit', '-m' , f"Version Bump {addon_to_package.name} {version}"], capture_output=True, encoding="utf-8") name = addon_to_package.name change_log = find_commit_via_message(addon_to_package,commit_msg_to_find) output_zips_path = Path(__file__).parent.parent.parent.parent.parent #TODO CHANGE THIS -- 2.30.2 From 7548204a0cd305651c768e2435ae5965870c7f1d Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 23 May 2023 15:58:12 -0400 Subject: [PATCH 05/43] Release System: un-stage changes before version bump --- scripts/pipeline-release/pipeline_release/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index e1cee7cb..28a38a8b 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -73,7 +73,8 @@ def get_commit_msg(commit:str): def create_new_addon_release(addon_to_package:Path, commit_msg_to_find:str, version:str,): - file_path = bump_addon_version(addon_to_package, version) # TODO DEBUG + file_path = bump_addon_version(addon_to_package, version) + subprocess_capture_command(f'git reset') #Unstage any changes user may have staged earlier so we only commit version bump subprocess_capture_command(f'git stage {file_path}') subprocess.run(['git', 'commit', '-m' , f"Version Bump {addon_to_package.name} {version}"], capture_output=True, encoding="utf-8") name = addon_to_package.name -- 2.30.2 From 4343fd4a9ca51a819c541c41b011572366ae716d Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 23 May 2023 16:28:03 -0400 Subject: [PATCH 06/43] Release System: Add Automatic Version Bump Logic --- .../pipeline_release/__main__.py | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 28a38a8b..b1edf268 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -55,7 +55,7 @@ def find_commit_via_message(folder:Path, commit_message:str): print("no commit found") return - commits_since_lastest_release = subprocess_capture_command(f'git rev-list {clean_str(last_version_commit)[0:9]}^..HEAD').stdout.split('\n') + commits_since_lastest_release = subprocess_capture_command(f'git rev-list {clean_str(last_version_commit)[0:9]}..HEAD').stdout.split('\n') new_commit_hashes_in_folder = [] for commit in commits_in_folder : @@ -72,35 +72,42 @@ def get_commit_msg(commit:str): return output -def create_new_addon_release(addon_to_package:Path, commit_msg_to_find:str, version:str,): - file_path = bump_addon_version(addon_to_package, version) +def create_new_addon_release(addon_to_package:Path, commit_msg_to_find='Version Bump:', major_version=False): + file_path, version = bump_addon_version(addon_to_package, major_version) subprocess_capture_command(f'git reset') #Unstage any changes user may have staged earlier so we only commit version bump subprocess_capture_command(f'git stage {file_path}') - subprocess.run(['git', 'commit', '-m' , f"Version Bump {addon_to_package.name} {version}"], capture_output=True, encoding="utf-8") + subprocess.run(['git', 'commit', '-m' , f"Version Bump: {addon_to_package.name} {version}"], capture_output=True, encoding="utf-8") name = addon_to_package.name change_log = find_commit_via_message(addon_to_package,commit_msg_to_find) - output_zips_path = Path(__file__).parent.parent.parent.parent.parent #TODO CHANGE THIS - shutil.make_archive(output_zips_path.joinpath(f"{name}{version}addon_test_pkg"), 'zip' ,addon_to_package) + output_zips_path = Path(__file__).parent.parent.parent.parent #TODO CHANGE THIS + shutil.make_archive(output_zips_path.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) return change_log -def bump_addon_version(addon_to_package, version:str): +def bump_addon_version(addon_to_package, major_version): num = None str_find = ' "version":' - repl_str = f' "version": ({version.replace(".",", ")}),\n' + init_file = addon_to_package.joinpath("__init__.py") with open(init_file,'r') as myFile: for num, line in enumerate(myFile, 1): if str_find in line and line[0] != "#": line = num break - file = open(init_file,) lines = file.readlines() + version = lines[num-1].split('(')[1].split(')')[0] + + # Bump either last digit for minor versions and second last digit for major + if major_version: + version = version[:-4] + str(int(version[3])+1) +version[-3:] + else: + version = version[:-1] + str(int(version[-1])+1) + repl_str = f' "version": ({version}),\n' lines[num-1] = repl_str out = open(init_file, 'w') out.writelines(lines) out.close() - return init_file + return init_file, version.replace(', ','.') def main() -> int: import sys @@ -111,9 +118,9 @@ def main() -> int: # PREPARE LOOP addon_to_package = addon_folder.joinpath(addon_folder, "blender_kitsu") # GENERATE COMMIT LOG AND VRESION BUMP - change_log = create_new_addon_release(addon_to_package,'Restructure repo content' , "0.1.1", ) + change_log = create_new_addon_release(addon_to_package, 'Restructure repo content') print("CREATED NEW CHANGE LOG") - #print(change_log) + print(change_log) return 0 if __name__ == "__main__": -- 2.30.2 From 45a1ca4df1d8071f040cb0c39b76d05bc75f43e6 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 23 May 2023 16:42:12 -0400 Subject: [PATCH 07/43] Release System: Run on all addons & add debug comments --- .../pipeline_release/__main__.py | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index b1edf268..f9092ea7 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -74,8 +74,9 @@ def get_commit_msg(commit:str): def create_new_addon_release(addon_to_package:Path, commit_msg_to_find='Version Bump:', major_version=False): file_path, version = bump_addon_version(addon_to_package, major_version) - subprocess_capture_command(f'git reset') #Unstage any changes user may have staged earlier so we only commit version bump - subprocess_capture_command(f'git stage {file_path}') + # COMMENTED THESE OUT FOR CONVIENCE + #subprocess_capture_command(f'git reset') #Unstage any changes user may have staged earlier so we only commit version bump + #subprocess_capture_command(f'git stage {file_path}') subprocess.run(['git', 'commit', '-m' , f"Version Bump: {addon_to_package.name} {version}"], capture_output=True, encoding="utf-8") name = addon_to_package.name change_log = find_commit_via_message(addon_to_package,commit_msg_to_find) @@ -84,24 +85,26 @@ def create_new_addon_release(addon_to_package:Path, commit_msg_to_find='Version return change_log def bump_addon_version(addon_to_package, major_version): + # DEBUG THIS LOGIC DOESN"T WORK ON ALL FOLDERS. num = None - str_find = ' "version":' - + str_find = '"version":' init_file = addon_to_package.joinpath("__init__.py") with open(init_file,'r') as myFile: for num, line in enumerate(myFile, 1): if str_find in line and line[0] != "#": - line = num + line = num # THIS IS RETURNING THE LAST LINE OF THE FILE + # TODO DEBUG WHY THIS BREAKS ON GEO NODE SHAPEKEYS MODULE break file = open(init_file,) lines = file.readlines() - version = lines[num-1].split('(')[1].split(')')[0] + #version = lines[num-1].split('(')[1].split(')')[0] # Bump either last digit for minor versions and second last digit for major - if major_version: - version = version[:-4] + str(int(version[3])+1) +version[-3:] - else: - version = version[:-1] + str(int(version[-1])+1) + # if major_version: + # version = version[:-4] + str(int(version[3])+1) +version[-3:] + # else: + # version = version[:-1] + str(int(version[-1])+1) + version = '9, 9, 9,' # TEMPORARY FOR TESTING repl_str = f' "version": ({version}),\n' lines[num-1] = repl_str out = open(init_file, 'w') @@ -115,12 +118,12 @@ def main() -> int: main_dir = Path(__file__).parent.parent.parent.parent addon_folder = main_dir.joinpath(main_dir, "scripts-blender/addons") print(addon_folder) - # PREPARE LOOP - addon_to_package = addon_folder.joinpath(addon_folder, "blender_kitsu") - # GENERATE COMMIT LOG AND VRESION BUMP - change_log = create_new_addon_release(addon_to_package, 'Restructure repo content') - print("CREATED NEW CHANGE LOG") - print(change_log) + addon_dirs = [name for name in os.listdir(addon_folder) if os.path.isdir(addon_folder.joinpath(name))] + for dir in addon_dirs: + addon_to_package = addon_folder.joinpath(addon_folder, dir) + change_log = create_new_addon_release(addon_to_package, 'Restructure repo content') + print(addon_dirs) + print("DONE") return 0 if __name__ == "__main__": -- 2.30.2 From dc754faf66e4cb48fad0e5892d33537309d607b3 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 24 May 2023 10:50:25 -0400 Subject: [PATCH 08/43] Release System: Fix Version Bump Logic --- .../pipeline_release/__main__.py | 72 +++++++++---------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index f9092ea7..46f36df5 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -19,12 +19,9 @@ # (c) 2021, Blender Foundation -import argparse import sys import os import subprocess -import argparse -import re from pathlib import Path from typing import List import shutil @@ -50,9 +47,7 @@ def find_commit_via_message(folder:Path, commit_message:str): commit_msg = subprocess_capture_command(f'git log --format=%B -n 1 {commit}') if commit_message in commit_msg.stdout: last_version_commit = commit - print(last_version_commit) if last_version_commit is None: - print("no commit found") return commits_since_lastest_release = subprocess_capture_command(f'git rev-list {clean_str(last_version_commit)[0:9]}..HEAD').stdout.split('\n') @@ -73,57 +68,60 @@ def get_commit_msg(commit:str): def create_new_addon_release(addon_to_package:Path, commit_msg_to_find='Version Bump:', major_version=False): - file_path, version = bump_addon_version(addon_to_package, major_version) - # COMMENTED THESE OUT FOR CONVIENCE - #subprocess_capture_command(f'git reset') #Unstage any changes user may have staged earlier so we only commit version bump - #subprocess_capture_command(f'git stage {file_path}') - subprocess.run(['git', 'commit', '-m' , f"Version Bump: {addon_to_package.name} {version}"], capture_output=True, encoding="utf-8") - name = addon_to_package.name change_log = find_commit_via_message(addon_to_package,commit_msg_to_find) - output_zips_path = Path(__file__).parent.parent.parent.parent #TODO CHANGE THIS - shutil.make_archive(output_zips_path.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) + if change_log: + file_path, version = bump_addon_version(addon_to_package, major_version) + subprocess_capture_command(f'git reset') #Unstage any changes user may have staged earlier so we only commit version bump + subprocess_capture_command(f'git stage {file_path}') + subprocess.run(['git', 'commit', '-m' , f"Version Bump: {addon_to_package.name} {version}"], capture_output=True, encoding="utf-8") + print(f"Version Bump: {addon_to_package.name} {version}") + name = addon_to_package.name + change_log = find_commit_via_message(addon_to_package,commit_msg_to_find) + output_zips_path = Path(__file__).parent.parent.parent.parent #TODO CHANGE THIS + shutil.make_archive(output_zips_path.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) + change_log_file = open(addon_to_package.joinpath("TEST_CHANGELOG.MD"), 'w') + change_log_file.writelines(change_log) + change_log_file.close() + else: + print(f"No New Version: {addon_to_package.name}") return change_log +def find_version_number(version_line:str, major_version): + version = version_line.split('(')[1].split(')')[0] + #Bump either last digit for minor versions and second last digit for major + if major_version: + new_version = version[:-4] + str(int(version[3])+1) +version[-3:] + else: + new_version = version[:-1] + str(int(version[-1])+1) + return new_version + def bump_addon_version(addon_to_package, major_version): - # DEBUG THIS LOGIC DOESN"T WORK ON ALL FOLDERS. - num = None - str_find = '"version":' + version_line = None + str_find = "version" init_file = addon_to_package.joinpath("__init__.py") with open(init_file,'r') as myFile: - for num, line in enumerate(myFile, 1): - if str_find in line and line[0] != "#": - line = num # THIS IS RETURNING THE LAST LINE OF THE FILE - # TODO DEBUG WHY THIS BREAKS ON GEO NODE SHAPEKEYS MODULE - break + for num, line in enumerate(myFile): + if str_find in line and "(" in line and line[0] != "#": + version_line = num + break #Use first line found + file = open(init_file,) lines = file.readlines() - #version = lines[num-1].split('(')[1].split(')')[0] - - # Bump either last digit for minor versions and second last digit for major - # if major_version: - # version = version[:-4] + str(int(version[3])+1) +version[-3:] - # else: - # version = version[:-1] + str(int(version[-1])+1) - version = '9, 9, 9,' # TEMPORARY FOR TESTING + version = find_version_number(lines[version_line], major_version) repl_str = f' "version": ({version}),\n' - lines[num-1] = repl_str + lines[version_line] = repl_str out = open(init_file, 'w') out.writelines(lines) out.close() - return init_file, version.replace(', ','.') + return init_file, version.replace(', ','.').replace(', ','.') def main() -> int: - import sys - # Parse arguments. main_dir = Path(__file__).parent.parent.parent.parent addon_folder = main_dir.joinpath(main_dir, "scripts-blender/addons") - print(addon_folder) addon_dirs = [name for name in os.listdir(addon_folder) if os.path.isdir(addon_folder.joinpath(name))] for dir in addon_dirs: addon_to_package = addon_folder.joinpath(addon_folder, dir) - change_log = create_new_addon_release(addon_to_package, 'Restructure repo content') - print(addon_dirs) - print("DONE") + create_new_addon_release(addon_to_package, 'Restructure repo content') return 0 if __name__ == "__main__": -- 2.30.2 From 0eda1363666d36ce59d2433fcc7980a9e09874f4 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 24 May 2023 11:55:48 -0400 Subject: [PATCH 09/43] Release System: Add command line arguments --- .../pipeline_release/__main__.py | 43 ++++++++++++++++--- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 46f36df5..baa57407 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -25,6 +25,29 @@ import subprocess from pathlib import Path from typing import List import shutil +import argparse + + +parser = argparse.ArgumentParser() +parser.add_argument( + "-m", + "--msg", + help="Find commit with this message and use it as the last version.", + type=str, +) +parser.add_argument( + "-n", + "--name", + help="Only update the addon corrisponding to this name(s).", + type=str, +) + +parser.add_argument( + "-b", + "--bump", + help="Bump the major version number, otherwise bump minor version number", + action="store_true", +) def subprocess_capture_command(command:str): output = subprocess.run(command.split(' '), capture_output=True, encoding="utf-8") @@ -40,7 +63,7 @@ def clean_str(string:str): def find_commit_via_message(folder:Path, commit_message:str): last_version_commit = None - commits_in_folder =subprocess_capture_command(f'git log --format=format:"%H" {folder}/*').stdout.split('\n') # TODO Fix this so it ouputs all commits not just latest + commits_in_folder =subprocess_capture_command(f'git log --format=format:"%H" {folder}/*').stdout.split('\n') # Find Last Version for commit in commits_in_folder: commit = clean_str(commit) @@ -67,8 +90,10 @@ def get_commit_msg(commit:str): return output -def create_new_addon_release(addon_to_package:Path, commit_msg_to_find='Version Bump:', major_version=False): - change_log = find_commit_via_message(addon_to_package,commit_msg_to_find) +def create_new_addon_release(addon_to_package:Path, commit_msg_to_find:str, major_version=False): + # Check is NONE in function incase user passes no argument + commit_msg = 'Version Bump:' if commit_msg_to_find is None else commit_msg_to_find + change_log = find_commit_via_message(addon_to_package,commit_msg) if change_log: file_path, version = bump_addon_version(addon_to_package, major_version) subprocess_capture_command(f'git reset') #Unstage any changes user may have staged earlier so we only commit version bump @@ -76,7 +101,7 @@ def create_new_addon_release(addon_to_package:Path, commit_msg_to_find='Version subprocess.run(['git', 'commit', '-m' , f"Version Bump: {addon_to_package.name} {version}"], capture_output=True, encoding="utf-8") print(f"Version Bump: {addon_to_package.name} {version}") name = addon_to_package.name - change_log = find_commit_via_message(addon_to_package,commit_msg_to_find) + change_log = find_commit_via_message(addon_to_package,commit_msg) output_zips_path = Path(__file__).parent.parent.parent.parent #TODO CHANGE THIS shutil.make_archive(output_zips_path.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) change_log_file = open(addon_to_package.joinpath("TEST_CHANGELOG.MD"), 'w') @@ -113,15 +138,21 @@ def bump_addon_version(addon_to_package, major_version): out = open(init_file, 'w') out.writelines(lines) out.close() - return init_file, version.replace(', ','.').replace(', ','.') + return init_file, version.replace(', ','.').replace(',','.') def main() -> int: + args = parser.parse_args() main_dir = Path(__file__).parent.parent.parent.parent + msg = args.msg + bump = args.bump + user_names = args.name addon_folder = main_dir.joinpath(main_dir, "scripts-blender/addons") addon_dirs = [name for name in os.listdir(addon_folder) if os.path.isdir(addon_folder.joinpath(name))] + if user_names: + addon_dirs = [name for name in os.listdir(addon_folder) if os.path.isdir(addon_folder.joinpath(name)) and name in user_names] for dir in addon_dirs: addon_to_package = addon_folder.joinpath(addon_folder, dir) - create_new_addon_release(addon_to_package, 'Restructure repo content') + create_new_addon_release(addon_to_package, msg, bump) return 0 if __name__ == "__main__": -- 2.30.2 From db8c3aa0a0ce3e893fcd8f7e82caedd1d79ab959 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 24 May 2023 11:56:19 -0400 Subject: [PATCH 10/43] Cleanup: Addon init version numbers --- scripts-blender/addons/easy_weights/__init__.py | 2 +- scripts-blender/addons/lattice_magic/__init__.py | 2 +- scripts-blender/addons/lighting_overrider/__init__.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts-blender/addons/easy_weights/__init__.py b/scripts-blender/addons/easy_weights/__init__.py index 18c29258..8d8c4e75 100644 --- a/scripts-blender/addons/easy_weights/__init__.py +++ b/scripts-blender/addons/easy_weights/__init__.py @@ -27,7 +27,7 @@ import importlib bl_info = { "name": "Easy Weight", "author": "Demeter Dzadik", - "version": (1, 0), + "version": (0, 1, 0), "blender": (2, 90, 0), "location": "Weight Paint > Weights > Easy Weight", "description": "Operators to make weight painting easier.", diff --git a/scripts-blender/addons/lattice_magic/__init__.py b/scripts-blender/addons/lattice_magic/__init__.py index e199de76..da7369b4 100644 --- a/scripts-blender/addons/lattice_magic/__init__.py +++ b/scripts-blender/addons/lattice_magic/__init__.py @@ -16,7 +16,7 @@ bl_info = { "name": "Lattice Magic", "author": "Demeter Dzadik", - "version": (1,0), + "version": (0, 1, 0), "blender": (2, 90, 0), "location": "View3D > Sidebar > Lattice Magic", "description": "Various Lattice-based tools to smear or adjust geometry.", diff --git a/scripts-blender/addons/lighting_overrider/__init__.py b/scripts-blender/addons/lighting_overrider/__init__.py index 1ca6d880..daec86fb 100644 --- a/scripts-blender/addons/lighting_overrider/__init__.py +++ b/scripts-blender/addons/lighting_overrider/__init__.py @@ -6,7 +6,7 @@ from . import templates, json_io, execution, ui, override_picker bl_info = { "name": "Lighting Overrider", "author": "Simon Thommes", - "version": (1,0), + "version": (0, 1, 0), "blender": (3, 0, 0), "location": "3D Viewport > Sidebar > Overrides", "description": "Tool for the Blender Studio to create, manage and store local python overrides of linked data on a shot and sequence level.", -- 2.30.2 From b7baec498d1c67edfa73859ecff6e587c5070d77 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 24 May 2023 12:28:17 -0400 Subject: [PATCH 11/43] Release System: Update README --- scripts/pipeline-release/README.md | 37 +++++++++++++++++++ .../pipeline_release/README.md | 1 - 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 scripts/pipeline-release/README.md delete mode 100644 scripts/pipeline-release/pipeline_release/README.md diff --git a/scripts/pipeline-release/README.md b/scripts/pipeline-release/README.md new file mode 100644 index 00000000..b9535a0a --- /dev/null +++ b/scripts/pipeline-release/README.md @@ -0,0 +1,37 @@ +Pipeline release is a script to package addons in the pipeline repo. + +## Prerequisite +In order to use this tool you need: +- Python 3.5+ +- GIT + +## Run without Installation +This folder contains a command line tool that doesn't require installation to use properly. This tool doesn't require installation to be run. To run `pipeline_release` without installation follow the steps below. +1. Clone this repository with `git clone https://projects.blender.org/studio/blender-studio-pipeline.git` +2. Run `cd blender-studio-pipeline/scripts/pipeline_release` to enter directory +3. Run program with `python pipeline_release /my-folder/` + + +## Installation (OPTIONAL) +Download or clone this repository. This repository is a command line tool that can be installed with the python packaging manager. Installation is an optional step only intended for advanced users. +This script does the following (follow this if you want to do this manually or on another platform): +Steps 3 and 5 are specific to linux, similar steps to gain root/administration privileges are avaliable to [Windows](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/jj717276(v=ws.11)) and [Mac](https://support.apple.com/en-ca/guide/terminal/apd5b0b6259-a7d4-4435-947d-0dff528912ba/mac) users. + +1. Clone this repository with `git clone https://projects.blender.org/studio/blender-studio-pipeline.git` +2. Run `cd blender-studio-pipeline/scripts/pipeline_release` to enter directory +3. Gain root access with `su` or equivalent command to grant permission to modify the system. +4. Install with `pip install .` +5. Type `exit` to log out of root user or equivalent command. +5. Run with `pipeline_release /my-folder/` +6. Get help with `pipeline_release -h` + + +## How to get started + + +| Command | Description | +| ----------- | ----------- | +| -b, --bump|Bump the major version number, otherwise bump minor version| +| -n --name| Name of addon(s) folder to update. All addons will be checked if flag is not provided| +| -m --msg| Title of commit to consider basis of latest release| +| -h, --help| show the above help message and exit| diff --git a/scripts/pipeline-release/pipeline_release/README.md b/scripts/pipeline-release/pipeline_release/README.md deleted file mode 100644 index 8054ed4e..00000000 --- a/scripts/pipeline-release/pipeline_release/README.md +++ /dev/null @@ -1 +0,0 @@ -Pipeline release is a script to package addons in the pipeline repo. \ No newline at end of file -- 2.30.2 From 13319e759df6da9d1f4206e59ff1b595ab724029 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 24 May 2023 12:29:34 -0400 Subject: [PATCH 12/43] Release System: move Setup.py to correct folder for installation --- scripts/pipeline-release/{pipeline_release => }/setup.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/pipeline-release/{pipeline_release => }/setup.py (100%) diff --git a/scripts/pipeline-release/pipeline_release/setup.py b/scripts/pipeline-release/setup.py similarity index 100% rename from scripts/pipeline-release/pipeline_release/setup.py rename to scripts/pipeline-release/setup.py -- 2.30.2 From 888d55ed42504330c981ab579a36edf95ff33035 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 24 May 2023 12:42:05 -0400 Subject: [PATCH 13/43] Release System: Update README --- scripts/pipeline-release/README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/pipeline-release/README.md b/scripts/pipeline-release/README.md index b9535a0a..df73617e 100644 --- a/scripts/pipeline-release/README.md +++ b/scripts/pipeline-release/README.md @@ -28,10 +28,17 @@ Steps 3 and 5 are specific to linux, similar steps to gain root/administration p ## How to get started - | Command | Description | | ----------- | ----------- | | -b, --bump|Bump the major version number, otherwise bump minor version| | -n --name| Name of addon(s) folder to update. All addons will be checked if flag is not provided| -| -m --msg| Title of commit to consider basis of latest release| +| -m --msg| Title of commit to consider basis of latest release, otherwise the last commit called 'Version Bump:' will be used| | -h, --help| show the above help message and exit| + + +| Action | Command | +| ----------- | ----------- | +|Create a new minor version if available of all addons|`pipeline_release`| +|Create a new major version if available of all addons|`pipeline_release -b`| +|Only check if addon has this name(s) |`pipeline_release -n "blender_kitsu, blender_svn"`| +|Find a commit that matches this message and uses as version basis |`pipeline_release -m "Commit MSG"`| \ No newline at end of file -- 2.30.2 From 9a0b09501cff1c775195061c91b3fc48d8be115c Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 30 May 2023 21:42:50 -0400 Subject: [PATCH 14/43] Release System: get commit message as oneliner - Retrieve commit message oneliner - Save each message in a new line --- scripts/pipeline-release/pipeline_release/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index baa57407..810c464a 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -86,7 +86,7 @@ def find_commit_via_message(folder:Path, commit_message:str): return change_log def get_commit_msg(commit:str): - output = subprocess_capture_command(f'git log --format=%B -n 1 {commit}').stdout + output = f"{subprocess_capture_command(f'git log --pretty=format:%s -n 1 {commit}').stdout}\n" return output -- 2.30.2 From f5c06d8cdab982bdbee06d7854c0d99ef43b1751 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 30 May 2023 21:45:35 -0400 Subject: [PATCH 15/43] Release System: Save Addon zips in `dist` folder - Add function to safely get folders - Make a new folder per addon name --- .../pipeline-release/pipeline_release/__main__.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 810c464a..83918cf1 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -88,12 +88,19 @@ def find_commit_via_message(folder:Path, commit_message:str): def get_commit_msg(commit:str): output = f"{subprocess_capture_command(f'git log --pretty=format:%s -n 1 {commit}').stdout}\n" return output + +def get_directory(repo_root:Path, folder_name:str): + path = repo_root.joinpath(folder_name) + if not os.path.exists(path): + os.makedirs(path) + return path -def create_new_addon_release(addon_to_package:Path, commit_msg_to_find:str, major_version=False): +def create_new_addon_zip(addon_to_package:Path, commit_msg_to_find:str, major_version=False): # Check is NONE in function incase user passes no argument commit_msg = 'Version Bump:' if commit_msg_to_find is None else commit_msg_to_find change_log = find_commit_via_message(addon_to_package,commit_msg) + output_zips_path = get_directory(Path(__file__).parent.parent.parent.parent, "dist") if change_log: file_path, version = bump_addon_version(addon_to_package, major_version) subprocess_capture_command(f'git reset') #Unstage any changes user may have staged earlier so we only commit version bump @@ -102,8 +109,8 @@ def create_new_addon_release(addon_to_package:Path, commit_msg_to_find:str, majo print(f"Version Bump: {addon_to_package.name} {version}") name = addon_to_package.name change_log = find_commit_via_message(addon_to_package,commit_msg) - output_zips_path = Path(__file__).parent.parent.parent.parent #TODO CHANGE THIS - shutil.make_archive(output_zips_path.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) + addon_output_dir = get_directory(output_zips_path, addon_to_package.name) + shutil.make_archive(addon_output_dir.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) change_log_file = open(addon_to_package.joinpath("TEST_CHANGELOG.MD"), 'w') change_log_file.writelines(change_log) change_log_file.close() @@ -152,7 +159,7 @@ def main() -> int: addon_dirs = [name for name in os.listdir(addon_folder) if os.path.isdir(addon_folder.joinpath(name)) and name in user_names] for dir in addon_dirs: addon_to_package = addon_folder.joinpath(addon_folder, dir) - create_new_addon_release(addon_to_package, msg, bump) + create_new_addon_zip(addon_to_package, msg, bump) return 0 if __name__ == "__main__": -- 2.30.2 From 4b10e321f56fab5b778468253abb340489d30e06 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Tue, 30 May 2023 23:05:37 -0400 Subject: [PATCH 16/43] Release System: generate Changelog with categories - Borrow code from https://github.com/pawamoy/git-changelog/blob/master/src/git_changelog/commit.py - Parse commit for type - Create entries in changelog per type - Add category for uncategorized changes --- .../pipeline_release/__main__.py | 103 +++++++++++++++++- 1 file changed, 98 insertions(+), 5 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 83918cf1..93d3a109 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -26,6 +26,76 @@ from pathlib import Path from typing import List import shutil import argparse +import re +from typing import Pattern + + +# BORROWED FROM https://github.com/pawamoy/git-changelog/blob/master/src/git_changelog/commit.py +TYPES: dict[str, str] = { + "add": "Added", + "fix": "Fixed", + "change": "Changed", + "remove": "Removed", + "merge": "Merged", + "doc": "Documented", +} + +TYPE_REGEX: Pattern = re.compile(r"^(?P(%s))" % "|".join(TYPES.keys()), re.I) +BREAK_REGEX: Pattern = re.compile( + r"^break(s|ing changes?)?[ :].+$", + re.I | re.MULTILINE, +) +DEFAULT_RENDER: list[str] = [ + TYPES["add"], + TYPES["fix"], + TYPES["change"], + TYPES["remove"], +] + + +def check_minor(commit_type: str) -> bool: + """Tell if this commit is worth a minor bump. + Arguments: + commit_type: The commit type. + Returns: + Whether it's a minor commit. + """ + return commit_type == TYPES["add"] + +def check_major( commit_message: str) -> bool: + """Tell if this commit is worth a major bump. + Arguments: + commit_message: The commit message. + Returns: + Whether it's a major commit. + """ + return bool(BREAK_REGEX.search(commit_message)) + + +def parse_type(commit_subject: str) -> str: + """Parse the type of the commit given its subject. + Arguments: + commit_subject: The commit message subject. + Returns: + The commit type. + """ + type_match = TYPE_REGEX.match(commit_subject) + if type_match: + return TYPES.get(type_match.groupdict()["type"].lower(), "") + return "" + + +def parse_commit(message) -> dict[str, str | bool]: # noqa: D102 + commit_type = parse_type(message) + is_major = check_major(message) + is_patch = not check_minor + + return { + "message": message, + "type": commit_type, + "is_major": is_major, + "is_patch": is_patch, + } parser = argparse.ArgumentParser() @@ -61,6 +131,17 @@ def cancel_program(message: str): def clean_str(string:str): return string.replace('\n', '').replace("'", "").replace('"','') +def get_changelog_category_msgs(changelog_messages, title, key): + entry = '' + if not any(commit for commit in changelog_messages if commit["type"] == key): + return entry + entry += f"# {title} \n \n" + for commit in changelog_messages: + if commit["type"] == key: + entry += commit["message"] + return entry + + def find_commit_via_message(folder:Path, commit_message:str): last_version_commit = None commits_in_folder =subprocess_capture_command(f'git log --format=format:"%H" {folder}/*').stdout.split('\n') @@ -80,10 +161,22 @@ def find_commit_via_message(folder:Path, commit_message:str): if any(clean_str(commit) in x for x in commits_since_lastest_release): new_commit_hashes_in_folder.append(clean_str(commit)) - change_log = '' + change_log_entry = '' + changelog_messages = [] for commit in new_commit_hashes_in_folder: - change_log += get_commit_msg(commit) - return change_log + message = get_commit_msg(commit) + changelog_messages.append(parse_commit(message)) + + change_log_entry += get_changelog_category_msgs(changelog_messages, 'BUG FIXES', 'Fixed') + change_log_entry += get_changelog_category_msgs(changelog_messages, 'ADDED', 'Fixed') + change_log_entry += get_changelog_category_msgs(changelog_messages, 'CHANGED', 'Fixed') + change_log_entry += get_changelog_category_msgs(changelog_messages, 'REMOVED', 'Fixed') + + change_log_entry += "# UN-CATEGORIZED \n" + for commit in changelog_messages: + if commit["message"] not in change_log_entry: + change_log_entry += f"- {commit['message']}" + return change_log_entry #TODO Seperate versions in changelog with date of version number def get_commit_msg(commit:str): output = f"{subprocess_capture_command(f'git log --pretty=format:%s -n 1 {commit}').stdout}\n" @@ -97,7 +190,7 @@ def get_directory(repo_root:Path, folder_name:str): def create_new_addon_zip(addon_to_package:Path, commit_msg_to_find:str, major_version=False): - # Check is NONE in function incase user passes no argument + # TODO Check is NONE in function incase user passes no argument commit_msg = 'Version Bump:' if commit_msg_to_find is None else commit_msg_to_find change_log = find_commit_via_message(addon_to_package,commit_msg) output_zips_path = get_directory(Path(__file__).parent.parent.parent.parent, "dist") @@ -112,7 +205,7 @@ def create_new_addon_zip(addon_to_package:Path, commit_msg_to_find:str, major_ve addon_output_dir = get_directory(output_zips_path, addon_to_package.name) shutil.make_archive(addon_output_dir.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) change_log_file = open(addon_to_package.joinpath("TEST_CHANGELOG.MD"), 'w') - change_log_file.writelines(change_log) + change_log_file.writelines(change_log) # TODO Write to existing changelog file change_log_file.close() else: print(f"No New Version: {addon_to_package.name}") -- 2.30.2 From e3f1ce826b43d7a26fd291151c7e4279298cabbf Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 07:44:13 -0400 Subject: [PATCH 17/43] Release System: Save Checksum next to archive - Generate checksum next to "zipped" archive - Save changelog early so it goes into archive - add write_file() function --- .../pipeline_release/__main__.py | 31 +++++++++++++++---- 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 93d3a109..e12131bb 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -18,7 +18,8 @@ # # (c) 2021, Blender Foundation - +import zipfile +import hashlib import sys import os import subprocess @@ -187,7 +188,24 @@ def get_directory(repo_root:Path, folder_name:str): if not os.path.exists(path): os.makedirs(path) return path - + +def generate_checksum(path_to_archive:str): + archive = zipfile.ZipFile(path_to_archive) + blocksize = 1024**2 #1M chunks + checksum = hashlib.new('sha256') + for fname in archive.namelist(): + entry = archive.open(fname) + while True: + block = entry.read(blocksize) + if not block: + break + checksum.update(block) + return checksum + +def write_file(file_path:Path, content): + file = open(file_path, 'w') + file.writelines(content) + file.close() def create_new_addon_zip(addon_to_package:Path, commit_msg_to_find:str, major_version=False): # TODO Check is NONE in function incase user passes no argument @@ -203,10 +221,11 @@ def create_new_addon_zip(addon_to_package:Path, commit_msg_to_find:str, major_ve name = addon_to_package.name change_log = find_commit_via_message(addon_to_package,commit_msg) addon_output_dir = get_directory(output_zips_path, addon_to_package.name) - shutil.make_archive(addon_output_dir.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) - change_log_file = open(addon_to_package.joinpath("TEST_CHANGELOG.MD"), 'w') - change_log_file.writelines(change_log) # TODO Write to existing changelog file - change_log_file.close() + change_log_file = write_file(addon_to_package.joinpath("TEST_CHANGELOG.MD"), change_log) + zipped_addon = shutil.make_archive(addon_output_dir.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) + checksum = generate_checksum(zipped_addon) + checksum_file = write_file(addon_output_dir.joinpath(f"{name}_{version}.sha256"), f"{checksum.hexdigest()} {name}_{version}.zip") + else: print(f"No New Version: {addon_to_package.name}") return change_log -- 2.30.2 From f4644fea656eee2aa5bae59b49852a935222ea97 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 07:48:48 -0400 Subject: [PATCH 18/43] Release System: standardize addon bl_info commas --- scripts-blender/addons/anim_cupboard/__init__.py | 16 ++++++++-------- scripts-blender/addons/bone_gizmos/__init__.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts-blender/addons/anim_cupboard/__init__.py b/scripts-blender/addons/anim_cupboard/__init__.py index 8a2b3be2..a8ea90a1 100644 --- a/scripts-blender/addons/anim_cupboard/__init__.py +++ b/scripts-blender/addons/anim_cupboard/__init__.py @@ -10,14 +10,14 @@ from . import easy_constraints from . import warn_about_broken_libraries bl_info = { - 'name' : "Animation Cupboard" - ,'author': "Demeter Dzadik" - ,'version' : (0, 0, 1) - ,'blender' : (3, 2, 0) - ,'description' : "Tools to improve animation workflows" - ,'location': "Various" - ,'category': 'Animation' - # ,'doc_url' : "https://gitlab.com/blender/CloudRig/" + 'name' : "Animation Cupboard", + 'author': "Demeter Dzadik", + 'version' : (0, 0, 1), + 'blender' : (3, 2, 0), + 'description' : "Tools to improve animation workflows", + 'location': "Various", + 'category': 'Animation', + # 'doc_url' : "https://gitlab.com/blender/CloudRig/", } modules = ( diff --git a/scripts-blender/addons/bone_gizmos/__init__.py b/scripts-blender/addons/bone_gizmos/__init__.py index aabdd138..db35a056 100644 --- a/scripts-blender/addons/bone_gizmos/__init__.py +++ b/scripts-blender/addons/bone_gizmos/__init__.py @@ -10,14 +10,14 @@ from bpy.props import FloatProperty, IntProperty from bpy.types import AddonPreferences bl_info = { - 'name' : "Bone Gizmos" - ,'author': "Demeter Dzadik" - ,'version' : (0, 0, 1) - ,'blender' : (3, 0, 0) - ,'description' : "Bone Gizmos for better armature interaction" - ,'location': "Properties->Bone->Viewport Display->Custom Gizmo" - ,'category': 'Rigging' - # ,'doc_url' : "https://gitlab.com/blender/CloudRig/" + 'name' : "Bone Gizmos", + 'author': "Demeter Dzadik", + 'version' : (0, 0, 1), + 'blender' : (3, 0, 0), + 'description' : "Bone Gizmos for better armature interaction", + 'location': "Properties->Bone->Viewport Display->Custom Gizmo", + 'category': 'Rigging', + # 'doc_url' : "https://gitlab.com/blender/CloudRig/", } modules = ( -- 2.30.2 From c4b002f036bd8febc7c766f8bcee847ea0500918 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 08:09:02 -0400 Subject: [PATCH 19/43] Release System: Changelog Entries include date and version --- .../pipeline_release/__main__.py | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index e12131bb..269bbeba 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -29,6 +29,7 @@ import shutil import argparse import re from typing import Pattern +import datetime # BORROWED FROM https://github.com/pawamoy/git-changelog/blob/master/src/git_changelog/commit.py @@ -136,14 +137,31 @@ def get_changelog_category_msgs(changelog_messages, title, key): entry = '' if not any(commit for commit in changelog_messages if commit["type"] == key): return entry - entry += f"# {title} \n \n" + entry += f"## {title} \n \n" for commit in changelog_messages: if commit["type"] == key: entry += commit["message"] return entry +def generate_change_log_entry(new_commit_hashes_in_folder, version): + change_log_entry = f'# {version} - {datetime.date.today()} \n \n' + changelog_messages = [] + for commit in new_commit_hashes_in_folder: + message = get_commit_msg(commit) + changelog_messages.append(parse_commit(message)) -def find_commit_via_message(folder:Path, commit_message:str): + change_log_entry += get_changelog_category_msgs(changelog_messages, 'BUG FIXES', 'Fixed') + change_log_entry += get_changelog_category_msgs(changelog_messages, 'ADDED', 'Fixed') + change_log_entry += get_changelog_category_msgs(changelog_messages, 'CHANGED', 'Fixed') + change_log_entry += get_changelog_category_msgs(changelog_messages, 'REMOVED', 'Fixed') + + change_log_entry += "## UN-CATEGORIZED \n" + for commit in changelog_messages: + if commit["message"] not in change_log_entry: + change_log_entry += f"- {commit['message']}" + return change_log_entry #TODO + +def get_commits_in_folder(folder:Path, commit_message:str): last_version_commit = None commits_in_folder =subprocess_capture_command(f'git log --format=format:"%H" {folder}/*').stdout.split('\n') # Find Last Version @@ -161,23 +179,8 @@ def find_commit_via_message(folder:Path, commit_message:str): for commit in commits_in_folder : if any(clean_str(commit) in x for x in commits_since_lastest_release): new_commit_hashes_in_folder.append(clean_str(commit)) + return new_commit_hashes_in_folder - change_log_entry = '' - changelog_messages = [] - for commit in new_commit_hashes_in_folder: - message = get_commit_msg(commit) - changelog_messages.append(parse_commit(message)) - - change_log_entry += get_changelog_category_msgs(changelog_messages, 'BUG FIXES', 'Fixed') - change_log_entry += get_changelog_category_msgs(changelog_messages, 'ADDED', 'Fixed') - change_log_entry += get_changelog_category_msgs(changelog_messages, 'CHANGED', 'Fixed') - change_log_entry += get_changelog_category_msgs(changelog_messages, 'REMOVED', 'Fixed') - - change_log_entry += "# UN-CATEGORIZED \n" - for commit in changelog_messages: - if commit["message"] not in change_log_entry: - change_log_entry += f"- {commit['message']}" - return change_log_entry #TODO Seperate versions in changelog with date of version number def get_commit_msg(commit:str): output = f"{subprocess_capture_command(f'git log --pretty=format:%s -n 1 {commit}').stdout}\n" @@ -210,16 +213,16 @@ def write_file(file_path:Path, content): def create_new_addon_zip(addon_to_package:Path, commit_msg_to_find:str, major_version=False): # TODO Check is NONE in function incase user passes no argument commit_msg = 'Version Bump:' if commit_msg_to_find is None else commit_msg_to_find - change_log = find_commit_via_message(addon_to_package,commit_msg) + commits_in_folder = get_commits_in_folder(addon_to_package,commit_msg) output_zips_path = get_directory(Path(__file__).parent.parent.parent.parent, "dist") - if change_log: + if commits_in_folder: file_path, version = bump_addon_version(addon_to_package, major_version) + change_log = generate_change_log_entry(commits_in_folder, version) subprocess_capture_command(f'git reset') #Unstage any changes user may have staged earlier so we only commit version bump subprocess_capture_command(f'git stage {file_path}') subprocess.run(['git', 'commit', '-m' , f"Version Bump: {addon_to_package.name} {version}"], capture_output=True, encoding="utf-8") print(f"Version Bump: {addon_to_package.name} {version}") name = addon_to_package.name - change_log = find_commit_via_message(addon_to_package,commit_msg) addon_output_dir = get_directory(output_zips_path, addon_to_package.name) change_log_file = write_file(addon_to_package.joinpath("TEST_CHANGELOG.MD"), change_log) zipped_addon = shutil.make_archive(addon_output_dir.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) @@ -227,8 +230,7 @@ def create_new_addon_zip(addon_to_package:Path, commit_msg_to_find:str, major_ve checksum_file = write_file(addon_output_dir.joinpath(f"{name}_{version}.sha256"), f"{checksum.hexdigest()} {name}_{version}.zip") else: - print(f"No New Version: {addon_to_package.name}") - return change_log + print(f"No New Version: {addon_to_package.name}") def find_version_number(version_line:str, major_version): version = version_line.split('(')[1].split(')')[0] -- 2.30.2 From fab1b2dc7d60c45c4e7a5b37aa73760d107936dd Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 08:52:27 -0400 Subject: [PATCH 20/43] Release System: Write Changelog to existing file --- .../pipeline_release/__main__.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 269bbeba..9b1ed355 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -159,7 +159,8 @@ def generate_change_log_entry(new_commit_hashes_in_folder, version): for commit in changelog_messages: if commit["message"] not in change_log_entry: change_log_entry += f"- {commit['message']}" - return change_log_entry #TODO + change_log_entry += "\n" + return change_log_entry def get_commits_in_folder(folder:Path, commit_message:str): last_version_commit = None @@ -210,6 +211,18 @@ def write_file(file_path:Path, content): file.writelines(content) file.close() +def write_changelog_file(file_path:Path, content): + if file_path.exists(): + dummy_file = str(file_path._str) + '.bak' + with open(file_path, 'r') as read_obj, open(dummy_file, 'w') as write_obj: + write_obj.write(content) + for line in read_obj: + write_obj.write(line) + os.remove(file_path) + os.rename(dummy_file, file_path) + else: + write_file(file_path, content) + def create_new_addon_zip(addon_to_package:Path, commit_msg_to_find:str, major_version=False): # TODO Check is NONE in function incase user passes no argument commit_msg = 'Version Bump:' if commit_msg_to_find is None else commit_msg_to_find @@ -224,7 +237,7 @@ def create_new_addon_zip(addon_to_package:Path, commit_msg_to_find:str, major_ve print(f"Version Bump: {addon_to_package.name} {version}") name = addon_to_package.name addon_output_dir = get_directory(output_zips_path, addon_to_package.name) - change_log_file = write_file(addon_to_package.joinpath("TEST_CHANGELOG.MD"), change_log) + change_log_file = write_changelog_file(addon_to_package.joinpath("CHANGELOG.MD"), change_log) zipped_addon = shutil.make_archive(addon_output_dir.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) checksum = generate_checksum(zipped_addon) checksum_file = write_file(addon_output_dir.joinpath(f"{name}_{version}.sha256"), f"{checksum.hexdigest()} {name}_{version}.zip") -- 2.30.2 From 6d91399e77728aa1bfdb000f8ffa8a8cab3a2bf8 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 10:49:15 -0400 Subject: [PATCH 21/43] Release System: Enforce Black Formatting --- .../pipeline_release/__main__.py | 177 ++++++++++++------ 1 file changed, 115 insertions(+), 62 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 9b1ed355..173b263a 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -25,7 +25,7 @@ import os import subprocess from pathlib import Path from typing import List -import shutil +import shutil import argparse import re from typing import Pattern @@ -64,7 +64,8 @@ def check_minor(commit_type: str) -> bool: """ return commit_type == TYPES["add"] -def check_major( commit_message: str) -> bool: + +def check_major(commit_message: str) -> bool: """Tell if this commit is worth a major bump. Arguments: commit_message: The commit message. @@ -86,10 +87,10 @@ def parse_type(commit_subject: str) -> str: return TYPES.get(type_match.groupdict()["type"].lower(), "") return "" - + def parse_commit(message) -> dict[str, str | bool]: # noqa: D102 commit_type = parse_type(message) - is_major = check_major(message) + is_major = check_major(message) is_patch = not check_minor return { @@ -121,17 +122,21 @@ parser.add_argument( action="store_true", ) -def subprocess_capture_command(command:str): + +def subprocess_capture_command(command: str): output = subprocess.run(command.split(' '), capture_output=True, encoding="utf-8") return output + # Command line arguments. def cancel_program(message: str): print(message) sys.exit(0) -def clean_str(string:str): - return string.replace('\n', '').replace("'", "").replace('"','') + +def clean_str(string: str): + return string.replace('\n', '').replace("'", "").replace('"', '') + def get_changelog_category_msgs(changelog_messages, title, key): entry = '' @@ -143,6 +148,7 @@ def get_changelog_category_msgs(changelog_messages, title, key): entry += commit["message"] return entry + def generate_change_log_entry(new_commit_hashes_in_folder, version): change_log_entry = f'# {version} - {datetime.date.today()} \n \n' changelog_messages = [] @@ -150,21 +156,32 @@ def generate_change_log_entry(new_commit_hashes_in_folder, version): message = get_commit_msg(commit) changelog_messages.append(parse_commit(message)) - change_log_entry += get_changelog_category_msgs(changelog_messages, 'BUG FIXES', 'Fixed') - change_log_entry += get_changelog_category_msgs(changelog_messages, 'ADDED', 'Fixed') - change_log_entry += get_changelog_category_msgs(changelog_messages, 'CHANGED', 'Fixed') - change_log_entry += get_changelog_category_msgs(changelog_messages, 'REMOVED', 'Fixed') + change_log_entry += get_changelog_category_msgs( + changelog_messages, 'BUG FIXES', 'Fixed' + ) + change_log_entry += get_changelog_category_msgs( + changelog_messages, 'ADDED', 'Fixed' + ) + change_log_entry += get_changelog_category_msgs( + changelog_messages, 'CHANGED', 'Fixed' + ) + change_log_entry += get_changelog_category_msgs( + changelog_messages, 'REMOVED', 'Fixed' + ) change_log_entry += "## UN-CATEGORIZED \n" for commit in changelog_messages: if commit["message"] not in change_log_entry: change_log_entry += f"- {commit['message']}" change_log_entry += "\n" - return change_log_entry + return change_log_entry -def get_commits_in_folder(folder:Path, commit_message:str): + +def get_commits_in_folder(folder: Path, commit_message: str): last_version_commit = None - commits_in_folder =subprocess_capture_command(f'git log --format=format:"%H" {folder}/*').stdout.split('\n') + commits_in_folder = subprocess_capture_command( + f'git log --format=format:"%H" {folder}/*' + ).stdout.split('\n') # Find Last Version for commit in commits_in_folder: commit = clean_str(commit) @@ -172,46 +189,52 @@ def get_commits_in_folder(folder:Path, commit_message:str): if commit_message in commit_msg.stdout: last_version_commit = commit if last_version_commit is None: - return + return - commits_since_lastest_release = subprocess_capture_command(f'git rev-list {clean_str(last_version_commit)[0:9]}..HEAD').stdout.split('\n') + commits_since_lastest_release = subprocess_capture_command( + f'git rev-list {clean_str(last_version_commit)[0:9]}..HEAD' + ).stdout.split('\n') new_commit_hashes_in_folder = [] - for commit in commits_in_folder : + for commit in commits_in_folder: if any(clean_str(commit) in x for x in commits_since_lastest_release): new_commit_hashes_in_folder.append(clean_str(commit)) - return new_commit_hashes_in_folder - + return new_commit_hashes_in_folder -def get_commit_msg(commit:str): + +def get_commit_msg(commit: str): output = f"{subprocess_capture_command(f'git log --pretty=format:%s -n 1 {commit}').stdout}\n" return output -def get_directory(repo_root:Path, folder_name:str): + +def get_directory(repo_root: Path, folder_name: str): path = repo_root.joinpath(folder_name) if not os.path.exists(path): os.makedirs(path) return path -def generate_checksum(path_to_archive:str): - archive = zipfile.ZipFile(path_to_archive) - blocksize = 1024**2 #1M chunks - checksum = hashlib.new('sha256') - for fname in archive.namelist(): - entry = archive.open(fname) - while True: - block = entry.read(blocksize) - if not block: - break - checksum.update(block) - return checksum -def write_file(file_path:Path, content): +def generate_checksum(path_to_archive: str): + archive = zipfile.ZipFile(path_to_archive) + blocksize = 1024**2 # 1M chunks + checksum = hashlib.new('sha256') + for fname in archive.namelist(): + entry = archive.open(fname) + while True: + block = entry.read(blocksize) + if not block: + break + checksum.update(block) + return checksum + + +def write_file(file_path: Path, content): file = open(file_path, 'w') file.writelines(content) file.close() -def write_changelog_file(file_path:Path, content): + +def write_changelog_file(file_path: Path, content): if file_path.exists(): dummy_file = str(file_path._str) + '.bak' with open(file_path, 'r') as read_obj, open(dummy_file, 'w') as write_obj: @@ -223,71 +246,101 @@ def write_changelog_file(file_path:Path, content): else: write_file(file_path, content) -def create_new_addon_zip(addon_to_package:Path, commit_msg_to_find:str, major_version=False): + +def create_new_addon_zip( + addon_to_package: Path, commit_msg_to_find: str, major_version=False +): # TODO Check is NONE in function incase user passes no argument - commit_msg = 'Version Bump:' if commit_msg_to_find is None else commit_msg_to_find - commits_in_folder = get_commits_in_folder(addon_to_package,commit_msg) + commit_msg = 'Version Bump:' if commit_msg_to_find is None else commit_msg_to_find + commits_in_folder = get_commits_in_folder(addon_to_package, commit_msg) output_zips_path = get_directory(Path(__file__).parent.parent.parent.parent, "dist") if commits_in_folder: - file_path, version = bump_addon_version(addon_to_package, major_version) + file_path, version = bump_addon_version(addon_to_package, major_version) change_log = generate_change_log_entry(commits_in_folder, version) - subprocess_capture_command(f'git reset') #Unstage any changes user may have staged earlier so we only commit version bump + subprocess_capture_command( + f'git reset' + ) # Unstage any changes user may have staged earlier so we only commit version bump subprocess_capture_command(f'git stage {file_path}') - subprocess.run(['git', 'commit', '-m' , f"Version Bump: {addon_to_package.name} {version}"], capture_output=True, encoding="utf-8") + subprocess.run( + ['git', 'commit', '-m', f"Version Bump: {addon_to_package.name} {version}"], + capture_output=True, + encoding="utf-8", + ) print(f"Version Bump: {addon_to_package.name} {version}") name = addon_to_package.name addon_output_dir = get_directory(output_zips_path, addon_to_package.name) - change_log_file = write_changelog_file(addon_to_package.joinpath("CHANGELOG.MD"), change_log) - zipped_addon = shutil.make_archive(addon_output_dir.joinpath(f"{name}_{version}"), 'zip' ,addon_to_package) + change_log_file = write_changelog_file( + addon_to_package.joinpath("CHANGELOG.MD"), change_log + ) + zipped_addon = shutil.make_archive( + addon_output_dir.joinpath(f"{name}_{version}"), 'zip', addon_to_package + ) checksum = generate_checksum(zipped_addon) - checksum_file = write_file(addon_output_dir.joinpath(f"{name}_{version}.sha256"), f"{checksum.hexdigest()} {name}_{version}.zip") - - else: - print(f"No New Version: {addon_to_package.name}") + checksum_file = write_file( + addon_output_dir.joinpath(f"{name}_{version}.sha256"), + f"{checksum.hexdigest()} {name}_{version}.zip", + ) -def find_version_number(version_line:str, major_version): - version = version_line.split('(')[1].split(')')[0] - #Bump either last digit for minor versions and second last digit for major - if major_version: - new_version = version[:-4] + str(int(version[3])+1) +version[-3:] else: - new_version = version[:-1] + str(int(version[-1])+1) + print(f"No New Version: {addon_to_package.name}") + + +def find_version_number(version_line: str, major_version): + version = version_line.split('(')[1].split(')')[0] + # Bump either last digit for minor versions and second last digit for major + if major_version: + new_version = version[:-4] + str(int(version[3]) + 1) + version[-3:] + else: + new_version = version[:-1] + str(int(version[-1]) + 1) return new_version + def bump_addon_version(addon_to_package, major_version): version_line = None str_find = "version" init_file = addon_to_package.joinpath("__init__.py") - with open(init_file,'r') as myFile: + with open(init_file, 'r') as myFile: for num, line in enumerate(myFile): if str_find in line and "(" in line and line[0] != "#": version_line = num - break #Use first line found + break # Use first line found - file = open(init_file,) - lines = file.readlines() + file = open( + init_file, + ) + lines = file.readlines() version = find_version_number(lines[version_line], major_version) repl_str = f' "version": ({version}),\n' lines[version_line] = repl_str out = open(init_file, 'w') out.writelines(lines) out.close() - return init_file, version.replace(', ','.').replace(',','.') + return init_file, version.replace(', ', '.').replace(',', '.') + def main() -> int: args = parser.parse_args() main_dir = Path(__file__).parent.parent.parent.parent - msg = args.msg + msg = args.msg bump = args.bump user_names = args.name addon_folder = main_dir.joinpath(main_dir, "scripts-blender/addons") - addon_dirs = [name for name in os.listdir(addon_folder) if os.path.isdir(addon_folder.joinpath(name))] + addon_dirs = [ + name + for name in os.listdir(addon_folder) + if os.path.isdir(addon_folder.joinpath(name)) + ] if user_names: - addon_dirs = [name for name in os.listdir(addon_folder) if os.path.isdir(addon_folder.joinpath(name)) and name in user_names] + addon_dirs = [ + name + for name in os.listdir(addon_folder) + if os.path.isdir(addon_folder.joinpath(name)) and name in user_names + ] for dir in addon_dirs: addon_to_package = addon_folder.joinpath(addon_folder, dir) create_new_addon_zip(addon_to_package, msg, bump) return 0 + if __name__ == "__main__": - main() \ No newline at end of file + main() -- 2.30.2 From 086543bbe4f6f96d14713731c0a3d023cf22d7b1 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 11:07:42 -0400 Subject: [PATCH 22/43] Release System: Simplify Changelog generation - Remove no-op code - include "breaking" in parse_commit() --- .../pipeline_release/__main__.py | 71 ++++++------------- 1 file changed, 21 insertions(+), 50 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 173b263a..94bc2ce9 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -40,64 +40,32 @@ TYPES: dict[str, str] = { "remove": "Removed", "merge": "Merged", "doc": "Documented", + "breaking": "Breaking", } -TYPE_REGEX: Pattern = re.compile(r"^(?P(%s))" % "|".join(TYPES.keys()), re.I) -BREAK_REGEX: Pattern = re.compile( - r"^break(s|ing changes?)?[ :].+$", - re.I | re.MULTILINE, -) -DEFAULT_RENDER: list[str] = [ - TYPES["add"], - TYPES["fix"], - TYPES["change"], - TYPES["remove"], -] - -def check_minor(commit_type: str) -> bool: - """Tell if this commit is worth a minor bump. - Arguments: - commit_type: The commit type. - Returns: - Whether it's a minor commit. - """ - return commit_type == TYPES["add"] - - -def check_major(commit_message: str) -> bool: - """Tell if this commit is worth a major bump. - Arguments: - commit_message: The commit message. - Returns: - Whether it's a major commit. - """ - return bool(BREAK_REGEX.search(commit_message)) - - -def parse_type(commit_subject: str) -> str: +def parse_commit(commit_subject: str) -> dict[str, str | bool]: """Parse the type of the commit given its subject. Arguments: commit_subject: The commit message subject. Returns: The commit type. """ - type_match = TYPE_REGEX.match(commit_subject) + type = "" + type_regex: Pattern = re.compile(r"^(?P(%s))" % "|".join(TYPES.keys()), re.I) + breaking_regex: Pattern = re.compile( + r"^break(s|ing changes?)?[ :].+$", + re.I | re.MULTILINE, + ) + + type_match = type_regex.match(commit_subject) if type_match: - return TYPES.get(type_match.groupdict()["type"].lower(), "") - return "" - - -def parse_commit(message) -> dict[str, str | bool]: # noqa: D102 - commit_type = parse_type(message) - is_major = check_major(message) - is_patch = not check_minor - + type = TYPES.get(type_match.groupdict()["type"].lower(), "") + if bool(breaking_regex.search(commit_subject)): + type = "Breaking" return { - "message": message, - "type": commit_type, - "is_major": is_major, - "is_patch": is_patch, + "message": commit_subject, + "type": type, } @@ -156,17 +124,20 @@ def generate_change_log_entry(new_commit_hashes_in_folder, version): message = get_commit_msg(commit) changelog_messages.append(parse_commit(message)) + change_log_entry += get_changelog_category_msgs( + changelog_messages, 'BREAKING', 'Breaking' + ) change_log_entry += get_changelog_category_msgs( changelog_messages, 'BUG FIXES', 'Fixed' ) change_log_entry += get_changelog_category_msgs( - changelog_messages, 'ADDED', 'Fixed' + changelog_messages, 'ADDED', 'Added' ) change_log_entry += get_changelog_category_msgs( - changelog_messages, 'CHANGED', 'Fixed' + changelog_messages, 'CHANGED', 'Changed' ) change_log_entry += get_changelog_category_msgs( - changelog_messages, 'REMOVED', 'Fixed' + changelog_messages, 'REMOVED', 'Removed' ) change_log_entry += "## UN-CATEGORIZED \n" -- 2.30.2 From e805542c428393ac60c171972d5e1a8200d25e2d Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 11:12:16 -0400 Subject: [PATCH 23/43] Release System: Loop through TYPES --- .../pipeline_release/__main__.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 94bc2ce9..117f270a 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -124,21 +124,10 @@ def generate_change_log_entry(new_commit_hashes_in_folder, version): message = get_commit_msg(commit) changelog_messages.append(parse_commit(message)) - change_log_entry += get_changelog_category_msgs( - changelog_messages, 'BREAKING', 'Breaking' - ) - change_log_entry += get_changelog_category_msgs( - changelog_messages, 'BUG FIXES', 'Fixed' - ) - change_log_entry += get_changelog_category_msgs( - changelog_messages, 'ADDED', 'Added' - ) - change_log_entry += get_changelog_category_msgs( - changelog_messages, 'CHANGED', 'Changed' - ) - change_log_entry += get_changelog_category_msgs( - changelog_messages, 'REMOVED', 'Removed' - ) + for type in TYPES: + change_log_entry += get_changelog_category_msgs( + changelog_messages, TYPES.get(type).upper(), TYPES.get(type) + ) change_log_entry += "## UN-CATEGORIZED \n" for commit in changelog_messages: -- 2.30.2 From d627e1c9c0261c8350d765cadc014fe82d562164 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 12:15:59 -0400 Subject: [PATCH 24/43] Release System: Update Documentation in main.py functions --- .../pipeline_release/__main__.py | 266 +++++++++++------- 1 file changed, 167 insertions(+), 99 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 117f270a..8f9939d2 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -44,12 +44,12 @@ TYPES: dict[str, str] = { } -def parse_commit(commit_subject: str) -> dict[str, str | bool]: +def parse_commit(commit_message: str) -> dict[str, str]: """Parse the type of the commit given its subject. Arguments: commit_subject: The commit message subject. Returns: - The commit type. + Dict containing commit message and type """ type = "" type_regex: Pattern = re.compile(r"^(?P(%s))" % "|".join(TYPES.keys()), re.I) @@ -58,13 +58,13 @@ def parse_commit(commit_subject: str) -> dict[str, str | bool]: re.I | re.MULTILINE, ) - type_match = type_regex.match(commit_subject) + type_match = type_regex.match(commit_message) if type_match: type = TYPES.get(type_match.groupdict()["type"].lower(), "") - if bool(breaking_regex.search(commit_subject)): + if bool(breaking_regex.search(commit_message)): type = "Breaking" return { - "message": commit_subject, + "message": commit_message, "type": type, } @@ -91,91 +91,47 @@ parser.add_argument( ) -def subprocess_capture_command(command: str): +def cli_command(command: str) -> subprocess: + """Run command in CLI and capture it's output + Arguments: + command: String of command to run in CLI. + """ output = subprocess.run(command.split(' '), capture_output=True, encoding="utf-8") return output -# Command line arguments. -def cancel_program(message: str): +def exit_program(message: str): print(message) sys.exit(0) -def clean_str(string: str): - return string.replace('\n', '').replace("'", "").replace('"', '') +def write_file(file_path: Path, content): + file = open(file_path, 'w') + file.writelines(content) + file.close() -def get_changelog_category_msgs(changelog_messages, title, key): - entry = '' - if not any(commit for commit in changelog_messages if commit["type"] == key): - return entry - entry += f"## {title} \n \n" - for commit in changelog_messages: - if commit["type"] == key: - entry += commit["message"] - return entry - - -def generate_change_log_entry(new_commit_hashes_in_folder, version): - change_log_entry = f'# {version} - {datetime.date.today()} \n \n' - changelog_messages = [] - for commit in new_commit_hashes_in_folder: - message = get_commit_msg(commit) - changelog_messages.append(parse_commit(message)) - - for type in TYPES: - change_log_entry += get_changelog_category_msgs( - changelog_messages, TYPES.get(type).upper(), TYPES.get(type) - ) - - change_log_entry += "## UN-CATEGORIZED \n" - for commit in changelog_messages: - if commit["message"] not in change_log_entry: - change_log_entry += f"- {commit['message']}" - change_log_entry += "\n" - return change_log_entry - - -def get_commits_in_folder(folder: Path, commit_message: str): - last_version_commit = None - commits_in_folder = subprocess_capture_command( - f'git log --format=format:"%H" {folder}/*' - ).stdout.split('\n') - # Find Last Version - for commit in commits_in_folder: - commit = clean_str(commit) - commit_msg = subprocess_capture_command(f'git log --format=%B -n 1 {commit}') - if commit_message in commit_msg.stdout: - last_version_commit = commit - if last_version_commit is None: - return - - commits_since_lastest_release = subprocess_capture_command( - f'git rev-list {clean_str(last_version_commit)[0:9]}..HEAD' - ).stdout.split('\n') - new_commit_hashes_in_folder = [] - - for commit in commits_in_folder: - if any(clean_str(commit) in x for x in commits_since_lastest_release): - new_commit_hashes_in_folder.append(clean_str(commit)) - return new_commit_hashes_in_folder - - -def get_commit_msg(commit: str): - output = f"{subprocess_capture_command(f'git log --pretty=format:%s -n 1 {commit}').stdout}\n" - return output - - -def get_directory(repo_root: Path, folder_name: str): +def get_directory(repo_root: Path, folder_name: str) -> Path: + """Returns directory PATH, creates one if none exists""" path = repo_root.joinpath(folder_name) if not os.path.exists(path): os.makedirs(path) return path -def generate_checksum(path_to_archive: str): - archive = zipfile.ZipFile(path_to_archive) +def clean_str(string: str) -> str: + """Returns string with qoutes and line breaks removed""" + return string.replace('\n', '').replace("'", "").replace('"', '') + + +def generate_checksum(archive_path: str) -> str: + """Parse the type of the commit given its subject. + Arguments: + path_to_archive: String of the archive's file path + Returns: + sha256 checksum for the provided archive as string + """ + archive = zipfile.ZipFile(archive_path) blocksize = 1024**2 # 1M chunks checksum = hashlib.new('sha256') for fname in archive.namelist(): @@ -188,13 +144,93 @@ def generate_checksum(path_to_archive: str): return checksum -def write_file(file_path: Path, content): - file = open(file_path, 'w') - file.writelines(content) - file.close() +def changelog_category_get(changelog_messages: dict[str, str], title: str, key: str): + """Generate changelog messages for a specific commit type. + Types are defined in global variable 'TYPES' + Arguments: + changelog_messages: dict contaning commit message & type + title: Title of the changelog category + key: Key for type as defined in global variable TYPES + Returns: + changelog entry for the given category as a string + """ + entry = '' + if not any(commit for commit in changelog_messages if commit["type"] == key): + return entry + entry += f"## {title} \n" + for commit in changelog_messages: + if commit["type"] == key: + entry += commit["message"] + entry += "\n" + return entry -def write_changelog_file(file_path: Path, content): +def changelog_generate(commit_hashes: list[str], version: str) -> str: + """Generate Changelog Entries from a list of commits + Arguments: + commit_hashes: A list of commit hashes to include in Changelog + version: Latest addon version number + Returns: + complete changelog for latest version as string + """ + + log_entry = f'# {version} - {datetime.date.today()} \n \n' + changelog_messages = [] + for commit in commit_hashes: + message = f"{cli_command(f'git log --pretty=format:%s -n 1 {commit}').stdout}\n" + changelog_messages.append(parse_commit(message)) + + for type in TYPES: + log_entry += changelog_category_get( + changelog_messages, TYPES.get(type).upper(), TYPES.get(type) + ) + + log_entry += "## UN-CATEGORIZED \n" + for commit in changelog_messages: + if commit["message"] not in log_entry: + log_entry += f"- {commit['message']}" + log_entry += "\n" + return log_entry + + +def changelog_commits_get(directory: Path, commit_message: str) -> list[str]: + """Get list of commit hashes, that affect a given directory + Arguments: + directory: Name of directory/folder to filter commits + commit_message: Prefix of commit to use as base for latest release + Returns: + list of commit hashes + """ + last_version_commit = None + commits_in_folder = cli_command( + f'git log --format=format:"%H" {directory}/*' + ).stdout.split('\n') + # Find Last Version + for commit in commits_in_folder: + commit = clean_str(commit) + commit_msg = cli_command(f'git log --format=%B -n 1 {commit}') + if commit_message in commit_msg.stdout: + last_version_commit = commit + if last_version_commit is None: + return + + commits_since_release = cli_command( + f'git rev-list {clean_str(last_version_commit)[0:9]}..HEAD' + ).stdout.split('\n') + commit_hashes = [] + + for commit in commits_in_folder: + if any(clean_str(commit) in x for x in commits_since_release): + commit_hashes.append(clean_str(commit)) + return commit_hashes + + +def changelog_file_write(file_path: Path, content: str): + """Append changelog to existing changelog file if any + Arguments: + file_path: PATH to changelog + content: changelog for latest version as string + """ if file_path.exists(): dummy_file = str(file_path._str) + '.bak' with open(file_path, 'r') as read_obj, open(dummy_file, 'w') as write_obj: @@ -207,33 +243,44 @@ def write_changelog_file(file_path: Path, content): write_file(file_path, content) -def create_new_addon_zip( - addon_to_package: Path, commit_msg_to_find: str, major_version=False -): +def addon_package(directory: Path, commit_prefix: str, is_major=False): + """For a give directory, if new commits are found after the commit matching 'commit_prefix', + bump addon version, generate a changelog, commit changes and package addon into an archive. + Print statements indicate if addon was version bumped, or if new version was found. + Arguments: + directory: Name of directory/folder to filter commits + commit_prefix: Prefix of commit to use as base for latest release + is_major: if major 2nd digit in version is updated, else 3rd digit + """ # TODO Check is NONE in function incase user passes no argument - commit_msg = 'Version Bump:' if commit_msg_to_find is None else commit_msg_to_find - commits_in_folder = get_commits_in_folder(addon_to_package, commit_msg) + commit_msg = 'Version Bump:' if commit_prefix is None else commit_prefix + commits_in_folder = changelog_commits_get(directory, commit_msg) output_zips_path = get_directory(Path(__file__).parent.parent.parent.parent, "dist") if commits_in_folder: + init_file, version = addon_version_bump(directory, is_major) + change_log = changelog_generate(commits_in_folder, version) + change_log_file = changelog_file_write( + directory.joinpath("CHANGELOG.MD"), change_log + ) + cli_command(f'git reset') file_path, version = bump_addon_version(addon_to_package, major_version) change_log = generate_change_log_entry(commits_in_folder, version) subprocess_capture_command( f'git reset' ) # Unstage any changes user may have staged earlier so we only commit version bump subprocess_capture_command(f'git stage {file_path}') + cli_command(f'git stage {init_file}') subprocess.run( - ['git', 'commit', '-m', f"Version Bump: {addon_to_package.name} {version}"], + ['git', 'commit', '-m', f"Version Bump: {directory.name} {version}"], capture_output=True, encoding="utf-8", ) - print(f"Version Bump: {addon_to_package.name} {version}") - name = addon_to_package.name - addon_output_dir = get_directory(output_zips_path, addon_to_package.name) - change_log_file = write_changelog_file( - addon_to_package.joinpath("CHANGELOG.MD"), change_log - ) + print(f"Version Bump: {directory.name} {version}") + name = directory.name + addon_output_dir = get_directory(output_zips_path, directory.name) + zipped_addon = shutil.make_archive( - addon_output_dir.joinpath(f"{name}_{version}"), 'zip', addon_to_package + addon_output_dir.joinpath(f"{name}_{version}"), 'zip', directory ) checksum = generate_checksum(zipped_addon) checksum_file = write_file( @@ -242,23 +289,44 @@ def create_new_addon_zip( ) else: - print(f"No New Version: {addon_to_package.name}") + print(f"No New Version: {directory.name}") -def find_version_number(version_line: str, major_version): +def addon_version_get(version_line: str, is_major: bool) -> str: + """ + Update bl_info within addon's __init__.py file to indicate + version bump. Expects line to read as '"version": (n, n, n),\n' + Arguments: + version_line: Line of bl_info containing version number + is_major: if major 2nd digit in version is updated, else 3rd digit + Returns + Latest addon version number + """ version = version_line.split('(')[1].split(')')[0] # Bump either last digit for minor versions and second last digit for major - if major_version: + if is_major: new_version = version[:-4] + str(int(version[3]) + 1) + version[-3:] else: new_version = version[:-1] + str(int(version[-1]) + 1) return new_version -def bump_addon_version(addon_to_package, major_version): +def addon_version_bump(directory: Path, is_major: bool): + """ + Update bl_info within addon's __init__.py file to indicate + version bump. Expects line to read as '"version": (n, n, n),\n' + Arguments: + directory: Name of directory/folder containing addon + is_major: if major 2nd digit in version is updated, else 3rd digit + + Returns: + init_file: PATH to init file that has been updated with new version + version: Latest addon version number + """ + version_line = None str_find = "version" - init_file = addon_to_package.joinpath("__init__.py") + init_file = directory.joinpath("__init__.py") with open(init_file, 'r') as myFile: for num, line in enumerate(myFile): if str_find in line and "(" in line and line[0] != "#": @@ -269,7 +337,7 @@ def bump_addon_version(addon_to_package, major_version): init_file, ) lines = file.readlines() - version = find_version_number(lines[version_line], major_version) + version = addon_version_get(lines[version_line], is_major) repl_str = f' "version": ({version}),\n' lines[version_line] = repl_str out = open(init_file, 'w') @@ -298,7 +366,7 @@ def main() -> int: ] for dir in addon_dirs: addon_to_package = addon_folder.joinpath(addon_folder, dir) - create_new_addon_zip(addon_to_package, msg, bump) + addon_package(addon_to_package, msg, bump) return 0 -- 2.30.2 From b99524d2781c550d74d5ef1721a0a66c61523c68 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 12:16:45 -0400 Subject: [PATCH 25/43] Release System: Commit Change Log with Version Bump --- scripts/pipeline-release/pipeline_release/__main__.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 8f9939d2..fed339b6 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -241,6 +241,7 @@ def changelog_file_write(file_path: Path, content: str): os.rename(dummy_file, file_path) else: write_file(file_path, content) + return file_path def addon_package(directory: Path, commit_prefix: str, is_major=False): @@ -263,12 +264,7 @@ def addon_package(directory: Path, commit_prefix: str, is_major=False): directory.joinpath("CHANGELOG.MD"), change_log ) cli_command(f'git reset') - file_path, version = bump_addon_version(addon_to_package, major_version) - change_log = generate_change_log_entry(commits_in_folder, version) - subprocess_capture_command( - f'git reset' - ) # Unstage any changes user may have staged earlier so we only commit version bump - subprocess_capture_command(f'git stage {file_path}') + cli_command(f'git stage {change_log_file}') cli_command(f'git stage {init_file}') subprocess.run( ['git', 'commit', '-m', f"Version Bump: {directory.name} {version}"], -- 2.30.2 From 2ca99307bd351308e35e799165c5c715b59348bd Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 13:01:39 -0400 Subject: [PATCH 26/43] Release System: Add TODO --- scripts/pipeline-release/pipeline_release/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index fed339b6..5c8fbf40 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -52,6 +52,7 @@ def parse_commit(commit_message: str) -> dict[str, str]: Dict containing commit message and type """ type = "" + # TODO Split at first color to remove prefix from commit type_regex: Pattern = re.compile(r"^(?P(%s))" % "|".join(TYPES.keys()), re.I) breaking_regex: Pattern = re.compile( r"^break(s|ing changes?)?[ :].+$", -- 2.30.2 From 86304c033ca79e3ab0477d3a001daa9c31a86803 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 13:02:15 -0400 Subject: [PATCH 27/43] Release System: Fix documentation --- scripts/pipeline-release/pipeline_release/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 5c8fbf40..a089fcc4 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -126,9 +126,9 @@ def clean_str(string: str) -> str: def generate_checksum(archive_path: str) -> str: - """Parse the type of the commit given its subject. + """Generate a checksum for a zip file Arguments: - path_to_archive: String of the archive's file path + archive_path: String of the archive's file path Returns: sha256 checksum for the provided archive as string """ -- 2.30.2 From cad03f2f38e4f08b51a32b7480286587608a9300 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 14:01:03 -0400 Subject: [PATCH 28/43] Release System: Fix checksum logic --- .../pipeline_release/__main__.py | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index a089fcc4..91579429 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -132,17 +132,14 @@ def generate_checksum(archive_path: str) -> str: Returns: sha256 checksum for the provided archive as string """ - archive = zipfile.ZipFile(archive_path) - blocksize = 1024**2 # 1M chunks - checksum = hashlib.new('sha256') - for fname in archive.namelist(): - entry = archive.open(fname) - while True: - block = entry.read(blocksize) - if not block: - break - checksum.update(block) - return checksum + sha256 = hashlib.sha256() + with open(archive_path, 'rb') as file: + # Read the file in chunks to handle large files efficiently + chunk = file.read(4096) + while len(chunk) > 0: + sha256.update(chunk) + chunk = file.read(4096) + return sha256.hexdigest() def changelog_category_get(changelog_messages: dict[str, str], title: str, key: str): @@ -282,7 +279,7 @@ def addon_package(directory: Path, commit_prefix: str, is_major=False): checksum = generate_checksum(zipped_addon) checksum_file = write_file( addon_output_dir.joinpath(f"{name}_{version}.sha256"), - f"{checksum.hexdigest()} {name}_{version}.zip", + f"{checksum} {name}_{version}.zip", ) else: -- 2.30.2 From da38c44f5aa9da89d173746ae46ee689408fa7f6 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 14:05:45 -0400 Subject: [PATCH 29/43] Release System: Update README --- scripts/pipeline-release/README.md | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/scripts/pipeline-release/README.md b/scripts/pipeline-release/README.md index df73617e..8350b874 100644 --- a/scripts/pipeline-release/README.md +++ b/scripts/pipeline-release/README.md @@ -5,26 +5,11 @@ In order to use this tool you need: - Python 3.5+ - GIT -## Run without Installation -This folder contains a command line tool that doesn't require installation to use properly. This tool doesn't require installation to be run. To run `pipeline_release` without installation follow the steps below. +## Run +This folder contains a command line tool that doesn't require installation to use properly. To run `pipeline_release` without installation follow the steps below. 1. Clone this repository with `git clone https://projects.blender.org/studio/blender-studio-pipeline.git` 2. Run `cd blender-studio-pipeline/scripts/pipeline_release` to enter directory -3. Run program with `python pipeline_release /my-folder/` - - -## Installation (OPTIONAL) -Download or clone this repository. This repository is a command line tool that can be installed with the python packaging manager. Installation is an optional step only intended for advanced users. -This script does the following (follow this if you want to do this manually or on another platform): -Steps 3 and 5 are specific to linux, similar steps to gain root/administration privileges are avaliable to [Windows](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/jj717276(v=ws.11)) and [Mac](https://support.apple.com/en-ca/guide/terminal/apd5b0b6259-a7d4-4435-947d-0dff528912ba/mac) users. - -1. Clone this repository with `git clone https://projects.blender.org/studio/blender-studio-pipeline.git` -2. Run `cd blender-studio-pipeline/scripts/pipeline_release` to enter directory -3. Gain root access with `su` or equivalent command to grant permission to modify the system. -4. Install with `pip install .` -5. Type `exit` to log out of root user or equivalent command. -5. Run with `pipeline_release /my-folder/` -6. Get help with `pipeline_release -h` - +3. Run program with `python -m pipeline_release` ## How to get started @@ -38,7 +23,7 @@ Steps 3 and 5 are specific to linux, similar steps to gain root/administration p | Action | Command | | ----------- | ----------- | -|Create a new minor version if available of all addons|`pipeline_release`| -|Create a new major version if available of all addons|`pipeline_release -b`| -|Only check if addon has this name(s) |`pipeline_release -n "blender_kitsu, blender_svn"`| -|Find a commit that matches this message and uses as version basis |`pipeline_release -m "Commit MSG"`| \ No newline at end of file +|Create a new minor version if available of all addons|`python -m pipeline_release`| +|Create a new major version if available of all addons|`python -m pipeline_release -b`| +|Only check if addon has this name(s) |`python -m pipeline_release -n "blender_kitsu, blender_svn"`| +|Find a commit that matches this message and uses as version basis otherwise the last commit called 'Version Bump:' will be used |`python -m pipeline_release -m "Commit MSG"`| \ No newline at end of file -- 2.30.2 From 94a88bcbb811f050e7d4570cccfaa0619eb9f115 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 14:33:55 -0400 Subject: [PATCH 30/43] Release System: Include Changelog in Addon Docs --- docs/addons/anim_cupboard.md | 2 ++ docs/addons/asset_pipeline.md | 2 ++ docs/addons/blender_kitsu.md | 2 ++ docs/addons/blender_svn.md | 2 ++ docs/addons/bone_gizmos.md | 2 ++ docs/addons/cache_manager.md | 2 ++ docs/addons/contactsheet.md | 2 ++ docs/addons/easy_weights.md | 2 ++ docs/addons/geonode_shapekeys.md | 2 ++ docs/addons/grease_converter.md | 2 ++ docs/addons/lattice_magic.md | 2 ++ docs/addons/lighting_overrider.md | 2 ++ docs/addons/pose_shape_keys.md | 2 ++ docs/addons/render_review.md | 4 +++- 14 files changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/addons/anim_cupboard.md b/docs/addons/anim_cupboard.md index 1a916592..740c17de 100644 --- a/docs/addons/anim_cupboard.md +++ b/docs/addons/anim_cupboard.md @@ -1,2 +1,4 @@ +# CHANGELOG + diff --git a/docs/addons/asset_pipeline.md b/docs/addons/asset_pipeline.md index 9a403817..f2b4a984 100644 --- a/docs/addons/asset_pipeline.md +++ b/docs/addons/asset_pipeline.md @@ -1,2 +1,4 @@ +# CHANGELOG + diff --git a/docs/addons/blender_kitsu.md b/docs/addons/blender_kitsu.md index 209000d5..b9d969f9 100644 --- a/docs/addons/blender_kitsu.md +++ b/docs/addons/blender_kitsu.md @@ -1,2 +1,4 @@ +# CHANGELOG + diff --git a/docs/addons/blender_svn.md b/docs/addons/blender_svn.md index 798472bf..89a44089 100644 --- a/docs/addons/blender_svn.md +++ b/docs/addons/blender_svn.md @@ -1,2 +1,4 @@ +# CHANGELOG + diff --git a/docs/addons/bone_gizmos.md b/docs/addons/bone_gizmos.md index 42db980e..056a0541 100644 --- a/docs/addons/bone_gizmos.md +++ b/docs/addons/bone_gizmos.md @@ -1,2 +1,4 @@ +# CHANGELOG + diff --git a/docs/addons/cache_manager.md b/docs/addons/cache_manager.md index 74abdbc1..d8e2bd44 100644 --- a/docs/addons/cache_manager.md +++ b/docs/addons/cache_manager.md @@ -1,2 +1,4 @@ +# CHANGELOG + diff --git a/docs/addons/contactsheet.md b/docs/addons/contactsheet.md index d170c28d..68e36fce 100644 --- a/docs/addons/contactsheet.md +++ b/docs/addons/contactsheet.md @@ -1,2 +1,4 @@ +# CHANGELOG + diff --git a/docs/addons/easy_weights.md b/docs/addons/easy_weights.md index c9af828d..1857ec95 100644 --- a/docs/addons/easy_weights.md +++ b/docs/addons/easy_weights.md @@ -1,2 +1,4 @@ +# CHANGELOG + diff --git a/docs/addons/geonode_shapekeys.md b/docs/addons/geonode_shapekeys.md index 41217225..dcf7cdb4 100644 --- a/docs/addons/geonode_shapekeys.md +++ b/docs/addons/geonode_shapekeys.md @@ -1,2 +1,4 @@ +# CHANGELOG + diff --git a/docs/addons/grease_converter.md b/docs/addons/grease_converter.md index 63947dc1..bcfd423a 100644 --- a/docs/addons/grease_converter.md +++ b/docs/addons/grease_converter.md @@ -1,2 +1,4 @@ +# CHANGELOG + diff --git a/docs/addons/lattice_magic.md b/docs/addons/lattice_magic.md index 503172a5..15f46b6d 100644 --- a/docs/addons/lattice_magic.md +++ b/docs/addons/lattice_magic.md @@ -1 +1,3 @@ +# CHANGELOG + diff --git a/docs/addons/lighting_overrider.md b/docs/addons/lighting_overrider.md index 8212fca6..29d10472 100644 --- a/docs/addons/lighting_overrider.md +++ b/docs/addons/lighting_overrider.md @@ -1 +1,3 @@ +# CHANGELOG + diff --git a/docs/addons/pose_shape_keys.md b/docs/addons/pose_shape_keys.md index 0f2b92e4..1c9a091c 100644 --- a/docs/addons/pose_shape_keys.md +++ b/docs/addons/pose_shape_keys.md @@ -1 +1,3 @@ +# CHANGELOG + diff --git a/docs/addons/render_review.md b/docs/addons/render_review.md index 64de3a16..157c7433 100644 --- a/docs/addons/render_review.md +++ b/docs/addons/render_review.md @@ -1 +1,3 @@ - \ No newline at end of file + +# CHANGELOG + -- 2.30.2 From 4cb749a937f6e51cc97bf73915e0f7957e04003c Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 14:38:35 -0400 Subject: [PATCH 31/43] Release System: Changelog adjust headings --- .../pipeline_release/__main__.py | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 91579429..d7b84650 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -52,20 +52,24 @@ def parse_commit(commit_message: str) -> dict[str, str]: Dict containing commit message and type """ type = "" - # TODO Split at first color to remove prefix from commit + # Split at first colon to remove prefix from commit + if ": " in commit_message: + message_body = commit_message.split(': ')[1] + else: + message_body = commit_message type_regex: Pattern = re.compile(r"^(?P(%s))" % "|".join(TYPES.keys()), re.I) breaking_regex: Pattern = re.compile( r"^break(s|ing changes?)?[ :].+$", re.I | re.MULTILINE, ) - type_match = type_regex.match(commit_message) + type_match = type_regex.match(message_body) if type_match: type = TYPES.get(type_match.groupdict()["type"].lower(), "") - if bool(breaking_regex.search(commit_message)): + if bool(breaking_regex.search(message_body)): type = "Breaking" return { - "message": commit_message, + "message": message_body, "type": type, } @@ -155,10 +159,10 @@ def changelog_category_get(changelog_messages: dict[str, str], title: str, key: entry = '' if not any(commit for commit in changelog_messages if commit["type"] == key): return entry - entry += f"## {title} \n" + entry += f"### {title} \n" for commit in changelog_messages: if commit["type"] == key: - entry += commit["message"] + entry += f'- {commit["message"]}' entry += "\n" return entry @@ -172,7 +176,7 @@ def changelog_generate(commit_hashes: list[str], version: str) -> str: complete changelog for latest version as string """ - log_entry = f'# {version} - {datetime.date.today()} \n \n' + log_entry = f'## {version} - {datetime.date.today()} \n \n' changelog_messages = [] for commit in commit_hashes: message = f"{cli_command(f'git log --pretty=format:%s -n 1 {commit}').stdout}\n" @@ -183,7 +187,7 @@ def changelog_generate(commit_hashes: list[str], version: str) -> str: changelog_messages, TYPES.get(type).upper(), TYPES.get(type) ) - log_entry += "## UN-CATEGORIZED \n" + log_entry += "### UN-CATEGORIZED \n" for commit in changelog_messages: if commit["message"] not in log_entry: log_entry += f"- {commit['message']}" -- 2.30.2 From 434941e5804313ae66787746ed9d129cd541794e Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 14:56:04 -0400 Subject: [PATCH 32/43] Release System: Update doc strings --- .../pipeline_release/__main__.py | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index d7b84650..5362a038 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -45,7 +45,8 @@ TYPES: dict[str, str] = { def parse_commit(commit_message: str) -> dict[str, str]: - """Parse the type of the commit given its subject. + """ + Parse the type of the commit given its subject. Arguments: commit_subject: The commit message subject. Returns: @@ -130,7 +131,8 @@ def clean_str(string: str) -> str: def generate_checksum(archive_path: str) -> str: - """Generate a checksum for a zip file + """ + Generate a checksum for a zip file Arguments: archive_path: String of the archive's file path Returns: @@ -147,14 +149,15 @@ def generate_checksum(archive_path: str) -> str: def changelog_category_get(changelog_messages: dict[str, str], title: str, key: str): - """Generate changelog messages for a specific commit type. + """ + Generate changelog messages for a specific category. Types are defined in global variable 'TYPES' Arguments: changelog_messages: dict contaning commit message & type title: Title of the changelog category - key: Key for type as defined in global variable TYPES + key: Key for category/type as defined in global variable TYPES Returns: - changelog entry for the given category as a string + changelog entry for the given category/type as a string """ entry = '' if not any(commit for commit in changelog_messages if commit["type"] == key): @@ -168,7 +171,8 @@ def changelog_category_get(changelog_messages: dict[str, str], title: str, key: def changelog_generate(commit_hashes: list[str], version: str) -> str: - """Generate Changelog Entries from a list of commits + """ + Generate Changelog Entries from a list of commits hashes Arguments: commit_hashes: A list of commit hashes to include in Changelog version: Latest addon version number @@ -196,7 +200,8 @@ def changelog_generate(commit_hashes: list[str], version: str) -> str: def changelog_commits_get(directory: Path, commit_message: str) -> list[str]: - """Get list of commit hashes, that affect a given directory + """ + Get list of commit hashes, that affect a given directory Arguments: directory: Name of directory/folder to filter commits commit_message: Prefix of commit to use as base for latest release @@ -228,7 +233,9 @@ def changelog_commits_get(directory: Path, commit_message: str) -> list[str]: def changelog_file_write(file_path: Path, content: str): - """Append changelog to existing changelog file if any + """ + Append changelog to existing changelog file or create a new + changelog file if none exists Arguments: file_path: PATH to changelog content: changelog for latest version as string @@ -247,7 +254,8 @@ def changelog_file_write(file_path: Path, content: str): def addon_package(directory: Path, commit_prefix: str, is_major=False): - """For a give directory, if new commits are found after the commit matching 'commit_prefix', + """ + For a give directory, if new commits are found after the commit matching 'commit_prefix', bump addon version, generate a changelog, commit changes and package addon into an archive. Print statements indicate if addon was version bumped, or if new version was found. Arguments: @@ -255,7 +263,6 @@ def addon_package(directory: Path, commit_prefix: str, is_major=False): commit_prefix: Prefix of commit to use as base for latest release is_major: if major 2nd digit in version is updated, else 3rd digit """ - # TODO Check is NONE in function incase user passes no argument commit_msg = 'Version Bump:' if commit_prefix is None else commit_prefix commits_in_folder = changelog_commits_get(directory, commit_msg) output_zips_path = get_directory(Path(__file__).parent.parent.parent.parent, "dist") @@ -292,8 +299,7 @@ def addon_package(directory: Path, commit_prefix: str, is_major=False): def addon_version_get(version_line: str, is_major: bool) -> str: """ - Update bl_info within addon's __init__.py file to indicate - version bump. Expects line to read as '"version": (n, n, n),\n' + Read bl_info within addon's __init__.py file to get new version number Arguments: version_line: Line of bl_info containing version number is_major: if major 2nd digit in version is updated, else 3rd digit -- 2.30.2 From 829ca701866dca59eabaf2d51ed10c0491ac7e26 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 31 May 2023 15:12:20 -0400 Subject: [PATCH 33/43] Release System: Update readme.md - include feature list - include changelog conventions --- scripts/pipeline-release/README.md | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/scripts/pipeline-release/README.md b/scripts/pipeline-release/README.md index 8350b874..94f0c2ab 100644 --- a/scripts/pipeline-release/README.md +++ b/scripts/pipeline-release/README.md @@ -1,5 +1,12 @@ Pipeline release is a script to package addons in the pipeline repo. +# Features + - Automatically Find Commits since last version for each addon in `scripts-blender/addons/` + - Appends changelog to existing `CHANGELOG.md` per addon + - Bump Version on `__init__.py` file + - Commits `__init__.py` and `CHANGELOG.md` to current branch (user must manually push changes) + - Creates Archive with Checksum in `dist` folder + ## Prerequisite In order to use this tool you need: - Python 3.5+ @@ -21,6 +28,31 @@ This folder contains a command line tool that doesn't require installation to us | -h, --help| show the above help message and exit| +## Changelog Conventions +|Changelog Title| Commit Prefix| +| ----------- | ----------- | +|ADD |add| +|BUG FIX |fix| +|CHANGED |change| +|REMOVED |remove| +|MERGED |merge| +|DOCUMENTED|doc| +|BREAKING|breaking| + + +This tool will automatically generate changelog messages based on the "changelog categories" below. Commit's subject line convention is `{Name of Addon}: {category} commit content` for example: +### Commit Subject Line: +``` +Blender Kitsu: Fix naming conventions +```` + +### Changelog Output: +``` +### Fixes +- Fix naming conventions +``` + +## Example Usage | Action | Command | | ----------- | ----------- | |Create a new minor version if available of all addons|`python -m pipeline_release`| -- 2.30.2 From 7efec02b507b84567bc1beaf297deb01c0bb6214 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Thu, 1 Jun 2023 05:20:14 +0200 Subject: [PATCH 34/43] Release System: Create Addon Download Table --- scripts-blender/README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts-blender/README.md b/scripts-blender/README.md index 023b3abf..1b7089af 100644 --- a/scripts-blender/README.md +++ b/scripts-blender/README.md @@ -3,6 +3,24 @@ Most add-ons used in the Blender Studio pipeline. +| Addon Name | Download Link | +|---|---| +|Anim Cupboard | [v0.0.1](relative/to/page/anim_cupboard-0.1.0.zip) | +|Asset Pipeline | [v0.1.0](relative/to/page/asset_pipeline-0.1.0.zip)| +|Blender Kitsu|[v0.1.0](relative/to/page/blender_kitsu-0.1.0.zip) | +|Blender SVN | [v0.2.0](relative/to/page/blender_svn-0.1.0.zip)| +|Blender Gizmos|[v0.0.1](relative/to/page/blender_gizmos-0.1.0.zip)| +|Cache Manager |[v0.2.0](relative/to/page/cache_manager-0.1.0.zip) | +|Contact Sheet | [v0.1.0](relative/to/page/contact_sheet-0.1.0.zip)| +|Easy Weights |[v0.0.1](relative/to/page/easy_wights-0.1.0.zip)| +|Geonode Shapekeys | [v0.0.1](relative/to/page/geonode_shapekeys-0.1.0.zip)| +|Grease Converter |[v0.1.0](relative/to/page/grease_converter-0.1.0.zip) | +|Lattice Magic |[v0.1.0](relative/to/page/lattice_magic-0.1.0.zip) | +|Lighting Overrider | [v0.1.0](relative/to/page/lighting_overrider-0.1.0.zip)| +|Pose Shape Keys| [v0.1.0](relative/to/page/pose_shape_keys-0.1.0.zip)| +|Render Review |[v0.1.0](relative/to/page/render_review-0.1.0.zip) | + + ## Anim Cupboard Add-on with miscellaneous tools for animators. -- 2.30.2 From 31723dd35b9207cce13fd6605dd49da9db24eb96 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Thu, 1 Jun 2023 13:17:27 -0400 Subject: [PATCH 35/43] Release System: Include Checksums in download table --- scripts-blender/README.md | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts-blender/README.md b/scripts-blender/README.md index 1b7089af..c05b717b 100644 --- a/scripts-blender/README.md +++ b/scripts-blender/README.md @@ -3,22 +3,22 @@ Most add-ons used in the Blender Studio pipeline. -| Addon Name | Download Link | -|---|---| -|Anim Cupboard | [v0.0.1](relative/to/page/anim_cupboard-0.1.0.zip) | -|Asset Pipeline | [v0.1.0](relative/to/page/asset_pipeline-0.1.0.zip)| -|Blender Kitsu|[v0.1.0](relative/to/page/blender_kitsu-0.1.0.zip) | -|Blender SVN | [v0.2.0](relative/to/page/blender_svn-0.1.0.zip)| -|Blender Gizmos|[v0.0.1](relative/to/page/blender_gizmos-0.1.0.zip)| -|Cache Manager |[v0.2.0](relative/to/page/cache_manager-0.1.0.zip) | -|Contact Sheet | [v0.1.0](relative/to/page/contact_sheet-0.1.0.zip)| -|Easy Weights |[v0.0.1](relative/to/page/easy_wights-0.1.0.zip)| -|Geonode Shapekeys | [v0.0.1](relative/to/page/geonode_shapekeys-0.1.0.zip)| -|Grease Converter |[v0.1.0](relative/to/page/grease_converter-0.1.0.zip) | -|Lattice Magic |[v0.1.0](relative/to/page/lattice_magic-0.1.0.zip) | -|Lighting Overrider | [v0.1.0](relative/to/page/lighting_overrider-0.1.0.zip)| -|Pose Shape Keys| [v0.1.0](relative/to/page/pose_shape_keys-0.1.0.zip)| -|Render Review |[v0.1.0](relative/to/page/render_review-0.1.0.zip) | +| Add-on | Version | Checksum | +|---|---|---| +|Anim Cupboard | [v0.0.1](relative/to/page/anim_cupboard-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Asset Pipeline | [v0.1.0](relative/to/page/asset_pipeline-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Blender Kitsu|[v0.1.0](relative/to/page/blender_kitsu-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Blender SVN | [v0.2.0](relative/to/page/blender_svn-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Blender Gizmos|[v0.0.1](relative/to/page/blender_gizmos-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Cache Manager |[v0.2.0](relative/to/page/cache_manager-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Contact Sheet | [v0.1.0](relative/to/page/contact_sheet-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Easy Weights |[v0.0.1](relative/to/page/easy_wights-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Geonode Shapekeys | [v0.0.1](relative/to/page/geonode_shapekeys-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Grease Converter |[v0.1.0](relative/to/page/grease_converter-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Lattice Magic |[v0.1.0](relative/to/page/lattice_magic-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Lighting Overrider | [v0.1.0](relative/to/page/lighting_overrider-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Pose Shape Keys| [v0.1.0](relative/to/page/pose_shape_keys-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| +|Render Review |[v0.1.0](relative/to/page/render_review-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| ## Anim Cupboard -- 2.30.2 From 4a8c8c936fa842a4b841cd2837008d9a87e0a135 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Thu, 1 Jun 2023 19:45:47 +0200 Subject: [PATCH 36/43] Deploy: Update run:publish to sync dist add-ons --- docs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/package.json b/docs/package.json index 21555acd..cc083234 100644 --- a/docs/package.json +++ b/docs/package.json @@ -10,7 +10,7 @@ "docs:dev": "vitepress dev", "docs:build": "vitepress build", "docs:preview": "vitepress preview", - "docs:publish": "vitepress build && source .env && rsync -ravz -e \"ssh\" .vitepress/dist/ $DESTINATION" + "docs:publish": "vitepress build && source .env && rsync -ravz -e \"ssh\" .vitepress/dist/ $DESTINATION && rsync -ravz -e \"ssh\" ../dist/ $DESTINATION/download" }, "dependencies": { "@fontsource/heebo": "^4.5.15", -- 2.30.2 From df3196628dfa589f355787f9958b029574695794 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Thu, 1 Jun 2023 14:26:14 -0400 Subject: [PATCH 37/43] Release System: Move descriptions into table & update links - Add oneline descriptions to download table - Remove old descriptions - Update description of page to include link to issues board --- scripts-blender/README.md | 133 +++++--------------------------------- 1 file changed, 17 insertions(+), 116 deletions(-) diff --git a/scripts-blender/README.md b/scripts-blender/README.md index c05b717b..c611c960 100644 --- a/scripts-blender/README.md +++ b/scripts-blender/README.md @@ -1,120 +1,21 @@ # Blender Add-ons -Most add-ons used in the Blender Studio pipeline. +Add-ons used by the Blender Studio pipeline. Download the latest addons releases from the table below. To review or report issues visit the [Blender-Studio-Pipeline](https://projects.blender.org/studio/blender-studio-pipeline/issues) issues board. -| Add-on | Version | Checksum | -|---|---|---| -|Anim Cupboard | [v0.0.1](relative/to/page/anim_cupboard-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Asset Pipeline | [v0.1.0](relative/to/page/asset_pipeline-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Blender Kitsu|[v0.1.0](relative/to/page/blender_kitsu-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Blender SVN | [v0.2.0](relative/to/page/blender_svn-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Blender Gizmos|[v0.0.1](relative/to/page/blender_gizmos-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Cache Manager |[v0.2.0](relative/to/page/cache_manager-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Contact Sheet | [v0.1.0](relative/to/page/contact_sheet-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Easy Weights |[v0.0.1](relative/to/page/easy_wights-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Geonode Shapekeys | [v0.0.1](relative/to/page/geonode_shapekeys-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Grease Converter |[v0.1.0](relative/to/page/grease_converter-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Lattice Magic |[v0.1.0](relative/to/page/lattice_magic-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Lighting Overrider | [v0.1.0](relative/to/page/lighting_overrider-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Pose Shape Keys| [v0.1.0](relative/to/page/pose_shape_keys-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| -|Render Review |[v0.1.0](relative/to/page/render_review-0.1.0.zip) |[SHA256](relative/to/page/{addon_name+version}.sha256)| - - -## Anim Cupboard - -Add-on with miscellaneous tools for animators. - -Author & Maintainer: Demeter Dzadik - - -## Asset Pipeline - -Add-on that manages the Asset Pipeline, used by Modeling, Shading and Rigging departments to be able to work on different aspects of the same asset, primarily characters. Each department works in their own files (char.modeling, char.shading, char.rigging), and push and pull changes from a publish file (char.v001.blend), where all the different data is combined into the final character file. - -Most of the actual data transferring code is in a file that is NOT part of the add-on. This file is in the production SVN, under `pro/config/asset_pipeline_config/task_layers.py`. - -Author: Paul Golter -Maintainers: Demeter Dzadik, Simon Thommes - - -## Blender Kitsu - -Add-on used by animation, layout, and editorial department to push video files of shot versions to Kitsu. It also has features that are not directly related to Kitsu but support certain aspects of the Blender Studio Pipeline. - -**Shot Builder** : tools used by animators or TDs to build .blend files by pulling in shot data from a production's Kitsu database, by linking characters, sets, and props that are used by a given shot. Author: Jeroen Bakker - -**Anim Setup** : Sub-module that automates the setup of animation within shot_builder. Author: Paul Golter - -Author: Paul Golter -Maintainers: Nick Alberelli, Francesco Siddi, Demeter Dzadik - -## Blender Svn - -Add-on that is intended as a UI for the SVN (Subversion) file versioning system which we use at the studio. Currently doesn't support check-out, but once a check-out is done, it supports all common SVN operations, including resolving conflicts. The currently opened .blend file must be in an SVN repository for the UI to appear. - -Author & Maintainer: Demeter Dzadik - - -## Bone Gizmos - -Add-on that attempts to prototype a system for using meshes for the manipulation of armatures. Design task: https://projects.blender.org/blender/blender/issues/92218 - -Author & Maintainer: Demeter Dzadik - -## Cache Manager - -Add-on to streamline the alembic cache workflow of assets. - -Author: Paul Golter - -## Contact Sheet - -Add-on to create a contactsheet from sequence editor strips. - -Author: Paul Golter - -## Easy Weights - -Easy Weight is an addon focused on quality of life improvements for weight painting in Blender. - -Author & Maintainer: Demeter Dzadik - -## Geonode Shapekeys - -Add-on used by animators to sculpt on linked and overridden meshes. - -Author & Maintainer: Demeter Dzadik - -## Grease Converter - -Add-on that can convert annotations to grease pencil objects and vise versa. - -Author: Paul Golter - -## Lattice Magic - -This addon adds some Lattice-based utilities to Blender. - -Author & Maintainer: Demeter Dzadik - -## Lighting Overrider - -Add-on to create, manage and apply python overrides in a flexible and reliable way as they are used in the lighting process of the Blender Studio pipeline on a shot and sequence level. - -Author & Maintainer: Simon Thommes - - -## Pose Shape Keys - -Add-on used by the rigging department to manage and maintain shapekeys. - -Author & Maintainer: Demeter Dzadik - - -## Render Review - -Add-on to review renders from flamenco with the sequence editor, and push and approve them on Kitsu. - -Author: Paul Golter -Maintainer: Demeter Dzadik \ No newline at end of file +| Add-on | Description | Version | Checksum | +|---|---|---|---| +|Anim Cupboard |Add-on with miscellaneous tools for animators. | [v0.0.1](download/anim_cupboard/anim_cupboard-0.1.0.zip) |[SHA256](download/anim_cupboard/anim_cupboard-0.1.0.sha256)| +|Asset Pipeline |Add-on that manages the Asset Pipeline, used by Modeling, Shading and Rigging departments. |[v0.1.0](download/asset_pipeline/asset_pipeline-0.1.0.zip) |[SHA256](download/asset_pipeline/asset_pipeline-0.1.0.sha256)| +|Blender Kitsu|Enforce conventions, build shots, manage production files and update data on kitsu server. |[v0.1.0](download/blender_kitsu/blender_kitsu-0.1.0.zip) |[SHA256](download/blender_kitsu/blender_kitsu-0.1.0.sha256)| +|Blender SVN |Add-on that is intended as a UI for the SVN (Subversion) file versioning system which we use at the studio. | [v0.2.0](download/blender_svn/blender_svn-0.1.0.zip) |[SHA256](download/blender_svn/blender_svn-0.1.0.sha256)| +|Blender Gizmos|Add-on that attempts to prototype a system for using meshes for the manipulation of armatures. |[v0.0.1](download/bone_gizmos/blender_gizmos-0.1.0.zip) |[SHA256](download/bone_gizmos/blender_gizmos-0.1.0.sha256)| +|Cache Manager |Streamline the alembic cache workflow of assets. |[v0.2.0](download/cache_manager/cache_manager-0.1.0.zip) |[SHA256](download/cache_manager/cache_manager-0.1.0.sha256)| +|Contact Sheet |Create a contactsheet from sequence editor strips. | [v0.1.0](download/contactsheet/contact_sheet-0.1.0.zip) |[SHA256](download/contactsheet/contact_sheet-0.1.0.sha256)| +|Easy Weights |Easy Weight is an addon focused on quality of life improvements for weight painting in Blender. |[v0.0.1](download/easy_wights/easy_wights-0.1.0.zip) |[SHA256](download/easy_wights/easy_wights-0.1.0.sha256)| +|Geonode Shapekeys |Add-on used by animators to sculpt on linked and overridden meshes. | [v0.0.1](download/geonode_shapekeys/geonode_shapekeys-0.1.0.zip) |[SHA256](download/geonode_shapekeys/geonode_shapekeys-0.1.0.sha256)| +|Grease Converter |Add-on that can convert annotations to grease pencil objects and vise versa. |[v0.1.0](download/grease_converter/grease_converter-0.1.0.zip) |[SHA256](download/grease_converter/grease_converter-0.1.0.sha256)| +|Lattice Magic |This addon adds some Lattice-based utilities to Blender. |[v0.1.0](download/lattice_magic/lattice_magic-0.1.0.zip) |[SHA256](download/lattice_magic/lattice_magic-0.1.0.sha256)| +|Lighting Overrider |Ccreate, manage and apply python overrides in a flexible and reliable way. | [v0.1.0](download/lighting_overrider/lighting_overrider-0.1.0.zip) |[SHA256](downloadlighting_overrider/lighting_overrider-0.1.0.sha256)| +|Pose Shape Keys|Add-on used by the rigging department to manage and maintain shapekeys. |[v0.1.0](download/pose_shape_keys/pose_shape_keys-0.1.0.zip) |[SHA256](download/pose_shape_keys/pose_shape_keys-0.1.0.sha256)| +|Render Review |Review renders from flamenco with the sequence editor. |[v0.1.0](download/render_review/render_review-0.1.0.zip) |[SHA256](download/render_review/render_review-0.1.0.sha256)| \ No newline at end of file -- 2.30.2 From 904380d16d613b1d52baf46f5dec0b639106de61 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Thu, 1 Jun 2023 16:09:08 -0400 Subject: [PATCH 38/43] Release System: Add CLI argument to force version bump --- scripts/pipeline-release/README.md | 2 + .../pipeline_release/__main__.py | 40 ++++++++++++------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/scripts/pipeline-release/README.md b/scripts/pipeline-release/README.md index 94f0c2ab..8e17b05a 100644 --- a/scripts/pipeline-release/README.md +++ b/scripts/pipeline-release/README.md @@ -25,6 +25,7 @@ This folder contains a command line tool that doesn't require installation to us | -b, --bump|Bump the major version number, otherwise bump minor version| | -n --name| Name of addon(s) folder to update. All addons will be checked if flag is not provided| | -m --msg| Title of commit to consider basis of latest release, otherwise the last commit called 'Version Bump:' will be used| +| -f --force|Bump version even if no commits are found| | -h, --help| show the above help message and exit| @@ -57,5 +58,6 @@ Blender Kitsu: Fix naming conventions | ----------- | ----------- | |Create a new minor version if available of all addons|`python -m pipeline_release`| |Create a new major version if available of all addons|`python -m pipeline_release -b`| +|Create a new version even no new commits are found|`python -m pipeline_release` -f| |Only check if addon has this name(s) |`python -m pipeline_release -n "blender_kitsu, blender_svn"`| |Find a commit that matches this message and uses as version basis otherwise the last commit called 'Version Bump:' will be used |`python -m pipeline_release -m "Commit MSG"`| \ No newline at end of file diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 5362a038..30ff591b 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -96,6 +96,13 @@ parser.add_argument( action="store_true", ) +parser.add_argument( + "-f", + "--force", + help="Bump version even if no commits are found", + action="store_true", +) + def cli_command(command: str) -> subprocess: """Run command in CLI and capture it's output @@ -182,19 +189,22 @@ def changelog_generate(commit_hashes: list[str], version: str) -> str: log_entry = f'## {version} - {datetime.date.today()} \n \n' changelog_messages = [] - for commit in commit_hashes: - message = f"{cli_command(f'git log --pretty=format:%s -n 1 {commit}').stdout}\n" - changelog_messages.append(parse_commit(message)) + if commit_hashes is not None: + for commit in commit_hashes: + message = ( + f"{cli_command(f'git log --pretty=format:%s -n 1 {commit}').stdout}\n" + ) + changelog_messages.append(parse_commit(message)) - for type in TYPES: - log_entry += changelog_category_get( - changelog_messages, TYPES.get(type).upper(), TYPES.get(type) - ) + for type in TYPES: + log_entry += changelog_category_get( + changelog_messages, TYPES.get(type).upper(), TYPES.get(type) + ) - log_entry += "### UN-CATEGORIZED \n" - for commit in changelog_messages: - if commit["message"] not in log_entry: - log_entry += f"- {commit['message']}" + log_entry += "### UN-CATEGORIZED \n" + for commit in changelog_messages: + if commit["message"] not in log_entry: + log_entry += f"- {commit['message']}" log_entry += "\n" return log_entry @@ -253,7 +263,7 @@ def changelog_file_write(file_path: Path, content: str): return file_path -def addon_package(directory: Path, commit_prefix: str, is_major=False): +def addon_package(directory: Path, commit_prefix: str, is_major=False, force=False): """ For a give directory, if new commits are found after the commit matching 'commit_prefix', bump addon version, generate a changelog, commit changes and package addon into an archive. @@ -266,7 +276,7 @@ def addon_package(directory: Path, commit_prefix: str, is_major=False): commit_msg = 'Version Bump:' if commit_prefix is None else commit_prefix commits_in_folder = changelog_commits_get(directory, commit_msg) output_zips_path = get_directory(Path(__file__).parent.parent.parent.parent, "dist") - if commits_in_folder: + if commits_in_folder or force: init_file, version = addon_version_bump(directory, is_major) change_log = changelog_generate(commits_in_folder, version) change_log_file = changelog_file_write( @@ -292,7 +302,6 @@ def addon_package(directory: Path, commit_prefix: str, is_major=False): addon_output_dir.joinpath(f"{name}_{version}.sha256"), f"{checksum} {name}_{version}.zip", ) - else: print(f"No New Version: {directory.name}") @@ -356,6 +365,7 @@ def main() -> int: msg = args.msg bump = args.bump user_names = args.name + force = args.force addon_folder = main_dir.joinpath(main_dir, "scripts-blender/addons") addon_dirs = [ name @@ -370,7 +380,7 @@ def main() -> int: ] for dir in addon_dirs: addon_to_package = addon_folder.joinpath(addon_folder, dir) - addon_package(addon_to_package, msg, bump) + addon_package(addon_to_package, msg, bump, force) return 0 -- 2.30.2 From 4d0d2860f6e6cfbfd87dbb061cc0c658435dcc12 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Thu, 1 Jun 2023 16:15:48 -0400 Subject: [PATCH 39/43] Release System: Fix Download Link Version Numbers - Match version numbers to output of script using --force arg --- scripts-blender/README.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts-blender/README.md b/scripts-blender/README.md index c611c960..fda1851d 100644 --- a/scripts-blender/README.md +++ b/scripts-blender/README.md @@ -5,17 +5,17 @@ Add-ons used by the Blender Studio pipeline. Download the latest addons releases | Add-on | Description | Version | Checksum | |---|---|---|---| -|Anim Cupboard |Add-on with miscellaneous tools for animators. | [v0.0.1](download/anim_cupboard/anim_cupboard-0.1.0.zip) |[SHA256](download/anim_cupboard/anim_cupboard-0.1.0.sha256)| -|Asset Pipeline |Add-on that manages the Asset Pipeline, used by Modeling, Shading and Rigging departments. |[v0.1.0](download/asset_pipeline/asset_pipeline-0.1.0.zip) |[SHA256](download/asset_pipeline/asset_pipeline-0.1.0.sha256)| -|Blender Kitsu|Enforce conventions, build shots, manage production files and update data on kitsu server. |[v0.1.0](download/blender_kitsu/blender_kitsu-0.1.0.zip) |[SHA256](download/blender_kitsu/blender_kitsu-0.1.0.sha256)| -|Blender SVN |Add-on that is intended as a UI for the SVN (Subversion) file versioning system which we use at the studio. | [v0.2.0](download/blender_svn/blender_svn-0.1.0.zip) |[SHA256](download/blender_svn/blender_svn-0.1.0.sha256)| -|Blender Gizmos|Add-on that attempts to prototype a system for using meshes for the manipulation of armatures. |[v0.0.1](download/bone_gizmos/blender_gizmos-0.1.0.zip) |[SHA256](download/bone_gizmos/blender_gizmos-0.1.0.sha256)| -|Cache Manager |Streamline the alembic cache workflow of assets. |[v0.2.0](download/cache_manager/cache_manager-0.1.0.zip) |[SHA256](download/cache_manager/cache_manager-0.1.0.sha256)| -|Contact Sheet |Create a contactsheet from sequence editor strips. | [v0.1.0](download/contactsheet/contact_sheet-0.1.0.zip) |[SHA256](download/contactsheet/contact_sheet-0.1.0.sha256)| -|Easy Weights |Easy Weight is an addon focused on quality of life improvements for weight painting in Blender. |[v0.0.1](download/easy_wights/easy_wights-0.1.0.zip) |[SHA256](download/easy_wights/easy_wights-0.1.0.sha256)| -|Geonode Shapekeys |Add-on used by animators to sculpt on linked and overridden meshes. | [v0.0.1](download/geonode_shapekeys/geonode_shapekeys-0.1.0.zip) |[SHA256](download/geonode_shapekeys/geonode_shapekeys-0.1.0.sha256)| -|Grease Converter |Add-on that can convert annotations to grease pencil objects and vise versa. |[v0.1.0](download/grease_converter/grease_converter-0.1.0.zip) |[SHA256](download/grease_converter/grease_converter-0.1.0.sha256)| -|Lattice Magic |This addon adds some Lattice-based utilities to Blender. |[v0.1.0](download/lattice_magic/lattice_magic-0.1.0.zip) |[SHA256](download/lattice_magic/lattice_magic-0.1.0.sha256)| -|Lighting Overrider |Ccreate, manage and apply python overrides in a flexible and reliable way. | [v0.1.0](download/lighting_overrider/lighting_overrider-0.1.0.zip) |[SHA256](downloadlighting_overrider/lighting_overrider-0.1.0.sha256)| -|Pose Shape Keys|Add-on used by the rigging department to manage and maintain shapekeys. |[v0.1.0](download/pose_shape_keys/pose_shape_keys-0.1.0.zip) |[SHA256](download/pose_shape_keys/pose_shape_keys-0.1.0.sha256)| -|Render Review |Review renders from flamenco with the sequence editor. |[v0.1.0](download/render_review/render_review-0.1.0.zip) |[SHA256](download/render_review/render_review-0.1.0.sha256)| \ No newline at end of file +|Anim Cupboard |Add-on with miscellaneous tools for animators. | [v0.0.2](download/anim_cupboard/anim_cupboard-0.0.2.zip) |[SHA256](download/anim_cupboard/anim_cupboard-0.0.2.sha256)| +|Asset Pipeline |Add-on that manages the Asset Pipeline, used by Modeling, Shading and Rigging departments. |[v0.1.1](download/asset_pipeline/asset_pipeline-0.1.1.zip) |[SHA256](download/asset_pipeline/asset_pipeline-0.1.1.sha256)| +|Blender Kitsu|Enforce conventions, build shots, manage production files and update data on kitsu server. |[v0.1.1](download/blender_kitsu/blender_kitsu-0.1.1.zip) |[SHA256](download/blender_kitsu/blender_kitsu-0.1.1.sha256)| +|Blender SVN |Add-on that is intended as a UI for the SVN (Subversion) file versioning system which we use at the studio. | [v0.2.1](download/blender_svn/blender_svn-0.2.1.zip) |[SHA256](download/blender_svn/blender_svn-0.2.1.sha256)| +|Blender Gizmos|Add-on that attempts to prototype a system for using meshes for the manipulation of armatures. |[v0.0.2](download/bone_gizmos/blender_gizmos-0.0.2.zip) |[SHA256](download/bone_gizmos/blender_gizmos-0.0.2.sha256)| +|Cache Manager |Streamline the alembic cache workflow of assets. |[v0.2.1](download/cache_manager/cache_manager-0.2.1.zip) |[SHA256](download/cache_manager/cache_manager-0.2.1.sha256)| +|Contact Sheet |Create a contactsheet from sequence editor strips. | [v0.1.1](download/contactsheet/contact_sheet-0.1.1.zip) |[SHA256](download/contactsheet/contact_sheet-0.1.1.sha256)| +|Easy Weights |Easy Weight is an addon focused on quality of life improvements for weight painting in Blender. |[v0.0.2](download/easy_wights/easy_wights-0.0.2.zip) |[SHA256](download/easy_wights/easy_wights-0.0.2.sha256)| +|Geonode Shapekeys |Add-on used by animators to sculpt on linked and overridden meshes. | [v0.0.2](download/geonode_shapekeys/geonode_shapekeys-0.0.2.zip) |[SHA256](download/geonode_shapekeys/geonode_shapekeys-0.0.2.sha256)| +|Grease Converter |Add-on that can convert annotations to grease pencil objects and vise versa. |[v0.1.1](download/grease_converter/grease_converter-0.1.1.zip) |[SHA256](download/grease_converter/grease_converter-0.1.1.sha256)| +|Lattice Magic |This addon adds some Lattice-based utilities to Blender. |[v0.1.1](download/lattice_magic/lattice_magic-0.1.1.zip) |[SHA256](download/lattice_magic/lattice_magic-0.1.1.sha256)| +|Lighting Overrider |Ccreate, manage and apply python overrides in a flexible and reliable way. | [v0.1.1](download/lighting_overrider/lighting_overrider-0.1.1.zip) |[SHA256](downloadlighting_overrider/lighting_overrider-0.1.1.sha256)| +|Pose Shape Keys|Add-on used by the rigging department to manage and maintain shapekeys. |[v0.0.2](download/pose_shape_keys/pose_shape_keys-0.0.2.zip) |[SHA256](download/pose_shape_keys/pose_shape_keys-0.1.1.sha256)| +|Render Review |Review renders from flamenco with the sequence editor. |[v0.1.1](download/render_review/render_review-0.1.1.zip) |[SHA256](download/render_review/render_review-0.1.1.sha256)| \ No newline at end of file -- 2.30.2 From 926c569f5aafa4fc2c61c6fc563be7bd95714424 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Thu, 1 Jun 2023 16:19:46 -0400 Subject: [PATCH 40/43] Release System: Add variable for top level repo directory --- scripts/pipeline-release/pipeline_release/__main__.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index 30ff591b..c1680500 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -31,7 +31,7 @@ import re from typing import Pattern import datetime - +REPO_ROOT_DIR = Path(__file__).parent.parent.parent.parent # BORROWED FROM https://github.com/pawamoy/git-changelog/blob/master/src/git_changelog/commit.py TYPES: dict[str, str] = { "add": "Added", @@ -275,7 +275,7 @@ def addon_package(directory: Path, commit_prefix: str, is_major=False, force=Fal """ commit_msg = 'Version Bump:' if commit_prefix is None else commit_prefix commits_in_folder = changelog_commits_get(directory, commit_msg) - output_zips_path = get_directory(Path(__file__).parent.parent.parent.parent, "dist") + output_zips_path = get_directory(REPO_ROOT_DIR, "dist") if commits_in_folder or force: init_file, version = addon_version_bump(directory, is_major) change_log = changelog_generate(commits_in_folder, version) @@ -361,12 +361,11 @@ def addon_version_bump(directory: Path, is_major: bool): def main() -> int: args = parser.parse_args() - main_dir = Path(__file__).parent.parent.parent.parent msg = args.msg bump = args.bump user_names = args.name force = args.force - addon_folder = main_dir.joinpath(main_dir, "scripts-blender/addons") + addon_folder = REPO_ROOT_DIR.joinpath(REPO_ROOT_DIR, "scripts-blender/addons") addon_dirs = [ name for name in os.listdir(addon_folder) -- 2.30.2 From d86b39050420b3bb1f575d358ba0578e9e921ded Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Thu, 1 Jun 2023 16:20:59 -0400 Subject: [PATCH 41/43] Release System: Rename dist_dir variable --- scripts/pipeline-release/pipeline_release/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release/__main__.py index c1680500..675f14ee 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release/__main__.py @@ -275,7 +275,7 @@ def addon_package(directory: Path, commit_prefix: str, is_major=False, force=Fal """ commit_msg = 'Version Bump:' if commit_prefix is None else commit_prefix commits_in_folder = changelog_commits_get(directory, commit_msg) - output_zips_path = get_directory(REPO_ROOT_DIR, "dist") + dist_dir = get_directory(REPO_ROOT_DIR, "dist") if commits_in_folder or force: init_file, version = addon_version_bump(directory, is_major) change_log = changelog_generate(commits_in_folder, version) @@ -292,7 +292,7 @@ def addon_package(directory: Path, commit_prefix: str, is_major=False, force=Fal ) print(f"Version Bump: {directory.name} {version}") name = directory.name - addon_output_dir = get_directory(output_zips_path, directory.name) + addon_output_dir = get_directory(dist_dir, directory.name) zipped_addon = shutil.make_archive( addon_output_dir.joinpath(f"{name}_{version}"), 'zip', directory -- 2.30.2 From 476a8f461061dd0d668f09372225c6415aab2745 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Thu, 1 Jun 2023 16:25:34 -0400 Subject: [PATCH 42/43] Release System: Remove Installation Logic - Rename `__main__.py` to `pipeline_release.py` - remove `setup.py` -remove extra directory - adjust REPO_ROOT_DIR variable to reflect directory change --- .../__main__.py => pipeline_release.py} | 2 +- scripts/pipeline-release/setup.py | 31 ------------------- 2 files changed, 1 insertion(+), 32 deletions(-) rename scripts/pipeline-release/{pipeline_release/__main__.py => pipeline_release.py} (99%) delete mode 100644 scripts/pipeline-release/setup.py diff --git a/scripts/pipeline-release/pipeline_release/__main__.py b/scripts/pipeline-release/pipeline_release.py similarity index 99% rename from scripts/pipeline-release/pipeline_release/__main__.py rename to scripts/pipeline-release/pipeline_release.py index 675f14ee..258380ce 100644 --- a/scripts/pipeline-release/pipeline_release/__main__.py +++ b/scripts/pipeline-release/pipeline_release.py @@ -31,7 +31,7 @@ import re from typing import Pattern import datetime -REPO_ROOT_DIR = Path(__file__).parent.parent.parent.parent +REPO_ROOT_DIR = Path(__file__).parent.parent.parent # BORROWED FROM https://github.com/pawamoy/git-changelog/blob/master/src/git_changelog/commit.py TYPES: dict[str, str] = { "add": "Added", diff --git a/scripts/pipeline-release/setup.py b/scripts/pipeline-release/setup.py deleted file mode 100644 index 6ddf65d5..00000000 --- a/scripts/pipeline-release/setup.py +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python -"""The setup script for pipeline-release.""" - -from setuptools import setup - -with open("README.md") as readme_file: - readme = readme_file.read() - - -setup( - author="Nick Alberelli", - author_email="nick@blender.org", - python_requires=">=3.5", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Natural Language :: English", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - ], - description="Command line tool to perform recursive crawl blend files from the console", - long_description=readme, - keywords="pipeline_release", - name="pipeline_release", - packages=["pipeline_release", "pipeline_release.default_scripts",], - version="0.1.1", - entry_points={"console_scripts": ["pipeline_release = pipeline_release.__main__:main"]}, -) -- 2.30.2 From 6d0b128e2241f184b973ba657457de5be08c42c7 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Fri, 2 Jun 2023 12:38:54 -0400 Subject: [PATCH 43/43] Release System: Replace '_' with '-' in addon package names --- scripts/pipeline-release/pipeline_release.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/pipeline-release/pipeline_release.py b/scripts/pipeline-release/pipeline_release.py index 258380ce..b824748b 100644 --- a/scripts/pipeline-release/pipeline_release.py +++ b/scripts/pipeline-release/pipeline_release.py @@ -295,12 +295,12 @@ def addon_package(directory: Path, commit_prefix: str, is_major=False, force=Fal addon_output_dir = get_directory(dist_dir, directory.name) zipped_addon = shutil.make_archive( - addon_output_dir.joinpath(f"{name}_{version}"), 'zip', directory + addon_output_dir.joinpath(f"{name}-{version}"), 'zip', directory ) checksum = generate_checksum(zipped_addon) checksum_file = write_file( - addon_output_dir.joinpath(f"{name}_{version}.sha256"), - f"{checksum} {name}_{version}.zip", + addon_output_dir.joinpath(f"{name}-{version}.sha256"), + f"{checksum} {name}-{version}.zip", ) else: print(f"No New Version: {directory.name}") -- 2.30.2