Skip to content

Commit

Permalink
Merge pull request #10575 from marmelab/improve-release-script-docume…
Browse files Browse the repository at this point in the history
…ntation

[chore] Improve release script by automating documentation update
  • Loading branch information
slax57 authored Mar 7, 2025
2 parents db22f7a + d4681dc commit fd7599f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 15 deletions.
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
GITHUB_ACCESS_TOKEN=your_github_access_token
RA_ENTERPRISE_PATH=../ra-enterprise
RA_DOC_PATH=../react-admin-doc
37 changes: 37 additions & 0 deletions scripts/copy-ra-oss-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
if [ -z "$RA_DOC_PATH" ]; then
echo "RA_DOC_PATH environment variable is not set"
exit 1
fi
if [ -z "$VERSION" ]; then
echo "VERSION environment variable is not set"
exit 1
fi

#!/bin/bash
echo "Updating the documentation to version $VERSION"
echo "Copying to the root folder..."
cp ./docs/*.html ${RA_DOC_PATH}
cp ./docs/_layouts/*.html ${RA_DOC_PATH}/_layouts
cp ./docs/*.md ${RA_DOC_PATH}
cp ./docs/img/* -r ${RA_DOC_PATH}/img
cp ./docs/css/docsearch.css ${RA_DOC_PATH}/css
cp ./docs/css/prism.css ${RA_DOC_PATH}/css
cp ./docs/css/style-*.css ${RA_DOC_PATH}/css
cp ./docs/js/materialize.min.js ./docs/js/prism.js ./docs/js/ra-doc-exec.js ${RA_DOC_PATH}/js

echo "Copying to the doc/${VERSION} folder..."
mkdir -p ${RA_DOC_PATH}/doc/${VERSION}
mkdir -p ${RA_DOC_PATH}/doc/${VERSION}/img
mkdir -p ${RA_DOC_PATH}/doc/${VERSION}/css
mkdir -p ${RA_DOC_PATH}/doc/${VERSION}/js
cp ./docs/*.html ${RA_DOC_PATH}/doc/${VERSION}
cp ./docs/*.md ${RA_DOC_PATH}/doc/${VERSION}
rm ${RA_DOC_PATH}/doc/${VERSION}/404.html
cp -r ./docs/img/* ${RA_DOC_PATH}/doc/${VERSION}/img
cp ./docs/css/docsearch.css ${RA_DOC_PATH}/doc/${VERSION}/css
cp ./docs/css/prism.css ${RA_DOC_PATH}/doc/${VERSION}/css
cp ./docs/css/style-*.css ${RA_DOC_PATH}/doc/${VERSION}/css
cp ./docs/js/materialize.min.js ./docs/js/prism.js ./docs/js/ra-doc-exec.js ${RA_DOC_PATH}/doc/${VERSION}/js

echo "Done"

55 changes: 40 additions & 15 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -e
source ./.env
RA_ENTERPRISE_PATH="${RA_ENTERPRISE_PATH:-../ra-enterprise}"
RA_DOC_PATH="${RA_DOC_PATH:-../react-admin-doc}"

info() {
echo -e "\033[1;34m$1\033[0m"
Expand Down Expand Up @@ -52,38 +53,46 @@ echo "[Minor version only] Update the dependencies to RA packages in the create-
echo "Press Enter when this is done"
read

step "manual task: Update the OldVersion.md file"
echo "[Minor version only] Update the ./docs/OldVersions.md file to add the new minor version and update the previous one && commit"
echo "Press Enter when this is done"
read

# Get the current version from package.json
npm_previous_package_version=$(jq -r '.version' ./packages/react-admin/package.json)

step "lerna version"
# Running lerna version
# This will create a commit and a tag
./node_modules/.bin/lerna version --force-publish --no-push

# Get the version from package.json
npm_package_version=$(jq -r '.version' ./packages/react-admin/package.json)
npm_current_package_version=$(jq -r '.version' ./packages/react-admin/package.json)

# Remove the tag created by lerna
echo "Removing tag v${npm_package_version} created by lerna"
git tag -d "v${npm_package_version}"
echo "Removing tag v${npm_current_package_version} created by lerna"
git tag -d "v${npm_current_package_version}"
if [ ! -z "$RELEASE_DRY_RUN" ]; then
# In dry-run mode, reset the last commit to avoid accidental push
echo "dry mode -- Resetting the workspace to the last commit"
git reset --soft HEAD~1
fi

step "update-changelog"
yarn run update-changelog ${npm_package_version}
yarn run update-changelog ${npm_current_package_version}
echo "Please review the ./CHANGELOG.md file and update it if needed."
echo "Press Enter when this is done"
read
if [ -z "$RELEASE_DRY_RUN" ]; then
echo "Committing the changelog"
git add CHANGELOG.md
git commit -m "Update changelog for version ${npm_package_version}"
git commit -m "Update changelog for version ${npm_current_package_version}"
fi

step "git tag"
if [ -z "$RELEASE_DRY_RUN" ]; then
echo "Creating new tag v${npm_package_version}"
git tag "v${npm_package_version}"
echo "Creating new tag v${npm_current_package_version}"
git tag "v${npm_current_package_version}"
else
echo "dry mode -- skipping git tag"
fi
Expand All @@ -106,14 +115,30 @@ else
fi

step "update-milestones"
yarn run update-milestones ${npm_package_version}
yarn run update-milestones ${npm_current_package_version}

step "create-github-release"
yarn run create-github-release ${npm_package_version}

step "manual step: Update the documentation"
echo "You can use the 'copy-ra-oss-docs.sh' script if you have it"
echo "Press Enter when this is done"
read
yarn run create-github-release ${npm_current_package_version}

step "Update the documentation"
if [ -d $RA_DOC_PATH ]; then
# ${npm_current_package_version%.*} extract the major.minor version
RA_DOC_PATH="$RA_DOC_PATH" VERSION="${npm_current_package_version%.*}" ./scripts/copy-ra-oss-docs.sh
# Set the latest version in the versions.yml file
echo "Update the latest version in the versions.yml file"
sed -i "/^\(- latest\).*/s//\1 \($npm_current_package_version\)/" $RA_DOC_PATH/_data/versions.yml
if [ "${npm_previous_package_version%.*}" == "${npm_current_package_version%.*}" ]; then
echo "Add the previous minor version to the list of versions in the versions.yml file"
# Add the previous minor version to the list of versions in the versions.yml file
sed -i "/^\(- latest.*\)/s//\1 \n- \"${npm_current_package_version%.*}\"/" $RA_DOC_PATH/_data/versions.yml
fi
( cd $RA_DOC_PATH && git add . && git commit -m "Update the documentation for version $npm_current_package_version" && git push )
else
warn "Cannot find the $RA_DOC_PATH folder in the repository parent directory"
echo "Please update the documentation manually"
echo "You can use the 'copy-ra-oss-docs.sh' script if you have it"
echo "Press Enter when this is done"
read
fi

step "The ${npm_package_version} release is done! 🎉"
step "The ${npm_current_package_version} release is done! 🎉"

0 comments on commit fd7599f

Please sign in to comment.