From 3b9442bf4bbee97b1c1ceebbb413d968c7f98c2a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sun, 8 Dec 2024 20:17:25 +1100 Subject: [PATCH] Release 2.0.17 (#60) * Release 2.0.17 * Reformat --------- Co-authored-by: Denis Tokarev --- .github/workflows/publish.yml | 1 + .github/workflows/release.yml | 88 +++++++++++++++++++++++------------ package.json | 2 +- 3 files changed, 59 insertions(+), 32 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8ccd3e2..70ed9cb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -4,6 +4,7 @@ on: push: tags: - '*' + workflow_dispatch: {} jobs: lint: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bf116e2..c2c9186 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -101,38 +101,51 @@ jobs: fetch-depth: 0 - name: Generate changelog run: | - initial_commit=$( git log --reverse --format='%H' | head -n 1 ) - printf '\n\ninitial_commit=%s\n\n' "${initial_commit[@]}" - - output='' - for tag in $( git tag -l | sort -V ); do - printf 'Processing tag=%s\n' "${tag[@]}" - commits=$( git log --reverse --format='- (%h) %s (%an)' "${initial_commit}".."${tag}" ) - if [ ${#commits[@]} -eq 0 ]; then - commits=$( git log --reverse --format='- (%h) %s (%an)' | head -n 1 ) + changelog="" + + # Get all tags in ascending order + tags=($( git tag --sort=version:refname )) + + # Loop through tags to generate the changelog + for ((i=0; i<${#tags[@]}; i++)); do + current_tag="${tags[$i]}" + previous_tag="" + tag_log="" + + if [ -z "${current_tag}" ]; then + continue fi - printf 'commits=<< 0 )); then + previous_tag="${tags[$((i-1))]}" fi - fi - - printf 'Changelog=<< CHANGELOG.md + + # Generate the header for the current tag + tag_log="### ${current_tag}\n" + + # Get the commits between the current tag and the previous tag + if [ -n "$previous_tag" ]; then + commits=$(git log --format="%s (%an) [%h]" "${previous_tag}..${current_tag}") + else + # If no previous tag, include all commits up to the first tag + commits=$(git log --format="%s (%an) [%h]" "${current_tag}") + fi + + # Add commits to the changelog, one per line + while IFS= read -r commit; do + tag_log+="- ${commit}\n" + done <<< "${commits}" + + changelog="${tag_log}\n${changelog}" + done + + changelog="# Changelog\n\n${changelog}" + + echo -e "${changelog}" + + # You can now use the variable $changelog elsewhere in your script + printf '%s' "${changelog}" > CHANGELOG.md - name: Upload new changelog uses: actions/upload-artifact@v4 with: @@ -146,7 +159,7 @@ jobs: printf 'Committing the updated changelog\n' git config --local user.name "github-actions[bot]" git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" - + git add CHANGELOG.md git commit -am "Update the project changelog" fi @@ -173,3 +186,16 @@ jobs: tag_prefix: '' tag_suffix: '' changelog_structure: "**{{messageHeadline}}** {{author}}\n" + trigger_publish: + name: Maybe trigger publish + runs-on: ubuntu-latest + needs: [maybe_tag] + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + set-safe-directory: 'true' + - name: Trigger workflow + run: gh workflow run publish.yml --ref $( git describe --tags --abbrev=0 ) + env: + GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' diff --git a/package.json b/package.json index 67ba157..eba5697 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "async-wait-until", - "version": "2.0.16", + "version": "2.0.17", "description": "Waits until the given predicate function returns a truthy value, then resolves", "main": "dist/index.js", "module": "./dist/index.esm.js",