Skip to content

Commit 0944f98

Browse files
committed
ci(release): add cloudsmith publish workflow for fetch-with-retries
Adds the release-only plumbing needed to publish the `fetch-with-retries` package from CircleCI to FT’s private Cloudsmith npm registry. I’ve already tested this with a pre-release (v0.1.0) and it worked fine, and have imported it successfully into a local clone of one of our other repos, for testing. The publishing workflow is tag-gated, package-scoped, and publishes via `npm publish --workspace packages/fetch-with-retries`. This repo uses Cloudsmith rather than public npm because the package is intended for internal use, and should not be published publicly.
1 parent 11c47f8 commit 0944f98

3 files changed

Lines changed: 84 additions & 12 deletions

File tree

.circleci/config.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
version: 2.1
22

33
orbs:
4+
cloudsmith-npm: ft-circleci-orbs/cloudsmith-npm@1.0
45
node: circleci/node@4.6.0
56

67
references:
@@ -19,6 +20,18 @@ references:
1920
attach_workspace:
2021
at: *workspace_root
2122

23+
filters_release_build: &filters_release_build
24+
tags:
25+
only:
26+
# Although the CI setup here is mostly from dotcom-reliability-kit,
27+
# we’re simplifying this tagging filter for now while we only have one
28+
# package. The dotcom kit uses \w instead of hard-coding the package
29+
# name, then runs a script (circleci-publish.sh) to figure out which
30+
# package to publish. We could adopt that later if we like!
31+
- /^fetch-with-retries-v\d+\.\d+\.\d+$/
32+
branches:
33+
ignore: /.*/
34+
2235
jobs:
2336
install:
2437
<<: *container_config_node
@@ -50,6 +63,16 @@ jobs:
5063
name: Run repo linting
5164
command: npm run lint
5265

66+
publish:
67+
<<: *container_config_node
68+
steps:
69+
- *attach_workspace
70+
- cloudsmith-npm/configure_npm:
71+
repository: financial-times-internal-releases
72+
- run:
73+
name: Publish fetch-with-retries to Cloudsmith
74+
command: npm publish --workspace packages/fetch-with-retries
75+
5376
workflows:
5477
test-and-lint:
5578
jobs:
@@ -69,3 +92,33 @@ workflows:
6992
name: lint-v24.15
7093
requires:
7194
- install-v24.15
95+
publish:
96+
jobs:
97+
- install:
98+
filters:
99+
<<: *filters_release_build
100+
name: install-publish-v<< matrix.node-version >>
101+
matrix:
102+
parameters:
103+
node-version: ["26.2", "24.15", "22.22"]
104+
- test:
105+
filters:
106+
<<: *filters_release_build
107+
name: test-publish-v<< matrix.node-version >>
108+
requires:
109+
- install-publish-v<< matrix.node-version >>
110+
matrix:
111+
parameters:
112+
node-version: ["26.2", "24.15", "22.22"]
113+
- lint:
114+
filters:
115+
<<: *filters_release_build
116+
name: lint-publish-v24.15
117+
requires:
118+
- install-publish-v24.15
119+
- publish:
120+
filters:
121+
<<: *filters_release_build
122+
requires:
123+
- test-publish-v24.15
124+
- lint-publish-v24.15

README.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,24 @@ npm run test -w packages/fetch-with-retries
3737

3838
## Publishing
3939

40-
`packages/fetch-with-retries` is configured to publish to Cloudsmith from CircleCI.
40+
Packages (e.g. `packages/fetch-with-retries`) are configured to publish from CircleCI to Cloudsmith after creating a GitHub release.
4141

42-
CircleCI project settings must include:
42+
Publishing flow:
4343

44-
```bash
45-
CLOUDSMITH_SERVICE_ACCOUNT=<your-service-account-id>
46-
```
44+
1. Update the package version, e.g. `packages/fetch-with-retries/package.json`.
45+
2. Update the CHANGELOG for that version, e.g. `packages/fetch-with-retries/CHANGELOG.md`.
46+
3. Open a PR to get those changes merged into the main branch.
47+
4. When merged, create a GitHub release targeting the release commit, and use a matching tag in this format:
4748

48-
The publish workflow is triggered by tags in this format:
49-
50-
```bash
49+
```
5150
fetch-with-retries-v1.0.0
5251
```
5352

54-
Publishing is package-scoped and runs:
53+
5. CircleCI will run the publish workflow for that tag.
54+
6. If tests and lint pass, CircleCI publishes the package to the `financial-times-internal-releases` Cloudsmith repository.
5555

56-
```bash
57-
npm publish --workspace packages/fetch-with-retries
58-
```
56+
> [!IMPORTANT]
57+
> The tag version must match the package version in your `package.json`. The CircleCI workflow is triggered by the git tag itself, not by a GitHub release title.
5958
6059
## Contact
6160

packages/fetch-with-retries/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Retry native Node `fetch` calls with a shared default policy, configurable backo
1212
- [`options.retryPatchRequests`](#optionsretrypatchrequests)
1313
- [Structured log events](#structured-log-events)
1414
- [TypeScript](#typescript)
15+
- [Publishing](#publishing)
1516
- [License](#license)
1617

1718
## Usage
@@ -184,6 +185,25 @@ Retries exhausted event:
184185
}
185186
```
186187
188+
### Publishing
189+
190+
Maintainers publish this package through CircleCI rather than from a local machine.
191+
192+
1. Update the version in `package.json`.
193+
2. Update `CHANGELOG.md` for that version.
194+
3. Open a PR to get those changes merged into the main branch.
195+
4. When merged, create a GitHub release targeting the release commit, and use a matching tag:
196+
197+
```
198+
fetch-with-retries-v1.0.0
199+
```
200+
201+
5. CircleCI will run the tagged publish workflow.
202+
6. If tests and lint pass, CircleCI publishes `@financial-times/martech-fetch-with-retries` to the `financial-times-internal-releases` Cloudsmith repository.
203+
204+
> [!IMPORTANT]
205+
> The tag version must match the package version in `package.json`. The CircleCI workflow is triggered by the git tag itself, not by a GitHub release title.
206+
187207
## License
188208
189209
MIT

0 commit comments

Comments
 (0)