Skip to content

Commit

Permalink
Infra: Release workflow with changesets. (#2384)
Browse files Browse the repository at this point in the history
Integrate changesets release workflows for Victory. Closes #2373 

- Adds changesets code, tasks, and CI support.
- Adds per-package CHANGELOG.md files to reference our old root one for previous versions.
  • Loading branch information
ryan-roemer authored Jul 27, 2022
1 parent a311c29 commit 2ec8d5d
Show file tree
Hide file tree
Showing 37 changed files with 830 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": ["@svitejs/changesets-changelog-github-compact", { "repo": "FormidableLabs/victory" }],
"access": "public",
"baseBranch": "main",
"fixed": [["victory*"]]
}
58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: 18.x

# Wireit cache
- uses: google/wireit@setup-github-actions-caching/v1

- uses: pnpm/[email protected]
with:
version: 7

- name: Get pnpm store directory
id: pnpm-cache
run: echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"

- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Build packages
run: pnpm run build

- name: PR or Publish
id: changesets
uses: changesets/action@v1
with:
# Note: Our `package.json:scripts.version` currently doesn't have `--fix-lockfile` for
# `pnpm install` because of a PNPM bug of some kind.
# See spectacle issue: https://github.com/FormidableLabs/spectacle/issues/1156
version: pnpm run version
publish: pnpm run publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Victory Changelog

> **Note**
> We have moved to per-package `CHANGELOG.md` files since migrating to changesets. Please refer to those individual changelogs for change history.
## 36.5.3 (2022-06-27)
* Export all types from Victory
* Fix for #2329 (use-animation-state crashing charts)
Expand Down
90 changes: 86 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,92 @@ $ pnpm run chromatic

## Release

