-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(changelog): add auto changelog (release)
- Loading branch information
1 parent
8148149
commit 79ce777
Showing
2 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
num_tags=60 | ||
excluded_author="GitHub" | ||
project_url="https://github.com/AxaFrance/slight-capture/commit" | ||
|
||
# Get all tag names in reverse order | ||
tags=(`git tag -l --sort=-creatordate | head -$num_tags`) | ||
|
||
# File to save the log | ||
outfile=CHANGELOG.md | ||
|
||
# Write the header | ||
echo "# Changelog" > $outfile | ||
echo "" >> $outfile | ||
|
||
# Iterate over tags array | ||
for((i=0; i<${#tags[@]}-1; i++)) | ||
do | ||
# current tag | ||
current=${tags[$i]} | ||
# previous tag | ||
previous=${tags[$i+1]} | ||
|
||
# Write header for current tag | ||
echo "## $current" >> $outfile | ||
echo "## $current" | ||
echo "" >> $outfile | ||
|
||
# Get commit hashes: between current and previous tag | ||
hashes=(`git log --pretty=format:"%H" $previous..$current`) | ||
|
||
# Output commit log for each hash | ||
for hash in ${hashes[@]} | ||
do | ||
# Check the author of the commit | ||
author=$(git log -1 --pretty=format:"%an" $hash) | ||
|
||
# Exclude commits from the specified author | ||
if [ "$author" != "$excluded_author" ]; then | ||
# Get commit log in the desired format. | ||
# You can modify the 'format' as per your need. Please refer 'PRETTY FORMATS' section of git-log man page | ||
log=$(git log -1 --pretty=format:"[%h]($project_url/%H) - %s, %ad by *%an*" --date=short $hash) | ||
|
||
# Write formatted log to CHANGELOG.md file | ||
echo "- $log" >> $outfile | ||
echo "- $log" | ||
fi | ||
done | ||
|
||
# Space between two tags | ||
echo "" >> $outfile | ||
echo "" >> $outfile | ||
done |