Skip to content

Commit

Permalink
WB-586: Add changesets to automate the release process
Browse files Browse the repository at this point in the history
Summary:

- Introduces `changesets` to the repository.
- Adds a new workflow to handle releases. This will be triggered after
  the "release coordinator" (one of WB's admins) has approved the
  release (by hitting the `Merge` button).
- Creates a new `release` script to handle releases using `changesets`
  instead of `lerna`. (keeping `lerna/publish` for backwards compatibility).

More info about the new release process here:
https://www.figma.com/file/xaYyzIuKLxqXAJVAl3y1S4/Wonder-Blocks-Web-Eng-process?node-id=50%3A400

NOTE: To include a regular PR in the release PR, the PR's author will
need to run `yarn changesets` to include the changes for each package
they have changed.

More info about using it on this part of the process here: https://www.figma.com/file/xaYyzIuKLxqXAJVAl3y1S4/Wonder-Blocks-Web-Eng-process?node-id=81%3A549

Issue: https://khanacademy.atlassian.net/browse/WB-586

Test plan:

Merge this PR and verify that the "Release PR" gets created after a
contributor lands a PR (merges it into `master`).
  • Loading branch information
jandrade committed Nov 16, 2021
1 parent 61090a6 commit edf3d58
Show file tree
Hide file tree
Showing 5 changed files with 619 additions and 14 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
10 changes: 10 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/@changesets/config@1.6.2/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"linked": [],
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": []
}
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release

on:
push:
branches:
- master

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so that Changesets can
# generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 12.x
uses: actions/setup-node@master
with:
node-version: 12.x

- name: Install Dependencies
run: yarn

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@master
with:
publish: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Send a Slack notification if a publish happens
- uses: rtCamp/action-slack-notify@v2
if: steps.changesets.outputs.published == 'true'
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_CHANNEL: wonder-blocks-eng
SLACK_MSG_AUTHOR: ${{ github.event.pull_request.user.login }}
SLACK_USERNAME: GithubGoose
SLACK_ICON_EMOJI: ":goose:"
SLACK_MESSAGE: "A new version of ${GITHUB_REPOSITORY} was published! [Release notes →](<https://github.com/Khan/wonder-blocks/releases/>)"
SLACK_TITLE: "New Wonder Blocks release!"
SLACK_FOOTER: Wonder Blocks Slack Notification
MSG_MINIMAL: true
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"jest": "jest --config config/jest/test.config.js",
"lint:watch": "esw --watch --config ./eslint/eslintrc packages",
"lint": "eslint --config .eslintrc.js packages",
"publish": "node utils/pre-publish-check.js && git diff --stat --exit-code HEAD && yarn build:cjs && yarn build:es6 && lerna publish",
"publish": "node utils/pre-publish-check.js && git diff --stat --exit-code HEAD && yarn build:all && lerna publish",
"release": "node utils/pre-publish-check.js && git diff --stat --exit-code HEAD && yarn build:all && changeset publish",
"start:prod": "yarn run build:styleguidist && yarn run start:styleguidist --config styleguide.prod.config.js",
"start:storybook": "start-storybook -s ./static -p 6061",
"start:styleguidist": "styleguidist server",
Expand All @@ -41,6 +42,7 @@
"@babel/plugin-transform-spread": "7.12.1",
"@babel/preset-env": "^7.13.10",
"@babel/preset-react": "^7.13.8",
"@changesets/cli": "^2.18.0",
"@khanacademy/eslint-config": "0.0.5",
"@storybook/addon-a11y": "^6.3.7",
"@storybook/addon-essentials": "^6.3.7",
Expand Down
Loading

0 comments on commit edf3d58

Please sign in to comment.