From ecf8bda52a7ae756ad41e0ced380d0f24449ef40 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Tue, 1 Jul 2025 15:10:19 +0200 Subject: [PATCH] test: Avoid publishing old tarballs for E2E tests I noticed that locally I sometimes have old tarballs lying around, which are all published for E2E tests. This is unnecessary, and can also make it a bit unreliable which version is used for tests (as we generally have the dependencies as `*` which could be anything). This changes it so we only publish the current version. --- dev-packages/e2e-tests/publish-packages.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/dev-packages/e2e-tests/publish-packages.ts b/dev-packages/e2e-tests/publish-packages.ts index d342470bd06d..5ade5b1d735c 100644 --- a/dev-packages/e2e-tests/publish-packages.ts +++ b/dev-packages/e2e-tests/publish-packages.ts @@ -1,15 +1,26 @@ import * as childProcess from 'child_process'; +import { readFileSync } from 'fs'; import * as glob from 'glob'; import * as path from 'path'; const repositoryRoot = path.resolve(__dirname, '../..'); +const version = (JSON.parse(readFileSync(path.join(__dirname, './package.json'), 'utf8')) as { version: string }) + .version; + // Get absolute paths of all the packages we want to publish to the fake registry -const packageTarballPaths = glob.sync('packages/*/sentry-*.tgz', { +// Only include the current versions, to avoid getting old tarballs published as well +const packageTarballPaths = glob.sync(`packages/*/sentry-*-${version}.tgz`, { cwd: repositoryRoot, absolute: true, }); +if (packageTarballPaths.length === 0) { + // eslint-disable-next-line no-console + console.log(`No packages to publish for version ${version}, did you run "yarn build:tarballs"?`); + process.exit(1); +} + // Publish built packages to the fake registry packageTarballPaths.forEach(tarballPath => { // eslint-disable-next-line no-console