<!--
TODO(release): REWRITE WHOLE SECTION
https://github.com/FormidableLabs/victory/issues/2373
-->
We use [changesets](https://github.com/changesets/changesets) to create package versions and publish them.

### Using changsets

Our official release path is to use automation to perform the actual publishing of our packages. The steps are to:

1. A human developer adds a changeset. Ideally this is as a part of a PR that will have a version impact on a package.
2. On merge of a PR our automation system opens a "Version Packages" PR.
3. On merging the "Version Packages" PR, the automation system publishes the packages.

Here are more details:

### Add a changeset

When you would like to add a changeset (which creates a file indicating the type of change), in your branch/PR issue this command:

```sh
$ pnpm changeset
```

to produce an interactive menu. Navigate the packages with arrow keys and hit `<space>` to select 1+ packages. Hit `<return>` when done. Select semver versions for packages and add appropriate messages. From there, you'll be prompted to enter a summary of the change. Some tips for this summary:

1. Aim for a single line, 1+ sentences as appropriate.
2. Include issue links in GH format (e.g. `#123`).
3. You don't need to reference the current pull request or whatnot, as that will be added later automatically.

After this, you'll see a new uncommitted file in `.changesets` like:

```sh
$ git status
# ....
Untracked files:
(use "git add <file>..." to include in what will be committed)
.changeset/flimsy-pandas-marry.md
```

Review the file, make any necessary adjustments, and commit it to source. When we eventually do a package release, the changeset notes and version will be incorporated!

### Creating versions

On a merge of a feature PR, the changesets GitHub action will open a new PR titled `"Version Packages"`. This PR is automatically kept up to date with additional PRs with changesets. So, if you're not ready to publish yet, just keep merging feature PRs and then merge the version packages PR later.

### Publishing packages

On the merge of a version packages PR, the changesets GitHub action will publish the packages to npm.

### The manual version

For exceptional circumstances, here is a quick guide to manually publishing from a local computer using changesets.

1. Add a changeset with `pnpm changeset`. Add changeset file, review file, tweak, and commit.
2. Make a version. Due to our changelog plugin you will need to create a personal GitHub token and pass it to the environment.

```sh
$ GITHUB_TOKEN=<INSERT TOKEN> pnpm run version
```

Review git changes, tweak, and commit.

3. Publish.

First, build necessary files:

```sh
# Build everything
$ pnpm run build
```

Then publish:

```sh
# Test things out first
$ pnpm -r publish --dry-run
# The real publish
# This first does a single git tag (if not already present), then publishes
$ pnpm run publish --otp=<insert otp code>
```

Note that publishing multiple pacakges via `changeset` to npm with an OTP code can often fail with `429 Too Many Requests` rate limiting error. Take a 5+ minute coffee break, then come back and try again.

Then issue the following to also push git tags:

```sh
$ git push && git push --tags
```

## Contributor Covenant Code of Conduct

Expand Down
23 changes: 19 additions & 4 deletions package-scripts.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
/**
* Workspace scripts.
*
* We only use `nps` for scripts that we:
* We generally use `nps` for scripts that we:
* 1. define at the root of the monorepo
* 2. that are meant to execute _within_ a workspace
*
* If you have an actual root task, define it in root `package.json:scripts`.
* ... or ...
*
* - That could use a little JS magic that we don't want to write a full
* node script for 😂
*
* For more cases, if you have an actual root task, define it in root
* `package.json:scripts`.
*/

const path = require("path");
const PKG_SRC = path.resolve("src");

// For publishing, use the core package's version.
const coreVersion = require("./packages/victory-core/package.json").version;
if (!coreVersion) {
throw new Error("Unable to read core version");
}
const coreTag = `v${coreVersion}`;

module.exports = {
scripts: {
// Root tasks.
// Try to find an existing tag (from previous attempts, etc.), and if not, create one.
"git:tag": `git show-ref ${coreTag} || git tag -a ${coreTag} -m \"Version ${coreVersion}\"`,

// Build.
// - Libraries
"build:lib:esm":
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
"@babel/plugin-transform-template-literals": "7.16.7",
"@babel/preset-react": "7.16.7",
"@babel/preset-typescript": "^7.17.12",
"@changesets/cli": "^2.24.1",
"@storybook/addon-actions": "^6.5.6",
"@storybook/addon-options": "^5.3.21",
"@storybook/addon-storysource": "^6.5.6",
"@storybook/react": "^6.5.6",
"@svitejs/changesets-changelog-github-compact": "^0.1.1",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/react": "^13.3.0",
"@testing-library/react-hooks": "^8.0.0",
Expand Down Expand Up @@ -116,6 +118,8 @@
}
},
"scripts": {
"version": "pnpm changeset version && pnpm install",
"publish": "nps git:tag && pnpm changeset publish --no-git-tag",
"start": "concurrently --raw \"pnpm:build:lib:esm --watch\" \"webpack serve --config ./config/webpack/demo/webpack.config.dev.js --static demo/js --entry ./demo/js/app\"",
"start:ts": "concurrently --raw \"pnpm:build:typescript --watch\" \"webpack serve --config ./config/webpack/demo/webpack.config.dev.js --static demo/ts --entry ./demo/ts/app\"",
"check": "wireit",
Expand Down
5 changes: 5 additions & 0 deletions packages/victory-area/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-area

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-axis/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-axis

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-bar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-bar

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-box-plot/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-box-plot

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-brush-container/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-brush-container

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-brush-line/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-brush-line

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-candlestick/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-candlestick

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-canvas

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-chart/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-chart

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-core

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-create-container/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-create-container

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-cursor-container/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-cursor-container

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-errorbar/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-errorbar

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-group/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-group

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-histogram/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-histogram

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-legend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-legend

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-line/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-line

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-native/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-native

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-pie/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-pie

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-polar-axis/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-polar-axis

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-scatter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-scatter

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-selection-container/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-selection-container

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-shared-events/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-shared-events

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-stack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-stack

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-tooltip/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-tooltip

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-vendor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-vendor

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
5 changes: 5 additions & 0 deletions packages/victory-voronoi-container/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# victory-voronoi-container

## 36.5.3 and earlier

Change history for version 36.5.3 and earlier can be found in our root [CHANGELOG.md](https://github.com/FormidableLabs/victory/blob/main/CHANGELOG.md).
Loading

0 comments on commit 2ec8d5d

Please sign in to comment.