Skip to content

Commit 3b9442b

Browse files
Release 2.0.17 (#60)
* Release 2.0.17 * Reformat --------- Co-authored-by: Denis Tokarev <[email protected]>
1 parent 2a673a0 commit 3b9442b

File tree

3 files changed

+59
-32
lines changed

3 files changed

+59
-32
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
tags:
66
- '*'
7+
workflow_dispatch: {}
78

89
jobs:
910
lint:

.github/workflows/release.yml

Lines changed: 57 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -101,38 +101,51 @@ jobs:
101101
fetch-depth: 0
102102
- name: Generate changelog
103103
run: |
104-
initial_commit=$( git log --reverse --format='%H' | head -n 1 )
105-
printf '\n\ninitial_commit=%s\n\n' "${initial_commit[@]}"
106-
107-
output=''
108-
for tag in $( git tag -l | sort -V ); do
109-
printf 'Processing tag=%s\n' "${tag[@]}"
110-
commits=$( git log --reverse --format='- (%h) %s (%an)' "${initial_commit}".."${tag}" )
111-
if [ ${#commits[@]} -eq 0 ]; then
112-
commits=$( git log --reverse --format='- (%h) %s (%an)' | head -n 1 )
104+
changelog=""
105+
106+
# Get all tags in ascending order
107+
tags=($( git tag --sort=version:refname ))
108+
109+
# Loop through tags to generate the changelog
110+
for ((i=0; i<${#tags[@]}; i++)); do
111+
current_tag="${tags[$i]}"
112+
previous_tag=""
113+
tag_log=""
114+
115+
if [ -z "${current_tag}" ]; then
116+
continue
113117
fi
114-
printf 'commits=<<<COMMITS\n%s\nCOMMITS\n' "${commits[@]}"
115-
section=$( printf '%s\n%s' "## v${tag}" "${commits}" )
116-
initial_commit="${tag}"
117-
step_output=$( printf '%s\n\n' "${section}" )
118-
printf 'version_changelog=<<<CHUNK\n%s\nCHUNK\n\n' "${step_output[@]}"
119-
output=$( printf '%s\n\n' "${step_output}" "${output}" )
120-
done
121-
122-
package_version=$( cat package.json | grep "version" | grep -oE '[0-9.]+' )
123-
last_tag=$( git tag -l | tail -n 1 )
124-
printf 'package_version=%s\nlast_tag=%s\n' "${package_version[@]}" "${last_tag[@]}"
125-
126-
if [ "${package_version}" != "${last_tag}" ]; then
127-
commits=$( git log --reverse --format='- (%h) %s (%an)' "${last_tag}"..HEAD )
128-
if [ ${#commits[@]} -ne 0 ]; then
129-
section=$( printf '%s\n%s' "## v${package_version}" "${commits}" )
130-
output=$( printf '%s\n\n' "${section}" "${output}" )
118+
119+
# Determine the previous tag if not the first tag
120+
if (( i > 0 )); then
121+
previous_tag="${tags[$((i-1))]}"
131122
fi
132-
fi
133-
134-
printf 'Changelog=<<<CHANGELOG\n%s\nCHANGELOG\n\n' "${output[@]}"
135-
printf '%s\n' "${output}" > CHANGELOG.md
123+
124+
# Generate the header for the current tag
125+
tag_log="### ${current_tag}\n"
126+
127+
# Get the commits between the current tag and the previous tag
128+
if [ -n "$previous_tag" ]; then
129+
commits=$(git log --format="%s (%an) [%h]" "${previous_tag}..${current_tag}")
130+
else
131+
# If no previous tag, include all commits up to the first tag
132+
commits=$(git log --format="%s (%an) [%h]" "${current_tag}")
133+
fi
134+
135+
# Add commits to the changelog, one per line
136+
while IFS= read -r commit; do
137+
tag_log+="- ${commit}\n"
138+
done <<< "${commits}"
139+
140+
changelog="${tag_log}\n${changelog}"
141+
done
142+
143+
changelog="# Changelog\n\n${changelog}"
144+
145+
echo -e "${changelog}"
146+
147+
# You can now use the variable $changelog elsewhere in your script
148+
printf '%s' "${changelog}" > CHANGELOG.md
136149
- name: Upload new changelog
137150
uses: actions/upload-artifact@v4
138151
with:
@@ -146,7 +159,7 @@ jobs:
146159
printf 'Committing the updated changelog\n'
147160
git config --local user.name "github-actions[bot]"
148161
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
149-
162+
150163
git add CHANGELOG.md
151164
git commit -am "Update the project changelog"
152165
fi
@@ -173,3 +186,16 @@ jobs:
173186
tag_prefix: ''
174187
tag_suffix: ''
175188
changelog_structure: "**{{messageHeadline}}** {{author}}\n"
189+
trigger_publish:
190+
name: Maybe trigger publish
191+
runs-on: ubuntu-latest
192+
needs: [maybe_tag]
193+
steps:
194+
- name: Checkout
195+
uses: actions/checkout@v4
196+
with:
197+
set-safe-directory: 'true'
198+
- name: Trigger workflow
199+
run: gh workflow run publish.yml --ref $( git describe --tags --abbrev=0 )
200+
env:
201+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "async-wait-until",
3-
"version": "2.0.16",
3+
"version": "2.0.17",
44
"description": "Waits until the given predicate function returns a truthy value, then resolves",
55
"main": "dist/index.js",
66
"module": "./dist/index.esm.js",

0 commit comments

Comments
 (0)