Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: add instructions about test release #2486

Merged
merged 11 commits into from
Apr 2, 2020
18 changes: 18 additions & 0 deletions admin/publish.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
38 changes: 38 additions & 0 deletions admin/scripts/test-release.sh
Original file line number Diff line number Diff line change
@@ -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."
32 changes: 32 additions & 0 deletions admin/verdaccio.yaml
Original file line number Diff line number Diff line change
@@ -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}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down