Skip to content

Commit cc84068

Browse files
authored
Merge pull request #1864 from finos/improve-release-workflow-and-instructions
Improving release workflow to add version sync guardrail and updating instructions
2 parents 3f3b8cb + 8c77956 commit cc84068

5 files changed

Lines changed: 49 additions & 29 deletions

File tree

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
- name: Build
3939
run: npm run build
4040

41+
- name: Verify version consistency across workspaces
42+
run: npm run version-check
43+
4144
# Compute prerelease flag & desired dist-tag from top-level package.json version
4245
- name: Determine prerelease tag
4346
id: version

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1212
* Added details of and procedures for resolving fully-qualified appIds and unqualified appIds in the API and Bridging Parts of the Standard. ([#1523](https://github.com/finos/FDC3/pull/1523))
1313
* Added clarification regarding expected behavior upon repeated calls to `addContextListener` on same or overlapping types (allowed) and `addIntentListener` on same intent (rejected; new error type added). ([#1394](https://github.com/finos/FDC3/pull/1394))
1414
* Added `clearContext` function and associated `contextClearedEvent` to the `Channel` API, to be able to clear specific or all context types from the channel. ([#1379](https://github.com/finos/FDC3/pull/1379))
15+
* Added `version-check` script and integrated it into the `syncpack` script and Publish To NPM workflow to prevent version mismatches causing incorrect npm dist-tags. ([#1864](https://github.com/finos/FDC3/pull/1864))
1516

1617
### Changed
1718

19+
* Updated "Releasing FDC3 to NPM" instructions in README to reflect the current GitHub Actions release workflow. ([#1864](https://github.com/finos/FDC3/pull/1864))
20+
1821
### Deprecated
1922

2023
### Fixed

README.md

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -107,52 +107,44 @@ For installation and usage instructions, see: <https://fdc3.finos.org/docs/suppo
107107

108108
### Releasing FDC3 to NPM (for maintainers)
109109

110-
This is a 4-step process:
110+
Publishing to npm is handled automatically by the [Publish To NPM](.github/workflows/release.yml) GitHub Actions workflow, which is triggered when a GitHub Release is published. The workflow will lint, test and build the project, then publish all public workspace packages to both npmjs.org and GitHub Packages.
111+
112+
The npm dist-tag is determined by the version in the root `package.json`: versions containing a hyphen (e.g. `2.3.0-beta.1`) are published with the `prerelease` tag, while all other versions are published with the `latest` tag.
111113

112114
1. **Create a release branch**
113115

114-
Do this locally. Ensure the branch is named `release/v2.0` (or whatever the next version is).
115-
116116
```bash
117-
git checkout -b release/v2.0
117+
git checkout -b release/v2.3
118118
```
119-
120-
2. **Update the version numbers in the package.json files**
121119

122-
It's important that all of the versions of the submodules stay on the same version, and that the references between them are consistent to that version. To change the version number (say before or after a release) run the following:
120+
2. **Update version numbers**
121+
122+
All workspace versions and the root `package.json` version must match. Update them as follows:
123123

124124
```bash
125-
// first, update version number in package.json
126-
npm login
127-
npm version <new version from package.json> --workspaces // changes the version number in all submodule package.json files
128-
npm run syncpack // sycnhronizes version numbers
129-
npm up // fixes node_module references
130-
npm run build // builds all the modules against the new version
125+
npm version <new-version> --include-workspace-root --workspaces
126+
npm run syncpack # synchronizes @finos/* dependency versions and verifies consistency
127+
npm up # fixes node_module references
128+
npm run build # builds all modules against the new version
131129
```
132130

133-
3. **Push the branch to publish the packages to npm**
131+
The `syncpack` script will automatically run `version-check` to verify that the root version matches all public workspace versions. You can also run `npm run version-check` independently at any time.
132+
133+
3. **Push the branch and create a PR**
134134

135135
```bash
136136
git add .
137-
git commit -m "Updated to version vx.x"
138-
git push origin release/v2.0
137+
git commit -m "Updated to version v2.3.0"
138+
git push origin release/v2.3
139139
```
140-
141-
This should trigger a GitHub action that will publish the packages to npm.
142-
143-
4. **Create a PR for merging the release branch.**
144140

145-
Once the packages are published, create a PR to merge the release branch into the main branch. You will need other FDC3 maintainers to review and approve the PR.
141+
Create a PR to merge the release branch into main. You will need other FDC3 maintainers to review and approve the PR.
146142

147-
5. **Reset the `latest` NPM Version Tag If Releasing A Prerelease**
143+
4. **Create a GitHub Release to publish to npm**
148144

149-
If you're releasing beta/alpha code, be sure to replace the latest version in NPM like so:
150-
151-
```
152-
npm dist-tag add @finos/fdc3@2.1.1 latest
153-
```
145+
Once the PR is merged, [create a new GitHub Release](https://github.com/finos/FDC3/releases/new) targeting the main branch. Publishing the release will trigger the workflow, which will publish all packages to npm and GitHub Packages.
154146

155-
You will need support from help@finos.org for this step.
147+
The workflow also runs a version consistency check before publishing — if the root version doesn't match the workspace versions, the workflow will fail before any packages are published.
156148

157149
### Releasing the FDC3 Website (for maintainers)
158150

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"merge": "istanbul-merge --out coverage/complete.json packages/fdc3-standard/coverage/coverage-final.json packages/fdc3-get-agent/coverage/coverage-final.json packages/fdc3-agent-proxy/coverage/coverage-final.json toolbox/fdc3-for-web/fdc3-web-impl/coverage/coverage-final.json",
4040
"report": "nyc report --reporter json-summary --report-dir nyc-coverage-report --exclude-after-remap false --temp-dir coverage",
4141
"lint": "npm run lint --workspaces --if-present",
42-
"syncpack": "npm exec syncpack -- fix --dependencies \"@finos/*\"",
42+
"syncpack": "npm exec syncpack -- fix --dependencies \"@finos/*\" && npm run version-check",
43+
"version-check": "node scripts/version-check.js",
4344
"dev": "concurrently \"cd toolbox/fdc3-conformance && npm run dev\" \"cd toolbox/fdc3-workbench && npm run dev\" \"cd toolbox/fdc3-for-web/reference-ui && npm run dev\" \"cd toolbox/fdc3-for-web/demo && npm run dev\"",
4445
"prepare": "husky"
4546
},

scripts/version-check.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const fs = require('fs');
2+
3+
const root = JSON.parse(fs.readFileSync('package.json', 'utf8'));
4+
const workspaces = root.workspaces || [];
5+
6+
const mismatched = workspaces
7+
.map(dir => ({
8+
dir,
9+
...JSON.parse(fs.readFileSync(`${dir}/package.json`, 'utf8')),
10+
}))
11+
.filter(pkg => !pkg.private && pkg.version !== root.version);
12+
13+
if (mismatched.length) {
14+
console.error(
15+
`ERROR: Root version (${root.version}) does not match:\n` +
16+
mismatched.map(p => ` ${p.dir}: ${p.version}`).join('\n')
17+
);
18+
process.exit(1);
19+
}
20+
21+
console.log(`All public workspace versions match root: ${root.version}`);

0 commit comments

Comments
 (0)