Skip to content

Commit d48149f

Browse files
michaelmkrausgithub-actions[bot]mfranzkeCopilotnmerget
authored
feat: implement changesets in repo (#4735)
* feat: init changesets in repo * docs: update README.md to describe workflow with changesets * feat: added action to create/update release pr and update README.md * chore: disable husky for action to avoid error due to branch name generated by changesets * fix: adapted logging for action * fix: only call action on main push * chore: adapted action with preview step * chore: adapted action to explicitly fetch main * chore: adapted action to explicitly fetch main * chore: adapted shallow check * chore: fix eof error * chore: add comments to action and adapt runner * auto update snapshots (#4768) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add action to check html snapshots * fix: encode markdown in action * fix: encode markdown in action * fix: use env var instead of output * fix: use env var instead of output * feat: add action to check changes of snapshots * chore: change snapshot for testing * chore: bump to minor to check snapshot changes * chore: bump to minor to check changeset * fix: adapt determine bump plan in action * fix: adapt determine bump plan in action * fix: adapt determine bump plan in action * chore: roll back changed snapshot * revert: restore snapshots to main baseline * docs: include new action in readme * chore: remove core-web.iml * chore: remove core-web.iml * fix: revert accidental snapshot whitespace change * docs: add more comments to snapshot action * docs: add more comments to changeset action * docs: adapt README.md * chore: remove direct call of changeset in scripts * docs: adapt README.md * fix: resolve conflicts * chore: regenerate package-lock with Node 24 to include changesets * Apply suggestions from code review Co-authored-by: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> * chore: switch to changelog-github * chore: use job-level concurrency with cancel-in-progress * chore: use local Changesets CLI instead of ad-hoc install * chore: use node:fs builtin import in bump-plan step * chore: add early bump-plan step to skip snapshot checks on minor/major * chore: drop .changeset/*.md fallback in bump-plan step; JSON-only with env OR * chore(): remove status preview steps which are already covered by the copilot bot * Update .changeset/README.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update .github/workflows/pull-request-snapshot-diff.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Apply suggestions from code review * Update .changeset/README.md Co-authored-by: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> * Update .changeset/config.json Co-authored-by: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> * Update .changeset/README.md Co-authored-by: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> * Update .changeset/README.md Co-authored-by: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> * Update .changeset/README.md Co-authored-by: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> * Update .changeset/README.md Co-authored-by: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> * chore: refactor changeset publish process * chore: update package versions to 0.0.0 and adjust changeset configuration --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Nicolas Merget <104347736+nmerget@users.noreply.github.com> Co-authored-by: Nicolas Merget <nicolas.merget@deutschebahn.com>
1 parent ec7da1f commit d48149f

File tree

15 files changed

+3890
-1802
lines changed

15 files changed

+3890
-1802
lines changed

.changeset/README.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
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)

.changeset/config.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config/schema.json",
3+
"changelog": "@changesets/changelog-git",
4+
"commit": true,
5+
"fixed": [
6+
[
7+
"@db-ux/core-foundations",
8+
"@db-ux/core-components",
9+
"@db-ux/react-core-components",
10+
"@db-ux/ngx-core-components",
11+
"@db-ux/v-core-components",
12+
"@db-ux/wc-core-components",
13+
"@db-ux/core-stylelint",
14+
"@db-ux/core-migration"
15+
]
16+
],
17+
"ignore": ["scripts"],
18+
"linked": [],
19+
"access": "public",
20+
"baseBranch": "main",
21+
"updateInternalDependencies": "patch"
22+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# -------------------------------------------------------------
2+
# 🚢 Changesets – Create/Update Release PR and Cut Tags
3+
# Main path: on push to main, create/update the Release PR and cut tags/GitHub Releases
4+
# -------------------------------------------------------------
5+
name: Changesets – Create/Update Release PR and Cut Tags
6+
7+
on:
8+
push:
9+
branches: ["main"]
10+
11+
permissions:
12+
# Needed to push version commit + create releases
13+
contents: write
14+
# Needed to open/update the Release PR
15+
pull-requests: write
16+
17+
jobs:
18+
release_pr:
19+
name: 🧩 Create/Update Release PR (and cut tags/releases)
20+
runs-on: ubuntu-24.04
21+
concurrency:
22+
group: changesets-main-${{ github.ref }}
23+
cancel-in-progress: true
24+
25+
steps:
26+
# Work on the main branch that was just pushed
27+
- name: ⏬ Checkout main
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: 🔄 Init Node & NPM cache
33+
uses: ./.github/actions/npm-cache
34+
35+
# Let changesets open/update the "Version Packages" PR, commit bumped versions and create GitHub Releases/tags
36+
- name: 🧩 Changesets Action
37+
id: changesets
38+
uses: changesets/action@v1
39+
with:
40+
commit: "chore(release): version packages"
41+
title: "chore(release): version packages"
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
# Ensure Husky hooks (e.g., branch name patterns) don't block CI commits
45+
HUSKY: "0"
46+
CI: "true"
47+
48+
- name: 🆙 Publish
49+
if: steps.changesets.outputs.hasChangesets == 'false'
50+
run: |
51+
VERSION=$(jq -r .version ./packages/foundations/package.json)
52+
TAG="v$VERSION"
53+
# Check if tag exists
54+
if git tag --list "$TAG" | grep -q "$TAG"; then
55+
echo "Tag $TAG already exists. Skipping publish creation."
56+
else
57+
gh tag create "$TAG" --notes "Release $TAG"
58+
59+
# Extract latest changes from CHANGELOG.md (between first and second h2)
60+
NOTES=$(awk '/^## /{i++} i==2{exit} i==1{print}' CHANGELOG.md | sed '1d')
61+
# Check if release exists
62+
if gh release view "$TAG" > /dev/null 2>&1; then
63+
echo "Release $TAG already exists. Skipping release creation."
64+
else
65+
gh release create "$TAG" --notes "$NOTES"
66+
fi
67+
fi
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
HUSKY: "0"
71+
CI: "true"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ showcases/patternhub/public/iframe-resizer/*
6666
/scripts/public/
6767
/scripts/gh-pages.tar.gz
6868
!/scripts/tests/fixtures/out
69+
/core-web.iml

output/angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@db-ux/ngx-core-components",
3-
"version": "0.0.0",
3+
"version": "3.1.14",
44
"description": "Angular components @db-ux/core-components",
55
"type": "module",
66
"repository": {

output/react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@db-ux/react-core-components",
3-
"version": "0.0.0",
3+
"version": "3.1.14",
44
"description": "React components for @db-ux/core-components",
55
"repository": {
66
"type": "git",

output/stencil/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@db-ux/wc-core-components",
3-
"version": "0.0.0",
3+
"version": "3.1.14",
44
"description": "Stencil components for @db-ux/core-components",
55
"repository": {
66
"type": "git",

output/vue/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@db-ux/v-core-components",
3-
"version": "0.0.0",
3+
"version": "3.1.14",
44
"type": "module",
55
"description": "Vue components for @db-ux/core-components",
66
"repository": {

0 commit comments

Comments
 (0)