|
| 1 | +# 🚢 Release Workflow with Changesets |
| 2 | + |
| 3 | +This document describes how we use [Changesets](https://github.com/changesets/changesets) in our daily development workflow to manage versions, changelogs, and releases in this monorepo. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 📖 What are Changesets? |
| 8 | + |
| 9 | +A **changeset** is a small Markdown file committed alongside your code changes. It records: |
| 10 | + |
| 11 | +- Which packages are affected |
| 12 | +- What type of version bump they require (`patch`, `minor`, `major`) |
| 13 | +- A short description that will appear in the changelog |
| 14 | + |
| 15 | +By collecting these small pieces of information, we can automatically generate: |
| 16 | + |
| 17 | +- Version bumps in `package.json` |
| 18 | +- Updated `CHANGELOG.md` entries |
| 19 | +- Release PRs and npm publishes |
| 20 | +- [GitHub Releases](https://github.com/db-ux-design-system/core-web/releases) |
| 21 | + |
| 22 | +--- |
| 23 | + |
| 24 | +## 🛠 Workflow |
| 25 | + |
| 26 | +### 1. After making a change → add a changeset |
| 27 | + |
| 28 | +Run: |
| 29 | + |
| 30 | +```bash |
| 31 | +npx changeset |
| 32 | +``` |
| 33 | + |
| 34 | +You’ll be prompted to: |
| 35 | + |
| 36 | +- Select affected packages |
| 37 | +- Choose the bump/release type (patch, minor, major) |
| 38 | +- Provide a short summary for the changelog |
| 39 | + |
| 40 | +This creates a file like `.changeset/abcd123.md`. |
| 41 | +👉 Commit this file as part of your PR. |
| 42 | + |
| 43 | +### 2. Open a Pull Request |
| 44 | + |
| 45 | +- Every PR that changes published code must include a changeset file. |
| 46 | +- CI will verify the existence of at least one changeset when necessary. |
| 47 | + |
| 48 | +### 3. Release PRs |
| 49 | + |
| 50 | +When PRs are merged into `main` branch, the Release workflow will: |
| 51 | + |
| 52 | +- Collect pending changesets |
| 53 | +- Open (or update) a Release PR called “Version Packages” |
| 54 | +- Run `changeset version` to bump versions and update changelogs |
| 55 | + |
| 56 | +This PR should be reviewed like any other: |
| 57 | + |
| 58 | +- Check the versions are correct |
| 59 | +- Review the generated changelogs |
| 60 | + |
| 61 | +Once everything looks good, merge the Release PR. |
| 62 | + |
| 63 | +### 4. Publishing |
| 64 | + |
| 65 | +After the Release PR is merged into `main` branch: |
| 66 | + |
| 67 | +- CI will build the packages (`./build-outputs/`) |
| 68 | +- Publish new versions to npm with the tag `latest` |
| 69 | +- Create a [GitHub Release](https://github.com/db-ux-design-system/core-web/releases) |
| 70 | + |
| 71 | +You don’t have to run anything manually, it’s handled by CI. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## ✅ Best Practices |
| 76 | + |
| 77 | +- **Always add a changeset** |
| 78 | + |
| 79 | + If your code change affects published packages, create a changeset. |
| 80 | + |
| 81 | + No changeset → no version bump → no release. |
| 82 | + |
| 83 | +- **Choose the correct bump type** |
| 84 | + - patch: bugfix, no API or HTML changes |
| 85 | + - minor: new features, changes in inner component markup or behavior, backwards-compatible |
| 86 | + - major: breaking changes (e.g. removed props, changed APIs) |
| 87 | + |
| 88 | +- **Write user-friendly summaries** |
| 89 | + |
| 90 | + The text you provide will be copied into the `CHANGELOG.md`. Keep it concise and helpful. |
| 91 | + |
| 92 | +- **One changeset per PR** |
| 93 | + |
| 94 | + Usually you only need one. If a PR touches multiple packages with different bump types, a single changeset can cover them all. |
| 95 | + |
| 96 | +- **Baseline snapshots** |
| 97 | + |
| 98 | + ARIA snapshots by Playwright help detect markup changes. If they change, prefer minor instead of patch. |
| 99 | + And please mention those HTML changes within the `CHANGELOG.md` or of necessary (like bigger changes) in a [migration guide](https://github.com/db-ux-design-system/core-web/tree/main/docs/migration). |
| 100 | + |
| 101 | +- **Avoid manual version bumps** |
| 102 | + |
| 103 | + Never edit `package.json` `version` field by hand. Changesets handles this automatically. |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## 🚧 Pre-Releases |
| 108 | + |
| 109 | +We handle pre-releases without changesets. |
| 110 | +Instead, create a new [GitHub release](https://github.com/db-ux-design-system/core-web/releases/new) |
| 111 | +with a tag like `1.2.3-next0` and the CI will pick it up and publish it to npm with the tag `next`. |
| 112 | + |
| 113 | + |
| 114 | +--- |
| 115 | + |
| 116 | + |
| 117 | +## 🔑 Cheatsheet |
| 118 | + |
| 119 | +```bash |
| 120 | +# Initialize Changesets (only once per repo) |
| 121 | +npx changeset init |
| 122 | + |
| 123 | +# Create a new changeset |
| 124 | +npx changeset |
| 125 | + |
| 126 | +# Show pending releases |
| 127 | +npx changeset status --verbose |
| 128 | + |
| 129 | +# Apply version bumps and changelogs |
| 130 | +npx changeset version |
| 131 | + |
| 132 | +# Pre-release mode |
| 133 | +npx changeset pre enter next # enter prerelease |
| 134 | +npx changeset pre exit # exit prerelease |
| 135 | +``` |
| 136 | + |
| 137 | +--- |
| 138 | + |
| 139 | +## 📂 File Overview |
| 140 | + |
| 141 | +- `.changeset/` → contains pending changesets (`.md` files) |
| 142 | +- `package.json` → versions are updated automatically in this file |
| 143 | +- `CHANGELOG.md` → updated by changeset version |
| 144 | +- `.github/workflows/changesets-release-pr.yml` → automation for Release PRs & publishing |
| 145 | +- `.github/workflows/pull-request-snapshot-diff.yml` → validates changes in PNG/YML snapshots and enforces at least a MINOR bump |
| 146 | +- `scripts/github/publish-npm.js` → custom publish script (packs & publishes built outputs) |
0 commit comments