Skip to content

Commit 3459b00

Browse files
author
Lasim
committed
chore(release): enhance release workflow to extract and format changelog updates
1 parent 109926c commit 3459b00

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

.github/workflows/release-pr.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,26 @@ jobs:
6868
# Update package.json with the new version
6969
sed -i "s/\"version\": \"$CURRENT_VERSION\"/\"version\": \"$NEW_VERSION\"/" package.json
7070
71-
# Now run release-it for real to update the changelog
72-
npm run release -- $TYPE_ARG --ci --verbose --no-git.push --no-git.commit --no-git.tag --no-github --no-npm $BETA_ARG
71+
# Extract the changelog from dry run output and save it
72+
CHANGELOG=$(echo "$NEW_VERSION_INFO" | sed -n '/^Changelog:/,/^\$ npm run build/p' | grep -v '^\$ npm run build')
73+
# Format the changelog - remove 'Changelog:' line and ensure we use ## for version headers
74+
CHANGELOG=$(echo "$CHANGELOG" | sed '1d' | sed "s/# \[$NEW_VERSION\]/## \[$NEW_VERSION\]/")
75+
76+
# Get the existing changelog content
77+
EXISTING_CHANGELOG=$(cat CHANGELOG.md)
78+
79+
# Check if changelog already has the new version header
80+
if ! grep -q "## \[$NEW_VERSION\]" CHANGELOG.md; then
81+
# Insert the new changelog after the header
82+
echo -e "# Changelog\n\n$CHANGELOG\n$(echo "$EXISTING_CHANGELOG" | tail -n +2)" > CHANGELOG.md
83+
fi
84+
85+
# No need to run release-it again - we've already updated version and changelog
86+
87+
echo "Version and changelog updated successfully!"
88+
89+
# Also run the build to ensure everything is up to date
90+
npm run build
7391
7492
# Get the version from package.json (which should now be updated)
7593
- name: Get version

0 commit comments

Comments
 (0)