Skip to content

Commit 85c8e31

Browse files
CopilotChingEnLin
andcommitted
fix: Preserve complete release history in wiki page updates
- Read existing Releases.md before overwriting to preserve all history - Convert current "Latest Release" to "Previous Release" format - Remove faulty backup approach that only kept one previous release - Ensure cumulative release history is maintained across all updates Co-authored-by: ChingEnLin <50169422+ChingEnLin@users.noreply.github.com>
1 parent a843509 commit 85c8e31

1 file changed

Lines changed: 31 additions & 8 deletions

File tree

.github/workflows/semantic-release.yml

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,34 @@ jobs:
189189
git config user.name "github-actions[bot]"
190190
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
191191
192-
# Create or update the Releases page
192+
# Preserve existing releases before creating new content
193+
EXISTING_RELEASES=""
194+
if [ -f "Releases.md" ]; then
195+
# Extract everything after "### Previous Releases" from existing file
196+
if grep -q "### Previous Releases" "Releases.md"; then
197+
EXISTING_RELEASES=$(grep -A 1000 "### Previous Releases" "Releases.md" | tail -n +2)
198+
fi
199+
200+
# Also extract current "Latest Release" section to move to Previous Releases
201+
if grep -q "## Latest Release:" "Releases.md"; then
202+
CURRENT_LATEST=$(sed -n '/## Latest Release:/,/### Previous Releases/p' "Releases.md" | head -n -1)
203+
# Convert "Latest Release" to a previous release entry
204+
if [ -n "$CURRENT_LATEST" ]; then
205+
# Extract version from the current latest release
206+
PREV_VERSION=$(echo "$CURRENT_LATEST" | grep "## Latest Release:" | sed 's/.*Latest Release: //')
207+
# Format the previous release entry
208+
PREV_RELEASE_FORMATTED="## Release ${PREV_VERSION}"$'\n\n'"$(echo "$CURRENT_LATEST" | sed '/## Latest Release:/d')"
209+
# Combine with existing releases
210+
if [ -n "$EXISTING_RELEASES" ]; then
211+
EXISTING_RELEASES="${PREV_RELEASE_FORMATTED}"$'\n\n'"${EXISTING_RELEASES}"
212+
else
213+
EXISTING_RELEASES="${PREV_RELEASE_FORMATTED}"
214+
fi
215+
fi
216+
fi
217+
fi
218+
219+
# Create or update the Releases page with new content
193220
cat > "Releases.md" << EOF
194221
# QueryPal Releases
195222
@@ -232,15 +259,11 @@ jobs:
232259
233260
EOF
234261
235-
# If there's already a releases page, preserve previous releases section
236-
if [ -f "Releases.md.bak" ]; then
237-
# Extract previous releases section if it exists
238-
grep -A 1000 "### Previous Releases" "Releases.md.bak" | tail -n +2 >> "Releases.md" 2>/dev/null || true
262+
# Append preserved existing releases
263+
if [ -n "$EXISTING_RELEASES" ]; then
264+
echo "$EXISTING_RELEASES" >> "Releases.md"
239265
fi
240266
241-
# Backup current version for next time
242-
cp "Releases.md" "Releases.md.bak"
243-
244267
# Add to git and push
245268
git add "Releases.md"
246269
if ! git diff --staged --quiet; then

0 commit comments

Comments
 (0)