@@ -13,12 +13,45 @@ create_github_release() {
1313 echo " Creating GitHub release..."
1414 LATEST_TAG=$( git describe --tags --abbrev=0)
1515 if [ ! -z " $LATEST_TAG " ]; then
16- # Use CHANGELOG.md if it exists, otherwise use auto-generated notes
17- if [ -f " CHANGELOG.md" ]; then
18- gh release create " $LATEST_TAG " -F CHANGELOG.md --latest || echo " Release may already exist or creation failed"
16+ # Extract CHANGELOG.md changes from the release commit
17+ # Get the added lines from CHANGELOG.md, excluding the header lines and empty lines
18+ TEMP_NOTES=" /tmp/release_notes_$$ .md"
19+
20+ # Extract the diff and format it properly
21+ git diff HEAD^ HEAD -- CHANGELOG.md 2> /dev/null | \
22+ grep ' ^+' | \
23+ grep -v ' ^+++' | \
24+ sed ' s/^+//' | \
25+ grep -v ' ^# Change Log' | \
26+ grep -v ' ^All notable changes' | \
27+ grep -v ' ^See \[Conventional Commits\]' | \
28+ grep -v ' ^$' | \
29+ head -n 20 > " $TEMP_NOTES "
30+
31+ if [ -s " $TEMP_NOTES " ]; then
32+ echo " Creating release with changes from CHANGELOG.md"
33+ gh release create " $LATEST_TAG " -F " $TEMP_NOTES " --latest || echo " Release may already exist or creation failed"
1934 else
35+ echo " No CHANGELOG.md changes found, using auto-generated notes"
2036 gh release create " $LATEST_TAG " --generate-notes --latest || echo " Release may already exist or creation failed"
2137 fi
38+
39+ rm -f " $TEMP_NOTES "
40+ fi
41+ }
42+
43+ # Function to move tags to current HEAD
44+ move_tags_to_head () {
45+ echo " Moving tags to current HEAD..."
46+ # Get all tags pointing to the previous commit
47+ PREV_COMMIT=$( git rev-parse HEAD^)
48+ TAGS_TO_MOVE=$( git tag --points-at " $PREV_COMMIT " 2> /dev/null || true)
49+
50+ if [ ! -z " $TAGS_TO_MOVE " ]; then
51+ for tag in $TAGS_TO_MOVE ; do
52+ echo " Moving tag $tag to HEAD"
53+ git tag -f " $tag " HEAD
54+ done
2255 fi
2356}
2457
@@ -46,22 +79,34 @@ if git diff-tree --no-commit-id --name-only -r HEAD | grep -q "package-lock.json
4679 git add -A
4780 # Amend the last commit instead of creating a new one
4881 git commit --amend --no-edit
82+
83+ # Move tags from the old commit to the amended commit
84+ move_tags_to_head
85+
4986 echo " Pushing amended commit..."
5087 git push origin HEAD:master
51- echo " Push completed."
88+ echo " Commit pushed."
89+
90+ # Push tags immediately after commit
91+ push_tags
5292 else
5393 echo " No changes to commit after reverting package-lock.json files"
5494 # Still push the commit even if no changes were made
5595 git push origin master
56- echo " Push completed."
96+ echo " Commit pushed."
97+
98+ # Push tags immediately after commit
99+ push_tags
57100 fi
58101else
59102 echo " No package-lock.json changes detected"
60103 # Push the commit created by lerna
61104 git push origin master
62- echo " Push completed."
105+ echo " Commit pushed."
106+
107+ # Push tags immediately after commit
108+ push_tags
63109fi
64110
65- # Always push tags and create release after handling commits
66- push_tags
111+ # Don't push tags again - already done above
67112create_github_release
0 commit comments