Skip to content

Commit 7a98cb8

Browse files
committed
fix: cd release note and list commits
1 parent b26871e commit 7a98cb8

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

.github/workflows/cd.yml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -80,28 +80,28 @@ jobs:
8080
run: |
8181
git fetch
8282
last_tag=${{ steps.previous_tag.outputs.previous_tag }}
83-
commit_range="${last_tag}..HEAD"
83+
commit_range=$(git rev-list --abbrev-commit --reverse ${last_tag}..HEAD)
8484
major=$(echo "$last_tag" | cut -d. -f1)
8585
minor=$(echo "$last_tag" | cut -d. -f2)
8686
patch=$(echo "$last_tag" | cut -d. -f3)
8787
has_feat=false
8888
has_breaking_change=false
89-
while IFS= read -r line; do
90-
echo $line
91-
case "$line" in
89+
for hash in $commit_range; do
90+
subject=$(git log --format="%s" -n 1 $hash)
91+
case "$subject" in
9292
*'feat:'*)
93-
echo "has_feat=true because of [$line]"
93+
echo "has_feat=true because of [$subject]"
9494
has_feat=true
9595
;;
9696
*'BREAKING CHANGE:'*)
97-
echo "has_breaking_change=true because of [$line]"
97+
echo "has_breaking_change=true because of [$subject]"
9898
has_breaking_change=true
9999
;;
100100
*)
101-
echo "not feat not breaking change, commit -> [$line]"
101+
echo "not feat not breaking change, commit -> [$subject]"
102102
;;
103103
esac
104-
done < <(git log --pretty=format:"%s" "$commit_range")
104+
done
105105
if [ "$has_breaking_change" = true ]; then
106106
major=$((major + 1))
107107
minor=0
@@ -116,7 +116,6 @@ jobs:
116116
echo "NEW VERSION SHOULD BE => $new_version"
117117
echo "::set-output name=new_version::$new_version"
118118
119-
120119

121120
- name: Create new tag
122121
id: new_tag
@@ -135,26 +134,27 @@ jobs:
135134
id: release_notes
136135
run: |
137136
git fetch
137+
commit_range=$(git rev-list --abbrev-commit --reverse ${{ steps.previous_tag.outputs.previous_tag }}..${{ steps.version.outputs.new_version }})
138138
echo "## What's changed" > release_notes.md
139-
git log --pretty=format:"%h %s by @%an" ${{ steps.previous_tag.outputs.previous_tag }}..${{ steps.version.outputs.new_version }} | \
140-
while read line; do
141-
echo $line
142-
case "$line" in
143-
*'feat:'*)
144-
echo "* **Feature:** ${line#*:}" >> release_notes.md
145-
;;
146-
*'fix:'*)
147-
echo "* **Fix:** ${line#*:}" >> release_notes.md
148-
;;
149-
*'BREAKING CHANGE:'*)
150-
echo "* **Breaking Change:** ${line#*:}" >> release_notes.md
151-
;;
152-
*)
153-
echo "* ${line#*:}" >> release_notes.md
154-
;;
155-
esac
139+
140+
for hash in $commit_range; do
141+
subject=$(git log --format="%s" -n 1 $hash)
142+
case "$subject" in
143+
*'BREAKING CHANGE:'*)
144+
echo "* **Breaking Change:** ${line#*:}" >> release_notes.md
145+
;;
146+
*'feat:'*)
147+
echo "* **Feature:** ${line#*:}" >> release_notes.md
148+
has_feat=true
149+
;;
150+
*'fix:'*)
151+
echo "* **Fix:** ${line#*:}" >> release_notes.md
152+
;;
153+
*)
154+
echo "* ${line#*:}" >> release_notes.md
155+
;;
156+
esac
156157
done
157-
158158
echo "" >> release_notes.md
159159
160160
echo "" >> release_notes.md
@@ -177,4 +177,4 @@ jobs:
177177
tag_name: ${{ steps.version.outputs.new_version }}
178178
release_name: Release ${{ steps.version.outputs.new_version }}
179179
body_path: release_notes.md
180-
token: ${{ secrets.GITHUB_TOKEN }}
180+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)