Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 32 additions & 27 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
- name: Generate changelog
run: |
changelog=""

# Get tags newest to oldest
tags=($(git tag --sort=-version:refname))

Expand All @@ -117,8 +117,10 @@ jobs:
else
untagged_commits=$(git --no-pager log --format="%s (%an) [%h]")
fi

future_tag="$( awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json )"

# Get future version from package.json
future_tag="$(awk -F'"' '/"version": ".+"/{ print $4; exit; }' package.json)"

if [ -n "$untagged_commits" ]; then
tag_log="### ${future_tag}\n"
while IFS= read -r commit; do
Expand All @@ -127,32 +129,35 @@ jobs:
changelog="${tag_log}\n${changelog}"
fi

# Loop over all tags, newest to oldest
# Loop from i=0 to i <= tags.length (YES, intentionally +1)
for ((i=0; i<=${#tags[@]}; i++)); do
current="${tags[$i]}"
next=""

if (( i <= ${#tags[@]} - 1 )); then
next="${tags[$((i+1))]}"
commits=$(git --no-pager log --format="%s (%an) [%h]" "${next}..${current}")
else
echo "TAG (current) = (${current})"
commits=$(git --no-pager log --format="%s (%an) [%h]" "${current}")
fi

if [ -n "$commits" ]; then
tag_log="### ${current}\n"
while IFS= read -r commit; do
tag_log+="- ${commit}\n"
done <<< "$commits"
changelog="${changelog}\n${tag_log}"
fi
done

changelog="# Changelog\n${changelog}"

echo -e "$changelog"
printf '%b' "$changelog" > CHANGELOG.md
next="${tags[$((i+1))]}"

# Skip if current is empty (e.g., i == len)
if [ -z "$current" ]; then
continue
fi

if [ -n "$next" ]; then
commits=$(git --no-pager log --format="%s (%an) [%h]" "${next}..${current}")
else
# last tag (oldest), no previous one
commits=$(git --no-pager log --format="%s (%an) [%h]" "${current}")
fi

if [ -n "$commits" ]; then
tag_log="### ${current}\n"
while IFS= read -r commit; do
tag_log+="- ${commit}\n"
done <<< "$commits"
changelog="${changelog}\n${tag_log}"
fi
done

changelog="# Changelog\n${changelog}"
echo -e "$changelog"
printf '%b' "$changelog" > CHANGELOG.md
- name: Upload new changelog
uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "async-wait-until",
"version": "2.0.26",
"version": "2.0.27",
"description": "Waits until the given predicate function returns a truthy value, then resolves",
"main": "./dist/index.js",
"module": "./dist/index.esm.js",
Expand Down