Skip to content

Commit fa212a4

Browse files
author
Loïc Mangeonjean
committed
fix: make publish process more resilient
1 parent 132bcb4 commit fa212a4

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

release.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This script was inspired by https://dev.to/antongolub/you-don-t-need-semantic-release-sometimes-3k6k
33
*/
44
import semanticRelease, { type Options as SemanticReleaseOptions } from 'semantic-release'
5-
import { $ } from 'zx'
5+
import { $, ProcessOutput } from 'zx'
66
import yargs, { type Options } from 'yargs'
77
import semanticReleaseConfig from '@codingame/semantic-release-config-github'
88
import type { PackageJson } from 'type-fest'
@@ -52,7 +52,19 @@ async function publishNpm(version: string, tag: string) {
5252
await fs.writeFile(packageJsonFile, JSON.stringify(packageJson, null, 2))
5353

5454
$.cwd = libDir
55-
await $`npm publish --tag "${tag}" --access public`
55+
56+
try {
57+
await $`npm publish --tag "${tag}" --access public`
58+
} catch (err) {
59+
if (
60+
err instanceof ProcessOutput &&
61+
err.stderr.includes('You cannot publish over the previously published versions')
62+
) {
63+
// ignore, it's an internal retry from npm that fails
64+
} else {
65+
throw err
66+
}
67+
}
5668
}
5769
}
5870
}

0 commit comments

Comments
 (0)