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

chore: add prerelease script #876

Merged
merged 10 commits into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from 4 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
15 changes: 15 additions & 0 deletions admin/prerelease.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Prereleasing New Version of Docusaurus

[![asciicast](https://asciinema.org/a/n8rm53yfNURlIreGJkdSTgfAi.png)](https://asciinema.org/a/n8rm53yfNURlIreGJkdSTgfAi)

# Steps

1. Ensure that `origin` remote is your Docusaurus fork. Example
Copy link
Contributor

Choose a reason for hiding this comment

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

Before executing any of these steps, we will have to make the changes in the CHANGELOG, etc, is that right? If so, we should add it before this step.

Copy link
Contributor Author

@endiliey endiliey Jul 31, 2018

Choose a reason for hiding this comment

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

Yes we had to make changes in CHANGELOG, etc as well.

However, for CHANGELOG I propose that we now start adding changelog everytime we merge PR just like how jest do it. This will make it easier for our process.

Example:
A recently closed PR in jest https://github.com/facebook/jest/pull/6776/files has a changelog commit as well

Then we will always have a changelog for master version
screenshot_20180731-070432

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not opposed to trying that but feel that it's hard for Docusaurus PR submitters to write the CHANGELOG. We'll need to create a template for the next version and pending PRs would always have to take note of which section of CHANGELOG they're updating. Might be a source of frequent merge conflicts. @JoelMarcey thoughts?

Copy link
Contributor Author

@endiliey endiliey Jul 31, 2018

Choose a reason for hiding this comment

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

Alternatively, the person who merge the PR should update the changelog just right before merging it.

So PR submitter doesn't have to do it


```bash
$ git remote -v
origin https://github.com/endiliey/Docusaurus.git (fetch)
origin https://github.com/endiliey/Docusaurus.git (push)
```

2. Run `bash scripts/prerelease.sh` to create a pull request for release of new version.
47 changes: 47 additions & 0 deletions scripts/prerelease.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash

echo "Select an option for release:"
echo

select VERSION in patch minor major "Specific Version"
do
echo
if [[ $REPLY =~ ^[1-4]$ ]]; then
if [[ $REPLY == 4 ]]; then
read -p "Enter a specific version: " -r VERSION
echo
if [[ -z $REPLY ]]; then
VERSION=$REPLY
fi
fi

read -p "Release $VERSION - are you sure? (y/n) " -n 1 -r
Copy link
Contributor

Choose a reason for hiding this comment

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

I think "Submit a PR for a bump in $VERSION version - Are you sure ..." is clearer.

echo

if [[ $REPLY =~ ^[Yy]$ || -z $REPLY ]]; then
# bump version
yarn version --new-version $VERSION --no-git-tag-version
NEW_VERSION=$(node -p "require('./package.json').version")

# create new branch
git checkout -b $NEW_VERSION master
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should create new branch before bumping version just to be safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did this because I wanted to get the new version (after bump) as the branch name. How about naming it to prerelease ? We can also delete the existing local prerelease branch as well before creating new branch

Copy link
Contributor

Choose a reason for hiding this comment

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

Mm gotcha. Let's leave this as it is. On second thought it's fine because we're not committing yet.


# cut docusaurus docs version
cd website && yarn run version $NEW_VERSION
Copy link
Contributor

Choose a reason for hiding this comment

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

Omg we should probably rename this command within website/package.json. It's easy to confuse with yarn's native version command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will docsversion do?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good. Will need to update a few places as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually i wanted to rework all the CLI commands to docusaurus <command> instead of docusaurus-command but this might lead to breaking changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yes we should do that, but not now. I fully agree with you (wrote about that in v2 under API) also.


# Create PR
echo "Creating Pull Request for Release ${NEW_VERSION}"
git add .
git commit -m "v$NEW_VERSION"
git push origin $NEW_VERSION
echo "✅ Release PR created"
else
echo Cancelled
fi
break
else
echo Invalid \"${REPLY}\"
echo "To continue, please enter one of the options (1-4):"
echo
fi
done