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

doc(v2): publish doc update after alpha.58 release #2960

Merged
merged 4 commits into from
Jun 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ coverage
.docusaurus
.cache-loader
types
test-website
packages/docusaurus-utils/lib/
packages/docusaurus/lib/
packages/docusaurus-init/lib/
Expand Down
98 changes: 78 additions & 20 deletions admin/publish.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,84 @@
# 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).
Docusaurus is published as an npm package that can be installed via `npm` or `yarn`.

## Log in to npm
# Check publish rights

Get access from the Docusaurus npm admins (@yangshun/@JoelMarcey).

## GitHub

You need publish access to **the main Docusaurus repository** (not a fork).

## NPM

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 on your CLI, do the following:

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)
1. **Enable 2FA** on your account (preferably for D2: select 2FA mode `Authorization`, not `Authorization and Publishing`)

---

## Docusaurus 2

<!-- TODO: describe the process of hotfix releases -->

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.
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. Use 2FA mode `Authorization`, not `Authorization and Publishing`.

### 1. Git setup

Use the **master branch** (up to date) of the **main Docusaurus repository** (not a fork).

Create a new branch for the release (the branch name does not matter much):

```sh
git co -b <your_username>/<version_to_release>
```

### 2. Build and test the project

### 0. Build skeleton website with new version (Docker required)
Run `yarn install`

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:
It should run `yarn tsc` and build the project's packages.

```bash
To make sure that all packages will work correctly when they are published, we can initialize a new D2 skeleton website, and test that it can start/built.

```sh
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
```sh
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
**Note**: This step is also run by the CI on all pull requests ([see](https://github.com/facebook/docusaurus/pull/2954/checks?check_run_id=780871959))

### 3. Update the v2 changelog

The changelog uses GitHub labels to classify each pull request. Use the GitHub interface to assign each newly merged pull request to a GitHub label starting with `tag:`, otherwise the PR won't appear in the changelog.

The `tag:` label prefix is for PRs only. Other labels are not used by the changelog tool, and it's not necessary to assign such labels to issues, only PRs.

Generate a GitHub auth token by going to https://github.com/settings/tokens. Save the token somewhere for future reference.
Generate a GitHub auth token by going to https://github.com/settings/tokens (the only permission needed is `public_repo`). Save the token somewhere for future reference.

> Before running the command below, get all tags from the original repository by running `git fetch --tags`.
Generate the changelog with:

```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
### 4. Cut a new version of the docs

```sh
cd website
Expand All @@ -57,11 +87,26 @@ yarn run docusaurus docs:version 2.0.0-alpha.41

Test running the website with the new version locally.

### 3. Create a Pull Request
### 5. 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.
You should still be on your local branch `<your_username>/<version_to_release>`

### 4. Publish to npm
Make a commit/push, create a pull request with the changes and get it merged.

If nobody is around for a review, just wait for the CI checks to complete, check the deploy preview, and merge it.

An example PR would be [#2287](https://github.com/facebook/docusaurus/pull/2287).

### 6. Build and publish to npm

Go back to the `master` branch, from which we'll do the release

```
git checkout master
git pull
```

**Note**: the `git pull` is useful to update `master` with your recently merged PR. Unfortunately if you are unlucky this might as well include other code from other merged PRs. In such case you should ensure the extra code works correctly, and include it in the changelog. (**TODO**: make the release process more robust?)

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

Expand Down Expand Up @@ -99,13 +144,24 @@ npm access ls-packages
</pre>
</details>

If all accesses are available, build all the necessary packages with `yarn tsc`, and then you can run the command to release a new version:
It can happen that some accesses not granted, as an admin might add you to the @docusaurus NPM organisation, but you don't have access to the packages that are not in that organisation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to shift this portion higher up to the "Check publish rights". Feels more related there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought initially, but I think these rights might not apply for the v1 release process so I let them here


Please **double-check your permissions on these 3 packages**, otherwise you'll publish a half-release and will have to release a new version.

```
"docusaurus": "read-write",
"docusaurus-init": "read-write",
"stylelint-copyright": "read-write"
```

If all accesses are available, build all the necessary packages, and then run the lerna command to release a new version:

```sh
yarn tsc
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._
**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:

Expand All @@ -115,17 +171,17 @@ This command does a few things:

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

### 5. Create a release on GitHub
### 7. 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! 💰

### 6. Notify people about new release (optional but desirable)
### 8. Notify people about new release (optional but desirable)

After new release, it was cool to notify our users about this in the Dicsord chat (`docusaurus-users` channel) and write summaries in Twiiter using the following templates.
After new release, it is cool to notify our users about this in the Dicsord chat (`docusaurus-users` channel) and write summaries on Twitter using the following templates.

For Discord:

Expand Down Expand Up @@ -156,6 +212,8 @@ NOTE: most likely this last item will be relevant for each new release, so do no
https://github.com/facebook/docusaurus/releases/tag/%VER%
```

---

## Docusaurus 1

1. Bump version number in [`package.json`](https://github.com/facebook/docusaurus/blob/master/package.json).
Expand Down