Skip to content

Commit

Permalink
WB-586: Add changesets to automate the release process (#1221)
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
<img width="2890" alt="Wonder Blocks Web Eng process" src="https://user-images.githubusercontent.com/843075/142078849-75ec28bf-98b5-4c55-b3f6-de2d63a4d90d.png">




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: 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`).

Here's an example of how the `Release PR` will look: emotion-js/emotion#2394

Author: jandrade

Reviewers: kevinbarabash, jandrade

Required Reviewers:

Approved By: kevinbarabash

Checks: ✅ codecov/project, ✅ Mixed content, ⚪️ Redirect rules, ⚪️ Header rules, ⚪️ Pages changed, ✅ gerald, ✅ lint_and_test (ubuntu-latest, 12), ⏭  dependabot, ✅ chromatic (ubuntu-latest, 12)

Pull Request URL: #1221
  • Loading branch information
jandrade authored Dec 6, 2021
1 parent e47ebcc commit 1ceaec4
Show file tree
Hide file tree
Showing 5 changed files with 649 additions and 13 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": []
}
70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Release

on:
push:
branches:
- master

# This workflow will run changesets depending on two different scenarios:
#
# 1. If we are landing a specific commit into master (Author PR), then
# changesets will check if there are changes verifying the Markdown files
# generated automatically:
#
# a) There are new versions and there's NO Release PR, then the changesets
# action will create a new Release PR.
#
# b) There's a Release PR, then the changesets action will update the
# existing Release PR with the new commit.
#
# NOTE: (in both cases, changesets will modify the new version in
# package.json for each package, and will remove the MD files as part of the
# Release PR).
#
# 2. If we are landing the Release PR into master, then the changesets action
# will publish the changes to npm.
#
# For more info about this workflow, see:
# https://github.com/changesets/action#usage
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 publish:ci
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Send a Slack notification if a publish happens
if: steps.changesets.outputs.published == 'true'
uses: rtCamp/action-slack-notify@v2
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 @@ -23,7 +23,8 @@
"lint:watch": "esw --watch --config ./eslint/eslintrc packages",
"lint": "eslint --config .eslintrc.js packages",
"lint:ci": "eslint --config .eslintrc.js",
"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",
"publish:ci": "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 @@ -44,6 +45,7 @@
"@babel/plugin-transform-spread": "7.12.1",
"@babel/preset-env": "^7.16.4",
"@babel/preset-react": "^7.16.0",
"@changesets/cli": "^2.18.0",
"@khanacademy/eslint-config": "^0.1.0",
"@storybook/addon-a11y": "^6.3.12",
"@storybook/addon-essentials": "^6.3.12",
Expand Down
Loading

0 comments on commit 1ceaec4

Please sign in to comment.