docusaurus/admin/scripts/test-release.sh
Sébastien Lorber ac4a253cdf
chore: fix e2e yarn berry tests (#5342)
* disable pnp

* test-release support --skip-install + revert to pnp mode

* fix yarn canary?

* add YARN_ENABLE_IMMUTABLE_INSTALLS env

* add nodeLinker matrix

* Update .github/workflows/v2-tests-e2e.yml

Co-authored-by: Kristoffer K. <merceyz@users.noreply.github.com>

* polish e2e test workflows

* polish e2e test workflows

* set npm_config_registry

Co-authored-by: Kristoffer K. <merceyz@users.noreply.github.com>
2021-08-12 13:18:07 +02:00

59 lines
1.7 KiB
Bash
Executable file

#!/usr/bin/env bash
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
set -euo pipefail
CUSTOM_REGISTRY_URL="http://localhost:4873"
NEW_VERSION="$(node -p "require('./packages/docusaurus/package.json').version").NEW"
CONTAINER_NAME="verdaccio"
EXTRA_OPTS=""
usage() { echo "Usage: $0 [-n] [-s]" 1>&2; exit 1; }
while getopts ":ns" o; do
case "${o}" in
n)
EXTRA_OPTS="--use-npm"
;;
s)
EXTRA_OPTS="--skip-install"
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
if [ ! -z $EXTRA_OPTS ]
then
echo docusaurus-init extra options = ${EXTRA_OPTS}
fi
# 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:latest
# Build packages
yarn build:packages
# Publish the monorepo
npx --no-install lerna publish --exact --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
npm_config_registry="$CUSTOM_REGISTRY_URL" npx @docusaurus/init@"$NEW_VERSION" init test-website classic $EXTRA_OPTS
# Stop Docker container
if [[ -z "${KEEP_CONTAINER:-}" ]] && ( $(docker container inspect "$CONTAINER_NAME" > /dev/null 2>&1) ); then
# Remove Docker container
docker container stop $CONTAINER_NAME > /dev/null
fi
echo "The website with to-be published packages was successfully build to the $(tput setaf 2)test-website$(tput sgr 0) directory."