Skip to content

Commit 59dee75

Browse files
author
Lasim
committed
cicd(release): enhance release note extraction for backend and frontend services
1 parent 3865b9d commit 59dee75

File tree

6 files changed

+167
-52
lines changed

6 files changed

+167
-52
lines changed

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

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

.github/workflows/backend-release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,51 @@ jobs:
4848
with:
4949
path: services/backend
5050

51+
- name: Extract release notes
52+
id: extract-release-notes
53+
working-directory: services/backend
54+
run: |
55+
VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4)
56+
echo "Extracting release notes for version $VERSION"
57+
58+
# Find the latest backend tag (excluding the current one)
59+
LATEST_TAG=$(git tag --list "backend-v*" --sort=-version:refname | grep -v "backend-v${VERSION}" | head -1)
60+
61+
if [ -z "$LATEST_TAG" ]; then
62+
echo "No previous backend tag found, using all commits"
63+
BACKEND_COMMITS=$(git log --oneline --grep="(backend)" --grep="(all)" --grep-or)
64+
else
65+
echo "Using commits since $LATEST_TAG"
66+
# Get backend and all scoped commits since last release
67+
BACKEND_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(backend)")
68+
ALL_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(all)")
69+
70+
# Combine and format the commits
71+
COMBINED_COMMITS=$(echo -e "$BACKEND_COMMITS\n$ALL_COMMITS" | sort -u | grep -v "^$")
72+
fi
73+
74+
# Format commits for release notes
75+
if [ -n "$COMBINED_COMMITS" ]; then
76+
RELEASE_NOTES=""
77+
while IFS= read -r commit; do
78+
if [ -n "$commit" ]; then
79+
# Extract commit hash and message
80+
HASH=$(echo "$commit" | cut -d' ' -f1)
81+
MESSAGE=$(echo "$commit" | cut -d' ' -f2-)
82+
RELEASE_NOTES="${RELEASE_NOTES}- ${MESSAGE} ([${HASH}](https://github.com/deploystackio/deploystack/commit/${HASH}))\n"
83+
fi
84+
done <<< "$COMBINED_COMMITS"
85+
else
86+
RELEASE_NOTES="No significant changes since last release."
87+
fi
88+
89+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
90+
echo -e "$RELEASE_NOTES" >> $GITHUB_OUTPUT
91+
echo "EOF" >> $GITHUB_OUTPUT
92+
93+
echo "Release notes extracted:"
94+
echo -e "$RELEASE_NOTES"
95+
5196
- name: Build backend
5297
working-directory: services/backend
5398
run: npm run build

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

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,44 @@ jobs:
8383
VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4)
8484
echo "Extracting release notes for version $VERSION"
8585
86-
if [ -f CHANGELOG.md ]; then
87-
RELEASE_NOTES=$(awk -v version="$VERSION" '
88-
BEGIN { found=0; content="" }
89-
/^##? [0-9]+\.[0-9]+\.[0-9]+/ {
90-
if (found) exit
91-
if ($0 ~ version) { found=1; next }
92-
}
93-
found && /^##? [0-9]+\.[0-9]+\.[0-9]+/ { exit }
94-
found { content = content $0 "\n" }
95-
END { print content }
96-
' CHANGELOG.md)
97-
98-
CLEAN_NOTES=$(echo "$RELEASE_NOTES" | sed '/^$/d')
99-
100-
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
101-
echo "$CLEAN_NOTES" >> $GITHUB_OUTPUT
102-
echo "EOF" >> $GITHUB_OUTPUT
86+
# Find the latest frontend tag
87+
LATEST_TAG=$(git describe --tags --match=frontend-v* --abbrev=0 2>/dev/null || echo "")
88+
89+
if [ -z "$LATEST_TAG" ]; then
90+
echo "No previous frontend tag found, using all commits"
91+
FRONTEND_COMMITS=$(git log --oneline --grep="(frontend)" --grep="(all)" --grep-or)
92+
else
93+
echo "Using commits since $LATEST_TAG"
94+
# Get frontend and all scoped commits since last release
95+
FRONTEND_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(frontend)")
96+
ALL_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(all)")
10397
104-
echo "Release notes extracted:"
105-
echo "$CLEAN_NOTES"
98+
# Combine and format the commits
99+
COMBINED_COMMITS=$(echo -e "$FRONTEND_COMMITS\n$ALL_COMMITS" | sort -u | grep -v "^$")
100+
fi
101+
102+
# Format commits for release notes
103+
if [ -n "$COMBINED_COMMITS" ]; then
104+
RELEASE_NOTES=""
105+
while IFS= read -r commit; do
106+
if [ -n "$commit" ]; then
107+
# Extract commit hash and message
108+
HASH=$(echo "$commit" | cut -d' ' -f1)
109+
MESSAGE=$(echo "$commit" | cut -d' ' -f2-)
110+
RELEASE_NOTES="${RELEASE_NOTES}- ${MESSAGE} ([${HASH}](https://github.com/deploystackio/deploystack/commit/${HASH}))\n"
111+
fi
112+
done <<< "$COMBINED_COMMITS"
106113
else
107-
echo "No CHANGELOG.md found"
108-
echo "release_notes=" >> $GITHUB_OUTPUT
114+
RELEASE_NOTES="No significant changes since last release."
109115
fi
110116
117+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
118+
echo -e "$RELEASE_NOTES" >> $GITHUB_OUTPUT
119+
echo "EOF" >> $GITHUB_OUTPUT
120+
121+
echo "Release notes extracted:"
122+
echo -e "$RELEASE_NOTES"
123+
111124
- name: Create pull request
112125
uses: peter-evans/create-pull-request@v7
113126
id: cpr

