Skip to content

Commit

Permalink
chore: add npm publishing instructions (#2288)
Browse files Browse the repository at this point in the history
* chore(v2): add npm publishing instructions

* use headings
  • Loading branch information
yangshun authored Feb 16, 2020
1 parent d39c301 commit 21f36e5
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 90 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG-2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

## 2.0.0-alpha.41 (2020-02-16)

## Unreleased (2020-02-16)

#### :rocket: New Feature

- `docusaurus-init`, `docusaurus-preset-classic`, `docusaurus-theme-classic`
Expand Down
27 changes: 0 additions & 27 deletions admin/prerelease.md

This file was deleted.

74 changes: 68 additions & 6 deletions admin/publish.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,71 @@
Docusaurus is published as an npm package that can be installed via `npm` or `yarn`. Here is how you publish the package to npm:
# Publishing Instructions

Docusaurus is published as an npm package that can be installed via `npm` or `yarn`. Get access from the Docusaurus npm admins (@yangshun/@JoelMarcey).

## Log in to npm

Publishing will only work if you are logged into npm with an account with admin rights to the package.
Publishing will only work if you are logged into npm with an account with publishing rights to the package.

If you are not currently logged into npm locally:
If you are not currently logged into npm on your CLI, do the following:

1. `npm adduser`
1. `npm login`
1. Enter username, password and associated email address
1. Make sure you have 2FA enabled on your account (preferably just for authorization)

## Docusaurus 2

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.

### 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.

```sh
GITHUB_AUTH=<Your GitHub auth token> yarn changelog
```

Copy the generated contents and paste them in `CHANGELOG-2.x.md`.

### 2. Cut a new version of the docs

```sh
cd website
yarn run docusaurus docs:version 2.0.0-alpha.41
```

Test running the website with the new version locally.

### 3. Create a Pull Request

Make a commit and create a pull request with the changes and get it merged. An example PR would be [#2287](https://github.com/facebook/docusaurus/pull/2287). Make sure the preview loads fine and is showing the new version.

### 4. Publish to npm

As we have a monorepo structure, we use `lerna publish` to publish the new version of packages to npm in one shot.

```sh
yarn lerna publish 2.0.0-alpha.41 --dist-tag next
```

_Note: The v1 packages will also be modified because it's part of the monorepo. It is not ideal but we will live with it for now._

This command does a few things:

- Modifies the versions of all the `package.json` in the repository to be `2.0.0-alpha.41` and creates a commit
- Creates a new Git tag `v2.0.0-alpha.41`
- Pushes the new commit and Git tag to `master`

You should receive many emails notifying you that a new version of the packages has been published.

### 5. Create a release on GitHub

- Go to https://github.com/facebook/docusaurus/releases/new
- Under the "Tag version" field, look for the newly-created tag, which is `v2.0.0-alpha.41` in this case
- Paste the CHANGELOG changes in the textarea below
- Hit the green "Publish release" button
- Profit! 💰

## Publish
## Docusaurus 1

1. Bump version number in [`package.json`](https://github.com/facebook/docusaurus/blob/master/package.json).
1. Update the [changelog](https://github.com/facebook/docusaurus/blob/master/CHANGELOG.md), including at the reference links at the bottom.
Expand All @@ -19,8 +75,14 @@ If you are not currently logged into npm locally:
1. From the `website-1.x` directory, run `npm run docusaurus-version x.x.x`, where x.x.x is the same version number you updated to in `package.json`.
1. Test your PR locally on a project that was created via [these instructions](https://github.com/facebook/docusaurus/blob/master/admin/local-third-party-project-testing.md).
1. Submit your PR
1. When your PR is merged, rebase to get the PR commit locally.
1. When your PR is merged, rebase to get the PR commit locally
1. Run `npm publish`
1. Tag the commit with the new version prefixed with a `v` (e.g. `v1.19.0`) and push the tag to `master`
1. Go to https://github.com/facebook/docusaurus/releases/new
1. Under the "Tag version" field, look for the newly-created tag
1. Paste the CHANGELOG changes in the textarea below
1. Hit the green "Publish release" button
1. Profit! 💰

### What version should you use?

Expand Down
55 changes: 0 additions & 55 deletions scripts/prerelease.sh

This file was deleted.

0 comments on commit 21f36e5

Please sign in to comment.