Skip to content

Commit

Permalink
fix: cd release note and list commits
Browse files Browse the repository at this point in the history
  • Loading branch information
brunograna committed Feb 19, 2024
1 parent b26871e commit 7a98cb8
Showing 1 changed file with 28 additions and 28 deletions.
56 changes: 28 additions & 28 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,28 @@ jobs:
run: |
git fetch
last_tag=${{ steps.previous_tag.outputs.previous_tag }}
commit_range="${last_tag}..HEAD"
commit_range=$(git rev-list --abbrev-commit --reverse ${last_tag}..HEAD)
major=$(echo "$last_tag" | cut -d. -f1)
minor=$(echo "$last_tag" | cut -d. -f2)
patch=$(echo "$last_tag" | cut -d. -f3)
has_feat=false
has_breaking_change=false
while IFS= read -r line; do
echo $line
case "$line" in
for hash in $commit_range; do
subject=$(git log --format="%s" -n 1 $hash)
case "$subject" in
*'feat:'*)
echo "has_feat=true because of [$line]"
echo "has_feat=true because of [$subject]"
has_feat=true
;;
*'BREAKING CHANGE:'*)
echo "has_breaking_change=true because of [$line]"
echo "has_breaking_change=true because of [$subject]"
has_breaking_change=true
;;
*)
echo "not feat not breaking change, commit -> [$line]"
echo "not feat not breaking change, commit -> [$subject]"
;;
esac
done < <(git log --pretty=format:"%s" "$commit_range")
done
if [ "$has_breaking_change" = true ]; then
major=$((major + 1))
minor=0
Expand All @@ -116,7 +116,6 @@ jobs:
echo "NEW VERSION SHOULD BE => $new_version"
echo "::set-output name=new_version::$new_version"


- name: Create new tag
id: new_tag
Expand All @@ -135,26 +134,27 @@ jobs:
id: release_notes
run: |
git fetch
commit_range=$(git rev-list --abbrev-commit --reverse ${{ steps.previous_tag.outputs.previous_tag }}..${{ steps.version.outputs.new_version }})
echo "## What's changed" > release_notes.md
git log --pretty=format:"%h %s by @%an" ${{ steps.previous_tag.outputs.previous_tag }}..${{ steps.version.outputs.new_version }} | \
while read line; do
echo $line
case "$line" in
*'feat:'*)
echo "* **Feature:** ${line#*:}" >> release_notes.md
;;
*'fix:'*)
echo "* **Fix:** ${line#*:}" >> release_notes.md
;;
*'BREAKING CHANGE:'*)
echo "* **Breaking Change:** ${line#*:}" >> release_notes.md
;;
*)
echo "* ${line#*:}" >> release_notes.md
;;
esac
for hash in $commit_range; do
subject=$(git log --format="%s" -n 1 $hash)
case "$subject" in
*'BREAKING CHANGE:'*)
echo "* **Breaking Change:** ${line#*:}" >> release_notes.md
;;
*'feat:'*)
echo "* **Feature:** ${line#*:}" >> release_notes.md
has_feat=true
;;
*'fix:'*)
echo "* **Fix:** ${line#*:}" >> release_notes.md
;;
*)
echo "* ${line#*:}" >> release_notes.md
;;
esac
done
echo "" >> release_notes.md
echo "" >> release_notes.md
Expand All @@ -177,4 +177,4 @@ jobs:
tag_name: ${{ steps.version.outputs.new_version }}
release_name: Release ${{ steps.version.outputs.new_version }}
body_path: release_notes.md
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 7a98cb8

Please sign in to comment.