@@ -71,30 +71,43 @@ jobs:
7171 VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4)
7272 echo "Extracting release notes for version $VERSION"
7373
74- if [ -f CHANGELOG.md ]; then
75- RELEASE_NOTES=$(awk -v version="$VERSION" '
76- BEGIN { found=0; content="" }
77- /^##? [0-9]+\.[0-9]+\.[0-9]+/ {
78- if (found) exit
79- if ($0 ~ version) { found=1; next }
80- }
81- found && /^##? [0-9]+\.[0-9]+\.[0-9]+/ { exit }
82- found { content = content $0 "\n" }
83- END { print content }
84- ' CHANGELOG.md)
85-
86- CLEAN_NOTES=$(echo "$RELEASE_NOTES" | sed '/^$/d')
87-
88- echo "release_notes<<EOF" >> $GITHUB_OUTPUT
89- echo "$CLEAN_NOTES" >> $GITHUB_OUTPUT
90- echo "EOF" >> $GITHUB_OUTPUT
74+ # Find the latest gateway tag (excluding the current one)
75+ LATEST_TAG=$(git tag --list "gateway-v*" --sort=-version:refname | grep -v "gateway-v${VERSION}" | head -1)
76+
77+ if [ -z "$LATEST_TAG" ]; then
78+ echo "No previous gateway tag found, using all commits"
79+ GATEWAY_COMMITS=$(git log --oneline --grep="(gateway)" --grep="(all)" --grep-or)
80+ else
81+ echo "Using commits since $LATEST_TAG"
82+ # Get gateway and all scoped commits since last release
83+ GATEWAY_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(gateway)")
84+ ALL_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(all)")
9185
92- echo "Release notes extracted:"
93- echo "$CLEAN_NOTES"
86+ # Combine and format the commits
87+ COMBINED_COMMITS=$(echo -e "$GATEWAY_COMMITS\n$ALL_COMMITS" | sort -u | grep -v "^$")
88+ fi
89+
90+ # Format commits for release notes
91+ if [ -n "$COMBINED_COMMITS" ]; then
92+ RELEASE_NOTES=""
93+ while IFS= read -r commit; do
94+ if [ -n "$commit" ]; then
95+ # Extract commit hash and message
96+ HASH=$(echo "$commit" | cut -d' ' -f1)
97+ MESSAGE=$(echo "$commit" | cut -d' ' -f2-)
98+ RELEASE_NOTES="${RELEASE_NOTES}- ${MESSAGE} ([${HASH}](https://github.com/deploystackio/deploystack/commit/${HASH}))\n"
99+ fi
100+ done <<< "$COMBINED_COMMITS"
94101 else
95- echo "No CHANGELOG.md found"
96- echo "release_notes=" >> $GITHUB_OUTPUT
102+ RELEASE_NOTES="No significant changes since last release."
97103 fi
104+
105+ echo "release_notes<<EOF" >> $GITHUB_OUTPUT
106+ echo -e "$RELEASE_NOTES" >> $GITHUB_OUTPUT
107+ echo "EOF" >> $GITHUB_OUTPUT
108+
109+ echo "Release notes extracted:"
110+ echo -e "$RELEASE_NOTES"
98111 working-directory : services/gateway
99112 - name : Update GitHub Release
100113 uses : softprops/action-gh-release@v2
0 commit comments