Skip to content

Commit 6b897fb

Browse files
RahulHereRahulHere
authored andcommitted
Improve release notes validation and CI extraction
Changes: - dump-version.sh: validate Added/Changed/Fixed have content, error if empty - publish-packages.yml: extract versioned [X.Y.Z] section first, fix fallback regex - Update gopher-orch submodule to main branch - Add release notes for upcoming changes in CHANGELOG.md
1 parent 83e0f32 commit 6b897fb

5 files changed

Lines changed: 64 additions & 21 deletions

File tree

.github/workflows/publish-packages.yml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -251,27 +251,37 @@ jobs:
251251
echo "" >> RELEASE_NOTES.md
252252
253253
if [ -f "CHANGELOG.md" ]; then
254-
# Extract content from [Unreleased] section (between ## [Unreleased] and next ## [)
255-
sed -n '/^## \[Unreleased\]/,/^## \[/p' CHANGELOG.md | \
254+
# First try: extract the current version's section [X.Y.Z] or [X.Y.Z.A]
255+
# (dump-version.sh converts [Unreleased] to [X.Y.Z] before push)
256+
ESCAPED_VERSION=$(echo "$VERSION" | sed 's/\./\\./g')
257+
sed -n "/^## \[${ESCAPED_VERSION}\]/,/^## \[/p" CHANGELOG.md | \
256258
grep -v "^## \[" | \
257259
sed '/^$/d' >> RELEASE_NOTES.md || true
258260
259-
# If Unreleased section is empty, try to get the latest version section
260-
if [ ! -s RELEASE_NOTES.md ] || [ $(wc -l < RELEASE_NOTES.md) -le 10 ]; then
261-
echo "" >> RELEASE_NOTES.md
262-
# Get content from the first versioned section
263-
sed -n '/^## \[0-9\]/,/^## \[/p' CHANGELOG.md | \
261+
# Fallback: try [Unreleased] section if version section not found
262+
if [ $(wc -l < RELEASE_NOTES.md) -le 10 ]; then
263+
sed -n '/^## \[Unreleased\]/,/^## \[/p' CHANGELOG.md | \
264+
grep -v "^## \[" | \
265+
sed '/^$/d' >> RELEASE_NOTES.md || true
266+
fi
267+
268+
# Final fallback: get the first versioned section
269+
if [ $(wc -l < RELEASE_NOTES.md) -le 10 ]; then
270+
sed -n '/^## \[[0-9]/,/^## \[/p' CHANGELOG.md | \
264271
head -50 | \
265272
grep -v "^## \[" >> RELEASE_NOTES.md || true
266273
fi
267-
else
268-
echo "No CHANGELOG.md found, listing recent commits..." >> RELEASE_NOTES.md
274+
fi
275+
276+
# If still empty, list recent commits
277+
if [ $(wc -l < RELEASE_NOTES.md) -le 10 ]; then
278+
echo "### Changed" >> RELEASE_NOTES.md
269279
echo "" >> RELEASE_NOTES.md
270-
git log --pretty=format:"* %s (%h)" --no-merges -20 >> RELEASE_NOTES.md || true
280+
git log --pretty=format:"- %s" --no-merges -20 >> RELEASE_NOTES.md || true
271281
fi
272282
273283
# Add full changelog link
274-
PREV_TAG=$(git tag --sort=-creatordate | grep -v "^${VERSION_TAG}$" | head -1)
284+
PREV_TAG=$(git tag --sort=-creatordate | grep -E "^v[0-9]" | grep -v "^${VERSION_TAG}$" | head -1)
275285
if [ -n "$PREV_TAG" ]; then
276286
echo "" >> RELEASE_NOTES.md
277287
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${VERSION_TAG}" >> RELEASE_NOTES.md

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[submodule "third_party/gopher-orch"]
22
path = third_party/gopher-orch
33
url = https://github.com/GopherSecurity/gopher-orch.git
4-
branch = gateway-img-with-auth
4+
branch = main

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
## [Unreleased]
1010