.github/workflows/frontend-release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,51 @@ jobs:
5757
with:
5858
path: services/frontend
5959

60+
- name: Extract release notes
61+
id: extract-release-notes
62+
working-directory: services/frontend
63+
run: |
64+
VERSION=$(cat package.json | grep '"version"' | cut -d'"' -f4)
65+
echo "Extracting release notes for version $VERSION"
66+
67+
# Find the latest frontend tag (excluding the current one)
68+
LATEST_TAG=$(git tag --list "frontend-v*" --sort=-version:refname | grep -v "frontend-v${VERSION}" | head -1)
69+
70+
if [ -z "$LATEST_TAG" ]; then
71+
echo "No previous frontend tag found, using all commits"
72+
FRONTEND_COMMITS=$(git log --oneline --grep="(frontend)" --grep="(all)" --grep-or)
73+
else
74+
echo "Using commits since $LATEST_TAG"
75+
# Get frontend and all scoped commits since last release
76+
FRONTEND_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(frontend)")
77+
ALL_COMMITS=$(git log ${LATEST_TAG}..HEAD --oneline --grep="(all)")
78+
79+
# Combine and format the commits
80+
COMBINED_COMMITS=$(echo -e "$FRONTEND_COMMITS\n$ALL_COMMITS" | sort -u | grep -v "^$")
81+
fi
82+
83+
# Format commits for release notes
84+
if [ -n "$COMBINED_COMMITS" ]; then
85+
RELEASE_NOTES=""
86+
while IFS= read -r commit; do
87+
if [ -n "$commit" ]; then
88+
# Extract commit hash and message
89+
HASH=$(echo "$commit" | cut -d' ' -f1)
90+
MESSAGE=$(echo "$commit" | cut -d' ' -f2-)
91+
RELEASE_NOTES="${RELEASE_NOTES}- ${MESSAGE} ([${HASH}](https://github.com/deploystackio/deploystack/commit/${HASH}))\n"
92+
fi
93+
done <<< "$COMBINED_COMMITS"
94+
else
95+
RELEASE_NOTES="No significant changes since last release."
96+
fi
97+
98+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
99+
echo -e "$RELEASE_NOTES" >> $GITHUB_OUTPUT
100+
echo "EOF" >> $GITHUB_OUTPUT
101+
102+
echo "Release notes extracted:"
103+
echo -e "$RELEASE_NOTES"
104+
60105
- name: Update .env with version
61106
working-directory: services/frontend
62107
run: |

services/backend/.release-it.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ module.exports = {
22
git: {
33
commitMessage: 'chore(backend): release v${version}',
44
tagName: 'backend-v${version}',
5+
tagAnnotation: 'Backend Release ${version}',
6+
commitsPath: 'services/backend',
7+
addUntrackedFiles: false,
58
requireCleanWorkingDir: false
69
},
710
npm: {
@@ -16,10 +19,7 @@ module.exports = {
1619
name: 'angular'
1720
},
1821
infile: 'CHANGELOG.md',
19-
ignoreRecommendedBump: true,
20-
gitRawCommitsOpts: {
21-
path: 'services/backend'
22-
}
22+
ignoreRecommendedBump: true
2323
}
2424
}
2525
};

services/frontend/.release-it.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ module.exports = {
33
commitMessage: 'chore(frontend): release v${version}',
44
tagName: 'frontend-v${version}',
55
tagAnnotation: 'Frontend Release ${version}',
6-
addUntrackedFiles: false
6+
commitsPath: 'services/frontend',
7+
addUntrackedFiles: false,
8+
requireCleanWorkingDir: false
79
},
810
github: {
911
release: true,
@@ -23,10 +25,7 @@ module.exports = {
2325
name: 'angular'
2426
},
2527
infile: 'CHANGELOG.md',
26-
ignoreRecommendedBump: true,
27-
gitRawCommitsOpts: {
28-
path: 'services/frontend'
29-
}
28+
ignoreRecommendedBump: true
3029
}
3130
}
3231
};

0 commit comments

Comments
 (0)