11#! /bin/bash
22
3- set -e
3+ set +e # Don't exit on error immediately
44source ./.env
55RA_ENTERPRISE_PATH=" ${RA_ENTERPRISE_PATH:- ../ ra-enterprise} "
66RA_DOC_PATH=" ${RA_DOC_PATH:- ../ react-admin-doc} "
@@ -18,146 +18,223 @@ step() {
1818 info " $1 "
1919}
2020
21+ error () {
22+ echo -e " \033[1;31m$1 \033[0m"
23+ }
24+
25+ success () {
26+ echo -e " \033[1;32m$1 \033[0m"
27+ }
28+
29+ retry_step () {
30+ local step_name=" $1 "
31+ local step_command=" $2 "
32+
33+ while true ; do
34+ step " $step_name "
35+ if eval " $step_command " ; then
36+ success " ✓ $step_name completed successfully"
37+ break
38+ else
39+ error " ✗ $step_name failed"
40+ echo " "
41+ echo " Options:"
42+ echo " 1. Retry this step"
43+ echo " 2. Skip this step (continue with release)"
44+ echo " 3. Abort release"
45+ read -p " Choose (1/2/3): " choice
46+
47+ case $choice in
48+ 1)
49+ echo " Retrying..."
50+ continue
51+ ;;
52+ 2)
53+ warn " ⚠ Skipping $step_name "
54+ break
55+ ;;
56+ 3)
57+ error " Release aborted by user"
58+ exit 1
59+ ;;
60+ * )
61+ echo " Invalid choice, please enter 1, 2, or 3"
62+ ;;
63+ esac
64+ fi
65+ done
66+ }
67+
68+ manual_step () {
69+ local step_name=" $1 "
70+ local instructions=" $2 "
71+
72+ while true ; do
73+ step " $step_name "
74+ echo " $instructions "
75+ echo " Press Enter when this is done, or 'q' to quit"
76+ read -r response
77+
78+ if [ " $response " = " q" ] || [ " $response " = " Q" ]; then
79+ error " Release aborted by user"
80+ exit 1
81+ else
82+ success " ✓ $step_name marked as completed"
83+ break
84+ fi
85+ done
86+ }
87+
2188if [ ! -z " $RELEASE_DRY_RUN " ]; then
2289 echo " Dry run mode is enabled"
2390fi
2491
2592info " Starting the release process"
2693
27- step " make install "
28- make install
94+ # Step 1: Install
95+ retry_step " make install" " make install "
2996
30- step " make build "
31- make build
97+ # Step 2: Build
98+ retry_step " make build" " make build "
3299
33- step " Run the EE tests "
100+ # Step 3: EE Tests
34101if [ -d $RA_ENTERPRISE_PATH ]; then
35- cp -r packages/* $RA_ENTERPRISE_PATH /node_modules
36- # We must remove the @mui directory from the react-admin node_modules to avoid conflicts
37- ( cd $RA_ENTERPRISE_PATH && rm -rf node_modules/react-admin/node_modules/@mui && make build && CI=true make test )
102+ retry_step " Run the EE tests" "
103+ cp -r packages/* \$ RA_ENTERPRISE_PATH/node_modules &&
104+ cd \$ RA_ENTERPRISE_PATH &&
105+ rm -rf node_modules/react-admin/node_modules/@mui &&
106+ make build &&
107+ CI=true make test
108+ "
109+ cd -
38110else
39- warn " Cannot find the $RA_ENTERPRISE_PATH folder in the repository parent directory"
40- echo " Copy the the packages folder content inside the node_modules of ra-enterprise, then run a full build and run the tests"
41- echo " Tip: You can use the 'copy-ra-oss-packages-to-ee.sh' script if you have it"
42- echo " Press Enter when this is done"
43- read
111+ manual_step " Run the EE tests" "
112+ Cannot find the $RA_ENTERPRISE_PATH folder in the repository parent directory
113+ Copy the packages folder content inside the node_modules of ra-enterprise, then run a full build and run the tests
114+ Tip: You can use the 'copy-ra-oss-packages-to-ee.sh' script if you have it"
44115fi
45116
46- step " manual tests: Run the demos"
47- echo " Test the 3 demos (simple, e-commerce, crm): check console & UI"
48- echo " Press Enter when this is done"
49- read
50-
51- # Get the current version from package.json
52- npm_previous_package_version=$( jq -r ' .version' ./packages/react-admin/package.json)
53- # ${npm_previous_package_version%.*} extract the major.minor version
54- npm_previous_package_minor_version=${npm_previous_package_version% .* }
55-
56- step " lerna version"
57- # Running lerna version
58- # This will create a commit and a tag
59- ./node_modules/.bin/lerna version --force-publish --no-push
60-
61- # Get the version from package.json
62- npm_current_package_version=$( jq -r ' .version' ./packages/react-admin/package.json)
63- # ${npm_current_package_version%.*} extract the major.minor version
64- npm_current_package_minor_version=${npm_current_package_version% .* }
65-
66- # Remove the tag created by lerna
67- echo " Removing tag v${npm_current_package_version} created by lerna"
68- git tag -d " v${npm_current_package_version} "
69- if [ ! -z " $RELEASE_DRY_RUN " ]; then
70- # In dry-run mode, reset the last commit to avoid accidental push
71- echo " dry mode -- Resetting the workspace to the last commit"
72- git reset --soft HEAD~1
73- fi
117+ # Step 4: Manual demo tests
118+ manual_step " Run the demos" " Test the 3 demos (simple, e-commerce, crm): check console & UI"
119+
120+ # Get versions before lerna version
121+ retry_step " Get current version" "
122+ npm_previous_package_version=\$ (jq -r '.version' ./packages/react-admin/package.json) &&
123+ npm_previous_package_minor_version=\$ {npm_previous_package_version%.*} &&
124+ echo \" Current version: \$ npm_previous_package_version\"
125+ "
126+
127+ # Step 5: Lerna version
128+ retry_step " lerna version" " ./node_modules/.bin/lerna version --force-publish --no-push"
129+
130+ # Get new version and handle tag
131+ retry_step " Process version changes" "
132+ npm_current_package_version=\$ (jq -r '.version' ./packages/react-admin/package.json) &&
133+ npm_current_package_minor_version=\$ {npm_current_package_version%.*} &&
134+ echo \" New version: \$ npm_current_package_version\" &&
135+ echo \" Removing tag v\$ {npm_current_package_version} created by lerna\" &&
136+ git tag -d \" v\$ {npm_current_package_version}\" &&
137+ if [ ! -z \"\$ RELEASE_DRY_RUN\" ]; then
138+ echo \" dry mode -- Resetting the workspace to the last commit\" &&
139+ git reset --soft HEAD~1
140+ fi
141+ "
74142
143+ # Step 6: Handle minor version updates
75144if [ " $npm_previous_package_minor_version " != " $npm_current_package_minor_version " ]; then
76- echo " New minor version - Updating the docs/OldVersion.md file"
77- sed -i " s/^- \[v$npm_previous_package_minor_version \].*/- [v$npm_current_package_minor_version ](https:\/\/github.com\/marmelab\/react-admin\/blob\/master\/docs\/Admin.md)\n- [v$npm_previous_package_minor_version ](https:\/\/github\.com\/marmelab\/react\-admin\/blob\/v$npm_previous_package_version \/docs\/Admin.md\)/" docs/OldVersions.md
78- echo " Please review the docs/OldVersion.md file and update it if needed."
79- echo " Press Enter when this is done"
80- read
145+ retry_step " Update OldVersions.md" "
146+ sed -i \" s/^- \[v\$ npm_previous_package_minor_version\].*/- [v\$ npm_current_package_minor_version](https:\/\/github.com\/marmelab\/react-admin\/blob\/master\/docs\/Admin.md)\n- [v\$ npm_previous_package_minor_version](https:\/\/github\.com\/marmelab\/react\-admin\/blob\/v\$ npm_previous_package_version\/docs\/Admin.md\)/\" docs/OldVersions.md
147+ "
148+
149+ manual_step " Review OldVersions.md" " Please review the docs/OldVersions.md file and update it if needed."
150+
81151 if [ -z " $RELEASE_DRY_RUN " ]; then
82- echo " Committing the OldVersion.md file update"
83- git add .
84- git commit -m " Update docs/OldVersion.md for version ${npm_current_package_version} "
152+ retry_step " Commit OldVersions.md" "
153+ git add . &&
154+ git commit -m \" Update docs/OldVersions.md for version \$ {npm_current_package_version}\"
155+ "
85156 fi
86-
87- echo " New minor version - Updating the dependencies to RA packages in the create-react-admin templates "
88- yarn run update-create-react-admin-deps ${npm_current_package_version}
157+
158+ retry_step " Update create-react-admin templates " " yarn run update- create-react-admin-deps \$ {npm_current_package_version} "
159+
89160 if [ -z " $RELEASE_DRY_RUN " ]; then
90- echo " Committing the create-react-admin templates dependencies update"
91- git add .
92- git commit -m " Update create-react-admin templates dependencies for version ${npm_current_package_version} "
161+ retry_step " Commit template updates" "
162+ git add . &&
163+ git commit -m \" Update create-react-admin templates dependencies for version \$ {npm_current_package_version}\"
164+ "
93165 fi
94166fi
95167
96- step " update- changelog"
97- yarn run update-changelog ${npm_current_package_version}
98- echo " Please review the ./CHANGELOG.md file and update it if needed. "
99- echo " Press Enter when this is done "
100- read
168+ # Step 7: Update changelog
169+ retry_step " Generate changelog " " yarn run update-changelog \ $ {npm_current_package_version}"
170+
171+ manual_step " Review changelog " " Please review the ./CHANGELOG.md file and update it if needed. "
172+
101173if [ -z " $RELEASE_DRY_RUN " ]; then
102- echo " Committing the changelog"
103- git add CHANGELOG.md
104- git commit -m " Update changelog for version ${npm_current_package_version} "
174+ retry_step " Commit changelog" "
175+ git add CHANGELOG.md &&
176+ git commit -m \" Update changelog for version \$ {npm_current_package_version}\"
177+ "
105178fi
106179
107- step " git tag"
180+ # Step 8: Git tag
108181if [ -z " $RELEASE_DRY_RUN " ]; then
109- echo " Creating new tag v${npm_current_package_version} "
110- git tag " v${npm_current_package_version} " -m " v${npm_current_package_version} "
182+ retry_step " Create git tag" "
183+ echo \" Creating new tag v\$ {npm_current_package_version}\" &&
184+ git tag \" v\$ {npm_current_package_version}\" -m \" v\$ {npm_current_package_version}\"
185+ "
111186else
112- echo " dry mode -- skipping git tag"
187+ info " dry mode -- skipping git tag"
113188fi
114189
115- step " git push"
190+ # Step 9: Git push
116191if [ -z " $RELEASE_DRY_RUN " ]; then
117- echo " Pushing commits and tags to git"
118- git push origin HEAD
119- git push origin --tags
192+ retry_step " Push to git" "
193+ echo \" Pushing commits and tags to git\" &&
194+ git push origin HEAD &&
195+ git push origin --tags
196+ "
120197else
121- echo " dry mode -- skipping git push"
198+ info " dry mode -- skipping git push"
122199fi
123200
124- step " lerna publish "
201+ # Step 10: Publish packages
125202if [ -z " $RELEASE_DRY_RUN " ]; then
126- # explicitly publish packages where the latest version is not present in the registry
127- ./node_modules/.bin/lerna publish from-package
203+ retry_step " Publish packages" " ./node_modules/.bin/lerna publish from-package"
128204else
129- echo " dry mode -- skipping lerna publish"
205+ info " dry mode -- skipping lerna publish"
130206fi
131207
132- step " update- milestones"
133- yarn run update-milestones ${npm_current_package_version}
208+ # Step 11: Update milestones
209+ retry_step " Update milestones " " yarn run update-milestones \ $ {npm_current_package_version}"
134210
135- step " create-github- release"
136- yarn run create-github-release ${npm_current_package_version}
211+ # Step 12: Create GitHub release
212+ retry_step " Create GitHub release " " yarn run create-github-release \ $ {npm_current_package_version}"
137213
138- step " Update the documentation"
214+ # Step 13: Update documentation
139215if [ -d $RA_DOC_PATH ]; then
140- ( cd $RA_DOC_PATH && git pull )
141- RA_DOC_PATH=" $RA_DOC_PATH " VERSION=" $npm_current_package_minor_version " ./scripts/copy-ra-oss-docs.sh
142- # Set the latest version in the versions.yml file
143- echo " Update the latest version in the versions.yml file"
144- sed -i " /^\(- latest\).*/s//\1 \($npm_current_package_version \)/" $RA_DOC_PATH /_data/versions.yml
145- if [ " $npm_previous_package_minor_version " != " $npm_current_package_minor_version " ]; then
146- echo " Add the previous minor version to the list of versions in the versions.yml file"
147- # Add the previous minor version to the list of versions in the versions.yml file
148- sed -i " /^\(- latest.*\)/s//\1 \n- \" $npm_previous_package_minor_version \" /" $RA_DOC_PATH /_data/versions.yml
149- fi
150- if [ -z " $RELEASE_DRY_RUN " ]; then
151- ( cd $RA_DOC_PATH && git add . && git commit -m " Update the documentation for version $npm_current_package_version " && git push )
152- else
153- echo " dry mode -- skipping commit and push of the documentation"
154- fi
216+ retry_step " Update documentation" "
217+ cd \$ RA_DOC_PATH &&
218+ git pull &&
219+ cd - &&
220+ RA_DOC_PATH=\"\$ RA_DOC_PATH\" VERSION=\"\$ npm_current_package_minor_version\" ./scripts/copy-ra-oss-docs.sh &&
221+ sed -i \" /^\(- latest\).*/s//\1 (\$ npm_current_package_version)/\" \$ RA_DOC_PATH/_data/versions.yml &&
222+ if [ \"\$ npm_previous_package_minor_version\" != \"\$ npm_current_package_minor_version\" ]; then
223+ sed -i \" /^\(- latest.*\)/s//\1 \n- \\\"\$ npm_previous_package_minor_version\\\" /\" \$ RA_DOC_PATH/_data/versions.yml
224+ fi &&
225+ if [ -z \"\$ RELEASE_DRY_RUN\" ]; then
226+ cd \$ RA_DOC_PATH &&
227+ git add . &&
228+ git commit -m \" Update the documentation for version \$ npm_current_package_version\" &&
229+ git push &&
230+ cd -
231+ fi
232+ "
155233else
156- warn " Cannot find the $RA_DOC_PATH folder in the repository parent directory"
157- echo " Please update the documentation manually"
158- echo " You can use the 'copy-ra-oss-docs.sh' script if you have it"
159- echo " Press Enter when this is done"
160- read
234+ manual_step " Update documentation" "
235+ Cannot find the $RA_DOC_PATH folder in the repository parent directory
236+ Please update the documentation manually
237+ You can use the 'copy-ra-oss-docs.sh' script if you have it"
161238fi
162239
163- step " The ${npm_current_package_version} release is done! 🎉"
240+ success " 🎉 The ${npm_current_package_version} release is done! 🎉"
0 commit comments