11+
### Added
12+
13+
- Add empty release notes validation in dump-version.sh — errors out if all Added/Changed/Fixed sections are empty
14+
15+
### Changed
16+
17+
- Improve CI release notes extraction in publish-packages.yml: try versioned section `[X.Y.Z]` first, then `[Unreleased]`, with proper fallbacks and commit listing as final fallback
18+
- Update gopher-orch submodule to `main` branch
19+
20+
### Fixed
21+
22+
- Fix CI release notes showing empty What's Changed section (workflow extracted empty `[Unreleased]` instead of versioned `[X.Y.Z]` section)
23+
- Fix release notes fallback regex for extracting versioned sections from CHANGELOG.md
1124

1225
## [0.1.14] - 2026-04-21
1326

dump-version.sh

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,16 +160,36 @@ fi
160160
UNRELEASED_CONTENT=$(sed -n '/^## \[Unreleased\]/,/^## \[/p' "$CHANGELOG_FILE" | \
161161
grep -v "^## \[" | grep -v "^$" | head -20)
162162

163-
if [ -z "$UNRELEASED_CONTENT" ]; then
164-
echo -e "${YELLOW}Warning: [Unreleased] section in CHANGELOG.md appears empty${NC}"
165-
echo "You may want to add release notes before continuing."
166-
read -p "Continue anyway? (y/N) " -n 1 -r
167-
echo
168-
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
169-
exit 1
170-
fi
163+
# Check that at least one of Added/Changed/Fixed has actual content (not just headers)
164+
HAS_ADDED=$(sed -n '/^## \[Unreleased\]/,/^## \[/p' "$CHANGELOG_FILE" | \
165+
sed -n '/^### Added/,/^### /p' | grep -v "^### " | grep -v "^$" | head -1)
166+
HAS_CHANGED=$(sed -n '/^## \[Unreleased\]/,/^## \[/p' "$CHANGELOG_FILE" | \
167+
sed -n '/^### Changed/,/^### /p' | grep -v "^### " | grep -v "^$" | head -1)
168+
HAS_FIXED=$(sed -n '/^## \[Unreleased\]/,/^## \[/p' "$CHANGELOG_FILE" | \
169+
sed -n '/^### Fixed/,/^### /p' | grep -v "^### " | grep -v "^$" | head -1)
170+
171+
if [ -z "$HAS_ADDED" ] && [ -z "$HAS_CHANGED" ] && [ -z "$HAS_FIXED" ]; then
172+
echo -e "${RED}========================================${NC}"
173+
echo -e "${RED} Error: Empty release notes!${NC}"
174+
echo -e "${RED}========================================${NC}"
175+
echo ""
176+
echo -e "The [Unreleased] section in CHANGELOG.md has no content under"
177+
echo -e "Added, Changed, or Fixed. At least one section must have entries."
178+
echo ""
179+
echo "To fix this, edit CHANGELOG.md and add release notes under [Unreleased]:"
180+
echo " ## [Unreleased]"
181+
echo " ### Added"
182+
echo " - New feature description"
183+
echo " ### Changed"
184+
echo " - Change description"
185+
echo " ### Fixed"
186+
echo " - Bug fix description"
187+
exit 1
171188
else
172189
echo -e " ${GREEN}[Unreleased] section has content${NC}"
190+
[ -n "$HAS_ADDED" ] && echo -e " Added: ${GREEN}yes${NC}" || echo -e " Added: ${YELLOW}empty${NC}"
191+
[ -n "$HAS_CHANGED" ] && echo -e " Changed: ${GREEN}yes${NC}" || echo -e " Changed: ${YELLOW}empty${NC}"
192+
[ -n "$HAS_FIXED" ] && echo -e " Fixed: ${GREEN}yes${NC}" || echo -e " Fixed: ${YELLOW}empty${NC}"
173193
echo " Preview:"
174194
echo "$UNRELEASED_CONTENT" | head -5 | sed 's/^/ /'
175195
fi

third_party/gopher-orch

0 commit comments

Comments
 (0)