@@ -85,35 +85,48 @@ jobs:
8585
8686 - name : Extract release notes
8787 id : extract-release-notes
88+ working-directory : services/backend
8889 run : |
8990 VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4)
9091 echo "Extracting release notes for version $VERSION"
9192
92- if [ -f CHANGELOG.md ]; then
93- RELEASE_NOTES=$(awk -v version="$VERSION" '
94- BEGIN { found=0; content="" }
95- /^##? [0-9]+\.[0-9]+\.[0-9]+/ {
96- if (found) exit
97- if ($0 ~ version) { found=1; next }
98- }
99- found && /^##? [0-9]+\.[0-9]+\.[0-9]+/ { exit }
100- found { content = content $0 "\n" }
101- END { print content }
102- ' CHANGELOG.md)
103-
104- CLEAN_NOTES=$(echo "$RELEASE_NOTES" | sed '/^$/d')
105-
106- echo "release_notes<<EOF" >> $GITHUB_OUTPUT
107- echo "$CLEAN_NOTES" >> $GITHUB_OUTPUT
108- echo "EOF" >> $GITHUB_OUTPUT
93+ # Find the latest backend tag
94+ LATEST_TAG=$(git describe --tags --match=backend-v* --abbrev=0 2>/dev/null || echo "")
95+
96+ if [ -z "$LATEST_TAG" ]; then
97+ echo "No previous backend tag found, using all commits"
98+ BACKEND_COMMITS=$(git log --oneline --grep="(backend)" --grep="(all)" --grep-or)
99+ else
100+ echo "Using commits since $LATEST_TAG"
101+ # Get backend and all scoped commits since last release
102+ BACKEND_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(backend)")
103+ ALL_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(all)")
109104
110- echo "Release notes extracted:"
111- echo "$CLEAN_NOTES"
105+ # Combine and format the commits
106+ COMBINED_COMMITS=$(echo -e "$BACKEND_COMMITS\n$ALL_COMMITS" | sort -u | grep -v "^$")
107+ fi
108+
109+ # Format commits for release notes
110+ if [ -n "$COMBINED_COMMITS" ]; then
111+ RELEASE_NOTES=""
112+ while IFS= read -r commit; do
113+ if [ -n "$commit" ]; then
114+ # Extract commit hash and message
115+ HASH=$(echo "$commit" | cut -d' ' -f1)
116+ MESSAGE=$(echo "$commit" | cut -d' ' -f2-)
117+ RELEASE_NOTES="${RELEASE_NOTES}- ${MESSAGE} ([${HASH}](https://github.com/deploystackio/deploystack/commit/${HASH}))\n"
118+ fi
119+ done <<< "$COMBINED_COMMITS"
112120 else
113- echo "No CHANGELOG.md found"
114- echo "release_notes=" >> $GITHUB_OUTPUT
121+ RELEASE_NOTES="No significant changes since last release."
115122 fi
116- working-directory : services/backend
123+
124+ echo "release_notes<<EOF" >> $GITHUB_OUTPUT
125+ echo -e "$RELEASE_NOTES" >> $GITHUB_OUTPUT
126+ echo "EOF" >> $GITHUB_OUTPUT
127+
128+ echo "Release notes extracted:"
129+ echo -e "$RELEASE_NOTES"
117130
118131 - name : Create pull request
119132 uses : peter-evans/create-pull-request@v7
0 commit comments