Skip to content

Commit e68a725

Browse files
authored
chore: adopt Changesets release flow (#550)
## Summary - add Changesets config and scripts for workspace releases - switch publish automation to `changesets/action` with npm Trusted Publisher - document the release flow and add an empty changeset for the migration ## Verification - `bash -ic 'yarn changeset status'`
1 parent ea1a60b commit e68a725

8 files changed

Lines changed: 509 additions & 51 deletions

File tree

.changeset/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Changesets
2+
3+
Run `yarn changeset` after changing a publishable package.
4+
5+
Choose the packages that changed, select the appropriate semver bump, and write a short summary for users.
6+
7+
When the PR merges to `main`, the release workflow will either:
8+
9+
- open or update a `Version Packages` PR if there are pending changesets
10+
- publish to npm once that version PR is merged

.changeset/config.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://unpkg.com/@changesets/config@3.1.1/schema.json",
3+
"changelog": "@changesets/cli/changelog",
4+
"commit": false,
5+
"fixed": [],
6+
"linked": [],
7+
"access": "public",
8+
"baseBranch": "main",
9+
"updateInternalDependencies": "patch",
10+
"ignore": [
11+
"@reflag/eslint-config",
12+
"@reflag/tsconfig",
13+
"customer-admin-panel",
14+
"nextjs-bootstrap-demo",
15+
"nextjs-flag-demo",
16+
"nextjs-openfeature-example",
17+
"reflag-react-native-sdk-bare-rn",
18+
"reflag-react-sdk-expo"
19+
]
20+
}

.changeset/fair-badgers-move.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
4+
Document the repository's migration to Changesets-managed releases and npm Trusted Publisher publishing.

.github/workflows/publish.yml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
name: Publish updated packages
1+
name: Release packages
22

33
on:
44
push:
55
branches:
66
- main
77

8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
9+
810
jobs:
911
release:
1012
runs-on: ubuntu-latest
1113
permissions:
12-
contents: read
14+
contents: write
1315
id-token: write
16+
pull-requests: write
1417
steps:
1518
- uses: actions/checkout@v4
16-
# Setup .npmrc file to publish to npm
1719
- name: Enable corepack
1820
run: corepack enable
1921
- uses: actions/setup-node@v6
@@ -25,34 +27,33 @@ jobs:
2527
scope: "@reflag"
2628
- name: Install dependencies
2729
run: yarn install --immutable
28-
- name: Build packages
29-
run: yarn build
30-
- name: Publish
31-
run: |
32-
yarn lerna list --since --parseable --no-private | while read -r pkg; do
33-
name=$(node -p "require('$pkg/package.json').name")
34-
version=$(node -p "require('$pkg/package.json').version")
35-
published=$(npm view "$name" version --json 2>/dev/null || echo "")
36-
if [ "$published" = "\"$version\"" ]; then
37-
echo "SKIP $name@$version"
38-
else
39-
echo "PUBLISH $name@$version (registry has $published)"
40-
(cd "$pkg" && npm publish --access public --provenance)
41-
fi
42-
done
30+
- name: Create release PR or publish packages
31+
id: changesets
32+
uses: changesets/action@v1
33+
with:
34+
version: yarn version-packages
35+
publish: yarn build && yarn release
36+
title: Version Packages
37+
commit: Version Packages
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4340
- name: Build docs
41+
if: steps.changesets.outputs.published == 'true'
4442
run: yarn docs
4543
- name: Checkout docs with SSH
44+
if: steps.changesets.outputs.published == 'true'
4645
uses: actions/checkout@v3
4746
with:
4847
repository: reflagcom/docs
4948
ssh-key: ${{ secrets.DOCS_DEPLOY_KEY }}
5049
path: reflag-docs
5150
- name: Copy generated docs to docs repo
51+
if: steps.changesets.outputs.published == 'true'
5252
run: |
5353
rm -rf reflag-docs/sdk
5454
cp -R dist/docs reflag-docs/sdk
5555
- name: Commit and push changes
56+
if: steps.changesets.outputs.published == 'true'
5657
run: |
5758
cd reflag-docs
5859
git config user.name "github-actions[bot]"

README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,22 @@ Use the Reflag with OpenFeature on the server in Node.js through the Reflag Open
6262
### Versioning
6363

6464
1. Create a new branch locally
65-
2. Run `yarn run version`
66-
3. Push and PR
65+
2. Run `yarn changeset`
66+
3. Select the packages that changed and the correct bump type
67+
4. Commit the generated file in `.changeset/`
68+
5. Push and open a PR
6769

6870
### Publishing
6971

70-
The [Github Action](.github/workflows/publish.yml) will automatically publish any versioned packages when merging to `main`
72+
Repository setup:
73+
74+
1. Configure npm Trusted Publisher entries for the packages in this repo against the `reflagcom/javascript` GitHub repository and the `publish.yml` workflow
75+
2. Keep the workflow on GitHub-hosted runners with `id-token: write`, plus `contents: write` and `pull-requests: write` for the release PR flow
76+
77+
When a PR with one or more changesets is merged to `main`, the release workflow will open or update a `Version Packages` PR.
78+
79+
Merging that PR will:
80+
81+
1. Apply the version bumps
82+
2. Publish the updated packages to npm
83+
3. Rebuild and push the generated SDK docs

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"packages/openfeature-browser-provider/example"
1212
],
1313
"scripts": {
14+
"changeset": "changeset",
1415
"dev": "lerna run dev --parallel",
1516
"build": "lerna run build --stream",
1617
"test:ci": "lerna run test:ci --stream",
@@ -20,11 +21,13 @@
2021
"prettier:fix": "lerna run prettier -- --write",
2122
"lint": "lerna run lint --stream",
2223
"lint:ci": "lerna run lint:ci --stream",
23-
"version": "lerna version --exact --no-push",
24+
"version-packages": "changeset version",
25+
"release": "changeset publish",
2426
"docs": "./docs.sh"
2527
},
2628
"packageManager": "yarn@4.10.3",
2729
"devDependencies": {
30+
"@changesets/cli": "^2.29.6",
2831
"lerna": "^8.1.3",
2932
"prettier": "^3.5.2",
3033
"react": "19.1.0",

packages/openfeature-node-provider/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"vitest": "~1.6.0"
5151
},
5252
"dependencies": {
53-
"@reflag/node-sdk": "1.1.0"
53+
"@reflag/node-sdk": "1.2.0"
5454
},
5555
"peerDependencies": {
5656
"@openfeature/server-sdk": ">=1.16.1"

0 commit comments

Comments
 (0)