Skip to content

Commit

Permalink
doc(changelog): add auto changelog (release)
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaume-chervet committed Apr 14, 2024
1 parent 8148149 commit 79ce777
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ jobs:
mkdir opencv_build
cd opencv_build
# https://docs.opencv.org/3.4/d4/da1/tutorial_js_setup.html
git clone https://github.com/opencv/opencv.git
git clone -b 4.x https://github.com/opencv/opencv.git --depth 1
cd opencv
sed -i "s/white_list = makeWhiteList(\[core, imgproc, objdetect, video, dnn, features2d, photo, calib3d\])/white_list = makeWhiteList([core, imgproc, features2d, calib3d])/g" ./platforms/js/opencv_js.config.py
docker run --rm -v $(pwd):/src -u $(id -u):$(id -g) emscripten/emsdk:2.0.10 emcmake python3 ./platforms/js/build_js.py build_js
Expand All @@ -141,15 +141,21 @@ jobs:
# git push --force --tags --follow-tags
#
#
- name: Commit Release ${{ steps.tag_release.outputs.new_version }}
uses: stefanzweifel/git-auto-commit-action@v4
- name: Commit and push
if: github.ref == 'refs/heads/main' && steps.which_tag.outputs.tag == 'release'
with:
commit_message: "[skip ci] Release v${{ steps.tag_release.outputs.new_version }}"
commit_user_name: GitHub
commit_user_email: github-action@bot.com
commit_author: GitHub <github-action@bot.com>
push_options: '--force'
run: |
git config --global user.name "GitHub"
git config --global user.email "github-action@bot.com"
git add .
git commit -m "[skip ci] Update to version ${{ steps.tag.outputs.new_version }} in package.json"
git tag ${{ steps.tag.outputs.new_version }}
git push --set-upstream origin "HEAD:main" --follow-tags -f
chmod +x ./bin/generate-changelog.sh
./bin/generate-changelog.sh
git add .
git commit -m "[skip ci] Generate changelog to version ${{ steps.tag.outputs.new_version }}"
git push --set-upstream origin "HEAD:main" --follow-tags -f
- id: publish-slight-capture
uses: JS-DevTools/npm-publish@v1
Expand Down
54 changes: 54 additions & 0 deletions bin/generate-changelog.sh
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

0 comments on commit 79ce777

Please sign in to comment.