diff --git a/admin/publish.md b/admin/publish.md index 06377179ac89..617a8b669d82 100644 --- a/admin/publish.md +++ b/admin/publish.md @@ -16,6 +16,24 @@ If you are not currently logged into npm on your CLI, do the following: If you're publishing new v2 versions, 2FA might get in the way as the pin might expire during the publishing as there are over 10 packages to publish. You're encouraged not to use the "Authorization and Publishing" 2FA option. +### 0. Build skeleton website with new version (Docker required) + +To make sure that all packages will work correctly when they are published, you can build them locally and use them to run the skeleton website: + +```bash +yarn test:build:v2 +``` + +This command will build all the packages that it will publish to the running private npm proxy registry, and then initialize a new website in the `test-website` directory. Now you can start the dev server and/or make a production built. + +```bash +cd test-website +yarn start +yarn build # after manual testing in browser +``` + +If there are no errors, you can start preparing for the new release. + ### 1. Update the v2 changelog Generate a GitHub auth token by going to https://github.com/settings/tokens. Save the token somewhere for future reference. diff --git a/admin/scripts/test-release.sh b/admin/scripts/test-release.sh new file mode 100755 index 000000000000..eb751b7ec83d --- /dev/null +++ b/admin/scripts/test-release.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -euo pipefail + +CUSTOM_REGISTRY_URL="http://localhost:4873" +npm_config_registry="$CUSTOM_REGISTRY_URL" +ORIGINAL_YARN_REGISTRY_URL=`yarn config get registry` +NEW_VERSION="$(node -p "require('./packages/docusaurus/package.json').version").NEW" +CONTAINER_NAME="verdaccio" + +# Run Docker container with private npm registry Verdaccio +docker run -d --rm --name "$CONTAINER_NAME" -p 4873:4873 -v "$PWD/admin/verdaccio.yaml":/verdaccio/conf/config.yaml verdaccio/verdaccio:4 + +# Build packages +yarn tsc + +# Set Yarn registry to own local registry +yarn config set registry "$CUSTOM_REGISTRY_URL" + +# Publish the monorepo +npx --no-install lerna publish --yes --no-verify-access --no-git-reset --no-git-tag-version --no-push --registry "$CUSTOM_REGISTRY_URL" "$NEW_VERSION" + +# Revert version changes +git diff --name-only -- '*.json' | sed 's, ,\\&,g' | xargs git checkout -- + +# Build skeleton website with new version +npx @docusaurus/init@latest init test-website classic + +# Restore the original Yarn registry URL +yarn config set registry "$ORIGINAL_YARN_REGISTRY_URL" + +# Stop Docker container +if ( $(docker container inspect "$CONTAINER_NAME" > /dev/null 2>&1) ); then + # Remove Docker container + docker container stop $CONTAINER_NAME +fi + +echo "The website with to-be published packages was successfully build to the $(tput setaf 2)test-website$(tput sgr 0) directory." diff --git a/admin/verdaccio.yaml b/admin/verdaccio.yaml new file mode 100644 index 000000000000..a2d9e4e223b7 --- /dev/null +++ b/admin/verdaccio.yaml @@ -0,0 +1,32 @@ +# +# This is the default config file. It allows all users to do anything, +# so don't use it on production systems. +# +# Look here for more config file examples: +# https://github.com/verdaccio/verdaccio/tree/master/conf +# + +# File paths are relative to this configuration file. + +# Path to a directory with all packages +# storage: ./tmp/verdaccio + +storage: ../storage + +# A list of other known repositories we can talk to +uplinks: + npmjs: + url: https://registry.npmjs.org/ +packages: + '**': + # Allow all users (including non-authenticated users) to read and + # publish all packages + access: $all + publish: $all + + # Download from npm if a package is not available in the local registry + proxy: npmjs + +# Log settings +logs: + - {type: stdout, format: pretty, level: http} diff --git a/package.json b/package.json index 929568895b0d..e15c500ade4c 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "lint": "eslint --cache \"**/*.js\" && stylelint \"**/*.css\"", "lerna": "lerna", "test": "jest", + "test:build:v2": "./admin/scripts/test-release.sh", "tsc": "lerna run tsc --no-private" }, "devDependencies": {