@@ -14,35 +14,56 @@ ARGS:
1414EOF
1515}
1616
17- get_latest_changelog () {
18- local version=$( node -p " require('./package.json').version" )
19- awk " /## $version /,/^$/ { if (!/^## / && !/^$/) print }" CHANGELOG.md
17+ percentEncodeString () {
18+ jq -rn --arg x " $1 " ' $x|@uri'
2019}
2120
2221create_github_release () {
23- local current_version=$( node -p " require('./package.json').version" )
24- local changelog=$( get_latest_changelog)
25- local release_notes=" v$current_version
22+ local release_notes
23+ local changelog
24+ local is_collecting=0
25+ while IFS= read -r line; do
26+ if [[ $line == \#\# [[:space:]]* [[:digit:]]* ]]; then
27+ if [ $is_collecting == 0 ] ; then
28+ # Reached the entry for the version that is to be published
29+ is_collecting=1
30+ local version_and_date=" ${line#* } "
31+ else
32+ # Reached the next version entry, we're done.
33+ break
34+ fi
35+ elif [ $is_collecting == 1 ] ; then
36+ changelog+=" ${line}
37+ "
38+ fi
39+ done < CHANGELOG.md
40+
41+ release_notes=" $( cat << EOF
42+ $version_and_date
2643
27- Changes:
2844$changelog
2945
30- For full details, see the [CHANGELOG.md](https://github.com/degica/mobile-sdk_react-native/blob/main/payment_sdk/CHANGELOG.md)."
46+ Please [see the changelog](https://github.com/degica/mobile-sdk_react-native/blob/main/payment_sdk/CHANGELOG.md) for additional details.
47+ EOF
48+ ) "
3149
3250 if ! command -v hub & > /dev/null; then
33- echo " hub command not found. Falling back to manual release creation."
3451 create_github_release_fallback " $release_notes "
3552 else
53+ local current_version=${version_and_date% -* }
3654 echo " Creating GitHub release for tag: v$current_version "
3755 echo " "
38- hub release create -m " $release_notes " " v$current_version "
56+ echo -n " "
57+ hub release create -em " $release_notes " " v$current_version "
3958 fi
4059}
4160
4261create_github_release_fallback () {
4362 local release_notes=$1
44- echo " Please create a release manually on GitHub at https://github.com/degica/mobile-sdk_react-native/releases/new with the following notes:"
45- echo " $release_notes "
63+ cat << EOF
64+ Remember to create a release on GitHub at https://github.com/degica/mobile-sdk_react-native/releases/new with the following notes:
65+ $release_notes
66+ EOF
4667}
4768
4869# Show help if no arguments passed
@@ -108,7 +129,7 @@ echo "Bumping package.json $RELEASE_TYPE version and tagging commit"
108129npm version $RELEASE_TYPE
109130
110131echo " Publishing release to npm"
111- npm publish --access=public
132+ # npm publish --access=public
112133
113134echo " Pushing git commit and tag"
114135git push --follow-tags
0 commit comments