Skip to content

Commit 3865b9d

Browse files
author
Lasim
committed
cicd(gateway): enhance release note extraction by including all relevant commits since the last tag
1 parent 8aed4aa commit 3865b9d

File tree

3 files changed

+69
-46
lines changed

3 files changed

+69
-46
lines changed

.github/workflows/gateway-release-pr.yml

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,43 @@ jobs:
9292
VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4)
9393
echo "Extracting release notes for version $VERSION"
9494
95-
if [ -f CHANGELOG.md ]; then
96-
RELEASE_NOTES=$(awk -v version="$VERSION" '
97-
BEGIN { found=0; content="" }
98-
/^##? [0-9]+\.[0-9]+\.[0-9]+/ {
99-
if (found) exit
100-
if ($0 ~ version) { found=1; next }
101-
}
102-
found && /^##? [0-9]+\.[0-9]+\.[0-9]+/ { exit }
103-
found { content = content $0 "\n" }
104-
END { print content }
105-
' CHANGELOG.md)
106-
107-
CLEAN_NOTES=$(echo "$RELEASE_NOTES" | sed '/^$/d')
108-
109-
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
110-
echo "$CLEAN_NOTES" >> $GITHUB_OUTPUT
111-
echo "EOF" >> $GITHUB_OUTPUT
95+
# Find the latest gateway tag
96+
LATEST_TAG=$(git describe --tags --match=gateway-v* --abbrev=0 2>/dev/null || echo "")
97+
98+
if [ -z "$LATEST_TAG" ]; then
99+
echo "No previous gateway tag found, using all commits"
100+
GATEWAY_COMMITS=$(git log --oneline --grep="(gateway)" --grep="(all)" --grep-or)
101+
else
102+
echo "Using commits since $LATEST_TAG"
103+
# Get gateway and all scoped commits since last release
104+
GATEWAY_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(gateway)")
105+
ALL_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(all)")
112106
113-
echo "Release notes extracted:"
114-
echo "$CLEAN_NOTES"
107+
# Combine and format the commits
108+
COMBINED_COMMITS=$(echo -e "$GATEWAY_COMMITS\n$ALL_COMMITS" | sort -u | grep -v "^$")
109+
fi
110+
111+
# Format commits for release notes
112+
if [ -n "$COMBINED_COMMITS" ]; then
113+
RELEASE_NOTES=""
114+
while IFS= read -r commit; do
115+
if [ -n "$commit" ]; then
116+
# Extract commit hash and message
117+
HASH=$(echo "$commit" | cut -d' ' -f1)
118+
MESSAGE=$(echo "$commit" | cut -d' ' -f2-)
119+
RELEASE_NOTES="${RELEASE_NOTES}- ${MESSAGE} ([${HASH}](https://github.com/deploystackio/deploystack/commit/${HASH}))\n"
120+
fi
121+
done <<< "$COMBINED_COMMITS"
115122
else
116-
echo "No CHANGELOG.md found"
117-
echo "release_notes=" >> $GITHUB_OUTPUT
123+
RELEASE_NOTES="No significant changes since last release."
118124
fi
125+
126+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
127+
echo -e "$RELEASE_NOTES" >> $GITHUB_OUTPUT
128+
echo "EOF" >> $GITHUB_OUTPUT
129+
130+
echo "Release notes extracted:"
131+
echo -e "$RELEASE_NOTES"
119132
working-directory: services/gateway
120133

121134
- name: Create pull request

.github/workflows/gateway-release.yml

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

services/gateway/.release-it.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ module.exports = {
2525
name: 'angular'
2626
},
2727
infile: 'CHANGELOG.md',
28-
ignoreRecommendedBump: true,
29-
gitRawCommitsOpts: {
30-
path: 'services/gateway'
31-
}
28+
ignoreRecommendedBump: true
3229
}
3330
}
3431
};

0 commit comments

Comments
 (0)