Skip to content

refactor: publish releases with limited concurrency #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ten-eagles-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"changesets-gitlab": minor
---

refactor: publish releases with limited concurrency with [`p-limit`](https://github.com/sindresorhus/p-limit)
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"eslint": "^9.23.0",
"lint-staged": "^15.5.0",
"npm-run-all2": "^7.0.2",
"p-limit": "^6.2.0",
"prettier": "^3.5.3",
"simple-git-hooks": "^2.12.1",
"size-limit": "^11.2.0",
Expand Down
13 changes: 9 additions & 4 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { exec } from '@actions/exec'
import type { Gitlab } from '@gitbeaker/core'
import type { Package } from '@manypkg/get-packages'
import { getPackages } from '@manypkg/get-packages'
import pLimit from 'p-limit'
import resolveFrom from 'resolve-from'
import semver from 'semver'

Expand All @@ -23,6 +24,8 @@ import {
sortTheThings,
} from './utils.js'

const limit = pLimit(2 * 3)

export const createRelease = async (
api: Gitlab,
{ pkg, tagName }: { pkg: Package; tagName: string },
Expand Down Expand Up @@ -157,10 +160,12 @@ export async function runPublish({
if (createGitlabReleases) {
await Promise.all(
releasedPackages.map(pkg =>
createRelease(api, {
pkg,
tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`,
}),
limit(() =>
createRelease(api, {
pkg,
tagName: `${pkg.packageJson.name}@${pkg.packageJson.version}`,
}),
),
),
)
}
Expand Down
12 changes: 11 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5520,6 +5520,7 @@ __metadata:
mdast-util-to-string: "npm:^4.0.0"
micromatch: "npm:^4.0.8"
npm-run-all2: "npm:^7.0.2"
p-limit: "npm:^6.2.0"
prettier: "npm:^3.5.3"
remark-parse: "npm:^11.0.0"
remark-stringify: "npm:^11.0.0"
Expand Down Expand Up @@ -11134,6 +11135,15 @@ __metadata:
languageName: node
linkType: hard

"p-limit@npm:^6.2.0":
version: 6.2.0
resolution: "p-limit@npm:6.2.0"
dependencies:
yocto-queue: "npm:^1.1.1"
checksum: 10c0/448bf55a1776ca1444594d53b3c731e68cdca00d44a6c8df06a2f6e506d5bbd540ebb57b05280f8c8bff992a630ed782a69612473f769a7473495d19e2270166
languageName: node
linkType: hard

"p-locate@npm:^4.1.0":
version: 4.1.0
resolution: "p-locate@npm:4.1.0"
Expand Down Expand Up @@ -15095,7 +15105,7 @@ __metadata:
languageName: node
linkType: hard

"yocto-queue@npm:^1.0.0":
"yocto-queue@npm:^1.0.0, yocto-queue@npm:^1.1.1":
version: 1.2.1
resolution: "yocto-queue@npm:1.2.1"
checksum: 10c0/5762caa3d0b421f4bdb7a1926b2ae2189fc6e4a14469258f183600028eb16db3e9e0306f46e8ebf5a52ff4b81a881f22637afefbef5399d6ad440824e9b27f9f
Expand Down
Loading