-
Notifications
You must be signed in to change notification settings - Fork 0
Add changelog generator #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
@doms99 can you please update your branch from the base as we made some major changes to the base branch that could impact your implementation. Thank you! :) |
5da13a6 to
188491f
Compare
188491f to
3cbf480
Compare
|
@jabou I made required adjustments, let me know how it looks to you |
jabou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! :)
Let's discuss some comments I left in here before we proceed. Once the main implementation is defined and approved, we should consider migration logic or something like that as hitting init will probably override deploy-options.sh we don't want to change.
| # Set to "" if you don't want to use this feature. | ||
| BRANCH_NAME_TASK_MATCHING_REGEX="(<project>-[0-9]+)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # Set to "" if you don't want to use this feature. | |
| BRANCH_NAME_TASK_MATCHING_REGEX="(<project>-[0-9]+)" | |
| # Set to BRANCH_NAME_TASK_MATCHING_REGEX to "" if you don't want to use this feature. | |
| BRANCH_NAME_TASK_MATCHING_REGEX="(<project>-[0-9]+)" |
It should be self-explanatory, but on first reading, I thought that I had to set to ""
|
|
||
| # JIRA project URL. Used by python script to construct a url to specific issue. | ||
| # Replace <project> with your JIRA project name. | ||
| JIRA_PROJECT_URL="https://<project>.atlassian.net" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create a few additional variables at the top of the file where the user will have to write a value for this <project>, and BRANCH_NAME_TASK_MATCHING_REGEX's <project>.
It's always better to write those bash scripts in a way that you have some "global" config variables that the user needs to define/fill (even better, some yaml file, but let's not complicate for now), instead of the user needing to read through the file and search for all templates they have to fill/change.
| echo "Missing JIRA_EMAIL or JIRA_TOKEN. Please add it to your .zshrc or .bash_profile configuration file." | ||
| echo | ||
|
|
||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call exit or return some non 0 code so that program stops with the execution?
| # Task number contained in branch name | ||
| current_branch=`git rev-parse --abbrev-ref HEAD` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the main script already has this info. Please check and use that global var instead of rereading it with git command.
| # Task number contained in branch name | ||
| current_branch=`git rev-parse --abbrev-ref HEAD` | ||
| if [[ $current_branch =~ $BRANCH_NAME_TASK_MATCHING_REGEX ]]; then | ||
| task_numbers=$(printf "%s " "${BASH_REMATCH[@]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful with printf. Not all bash versions support it. I think I had issues with it, so I tried to avoid using it.
| echo "Enter task number contained in this build, separated by space (e.g., <project>-1234 <project>-5678)." | ||
| echo "For manual changelog entry, leave input empty and press enter." | ||
| echo | ||
| read -r -p "Tasks contained in this build (e.g. <project>-1234 <project>-5678): " task_numbers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we have already defined <project> within a global variable for this script, is it necessary for the user to retype it?
Can we maybe ask the user only for the task number (i.e., 1234, 5678) and then construct tasks using <project> from various + entered values?
| fi | ||
|
|
||
| # Select or edit changelog, edit tasks list and generate again | ||
| while true; do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 not sure I would use this approach as this could easily introduce an infinite loop...
execution will be paused when we call for a text editor. Maybe we can just leverage that? E.g., check how creating a regular tag opens the text editor, and while the editor is open, the script waits for input.
| break | ||
| fi | ||
|
|
||
| __call_python_script "$task_numbers" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be sure that whatever is behind __call_python_script, is supported on all Bash versions. Check which version came with macOS (at least 2-3 versions in the past).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know using Python would ease the implementation; however, I would consider using pure bash as much as possible, as with this one, we have now introduced a new dependency and requirement that the user needs to have Python 3.8.
| if [[ ${c} =~ ^(yes|y|Y) ]] || [ -z ${c} ]; then | ||
| __init_deploy_options | ||
| fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user enters N or just hits enter, what would happen if this logic is removed? Will execution stop?
Added ability to add automatic changelog generation.
Projects should add new
.changelog-generator.shfile that definesgenerate_changelogfunction that will be an entry point to the generation flow.Added an example from NutriU (made by @jabou) to generate changelog on projects that use JIRA.