3232 with :
3333 node-version : ' 22'
3434
35- - name : Get latest release tag
36- id : get-latest-tag
37- run : |
38- # Get the latest tag that looks like a version (v*)
39- LATEST_TAG=$(git tag -l 'v*' --sort=-v:refname | head -n 1)
40- if [ -z "$LATEST_TAG" ]; then
41- echo "No previous release tag found, using initial commit"
42- LATEST_TAG=$(git rev-list --max-parents=0 HEAD)
43- fi
44- echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
45- echo "Latest tag: $LATEST_TAG"
46-
4735 - name : Get current version
4836 id : get-current-version
4937 run : |
8573 echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
8674 echo "New version: $NEW_VERSION"
8775
76+ - name : Get latest release tag
77+ id : get-latest-tag
78+ run : |
79+ NEW_VERSION="${{ steps.calc-version.outputs.new_version }}"
80+ # Get the latest tag that looks like a version (v*), excluding the
81+ # tag being created so that re-runs don't use it as the baseline.
82+ LATEST_TAG=$(git tag -l 'v*' --sort=-v:refname | \
83+ grep -v "^v${NEW_VERSION}$" | head -n 1)
84+ if [ -z "$LATEST_TAG" ]; then
85+ echo "No previous release tag found, using initial commit"
86+ LATEST_TAG=$(git rev-list --max-parents=0 HEAD)
87+ fi
88+ echo "latest_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
89+ echo "Latest tag: $LATEST_TAG"
90+
8891 - name : Generate changelog diff
8992 id : changelog-diff
9093 run : |
@@ -93,16 +96,13 @@ jobs:
9396
9497 echo "Generating changelog for changes between $LATEST_TAG and HEAD..."
9598
96- # Get merge commits (PRs) between last tag and HEAD
97- CHANGELOG_CONTENT=$(git log "$LATEST_TAG"..HEAD --merges --pretty=format:"- %s" | \
98- sed 's/Merge pull request #\([0-9]*\) from [^:]*:/\[#\1\](https:\/\/github.com\/microsoft\/durabletask-js\/pull\/\1):/' | \
99- sed 's/Merge branch .*//' | \
100- grep -v '^$' || echo "")
101-
102- # If no merge commits, get regular commits
103- if [ -z "$CHANGELOG_CONTENT" ]; then
104- CHANGELOG_CONTENT=$(git log "$LATEST_TAG"..HEAD --pretty=format:"- %s" --no-merges | head -20)
105- fi
99+ # Get commits between last tag and HEAD.
100+ # GitHub squash-merges put the PR number in parentheses, e.g. "Some change (#123)".
101+ # We convert "(#N)" to a markdown link.
102+ CHANGELOG_CONTENT=$(git log "$LATEST_TAG"..HEAD --pretty=format:"%s" --no-merges | \
103+ sed 's/(#\([0-9]*\))/([#\1](https:\/\/github.com\/microsoft\/durabletask-js\/pull\/\1))/' | \
104+ sed 's/^/- /' | \
105+ grep -v '^- $' || echo "")
106106
107107 # Save to file for multi-line output
108108 echo "$CHANGELOG_CONTENT" > /tmp/changelog_content.txt
0 commit comments