Skip to content

Commit dd8f9f2

Browse files
authored
ref(core): Use Sentry-CLI to finalize release (#90)
Replace our own release finalization logic with Sentry CLI's implementation RIP Note: Since integration tests were failing because the CLI expects parameters that we didn't specify, I opted to set the `dryRun` option in our test setups. We're only testing release injection in these tests, so apart from the CLI's version detection (which still works as expected in dry run mode) we don't need any of its functionality.
1 parent 3e3a9b4 commit dd8f9f2

File tree

7 files changed

+8
-55
lines changed

7 files changed

+8
-55
lines changed

packages/bundler-plugin-core/src/sentry/api.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -80,36 +80,3 @@ export async function deleteAllReleaseArtifacts({
8080
throw e;
8181
}
8282
}
83-
84-
export async function updateRelease({
85-
release,
86-
org,
87-
authToken,
88-
sentryUrl,
89-
project,
90-
sentryHub,
91-
customHeader,
92-
}: {
93-
release: string;
94-
org: string;
95-
authToken: string;
96-
sentryUrl: string;
97-
project: string;
98-
sentryHub: Hub;
99-
customHeader: Record<string, string>;
100-
}): Promise<void> {
101-
const requestUrl = `${sentryUrl}${API_PATH}/projects/${org}/${project}/releases/${release}/`;
102-
103-
const releasePayload = {
104-
dateReleased: new Date().toISOString(),
105-
};
106-
107-
try {
108-
await sentryApiAxiosInstance({ authToken, customHeader }).put(requestUrl, releasePayload, {
109-
headers: { Authorization: `Bearer ${authToken}` },
110-
});
111-
} catch (e) {
112-
captureMinimalError(e, sentryHub);
113-
throw e;
114-
}
115-
}

packages/bundler-plugin-core/src/sentry/releasePipeline.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import { InternalOptions } from "../options-mapping";
1010
import { BuildContext } from "../types";
11-
import { createRelease, deleteAllReleaseArtifacts, updateRelease } from "./api";
11+
import { createRelease, deleteAllReleaseArtifacts } from "./api";
1212
import { addSpanToTransaction } from "./telemetry";
1313

1414
export async function createNewRelease(
@@ -75,34 +75,15 @@ export async function uploadSourceMaps(options: InternalOptions, ctx: BuildConte
7575
span?.finish();
7676
}
7777

78-
export async function finalizeRelease(
79-
options: InternalOptions,
80-
ctx: BuildContext
81-
): Promise<string> {
78+
export async function finalizeRelease(options: InternalOptions, ctx: BuildContext): Promise<void> {
8279
const span = addSpanToTransaction(ctx, "function.plugin.finalize_release");
8380

8481
if (options.finalize) {
85-
const { authToken, org, url, project } = options;
86-
if (!authToken || !org || !url || !project) {
87-
ctx.logger.warn("Missing required option. Will not clean existing artifacts.");
88-
return Promise.resolve("nothing to do here");
89-
}
90-
91-
await updateRelease({
92-
authToken,
93-
org,
94-
release: options.release,
95-
sentryUrl: url,
96-
project,
97-
sentryHub: ctx.hub,
98-
customHeader: options.customHeader,
99-
});
100-
82+
await ctx.cli.releases.finalize(options.release);
10183
ctx.logger.info("Successfully finalized release.");
10284
}
10385

10486
span?.finish();
105-
return Promise.resolve("nothing to do here");
10687
}
10788

10889
export async function cleanArtifacts(options: InternalOptions, ctx: BuildContext): Promise<string> {

packages/integration-tests/fixtures/array-entries-option/setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ createCjsBundles(
1414
release: "I AM A RELEASE!",
1515
include: outputDir,
1616
entries: [/entrypoint1\.js/, entryPoint3Path],
17+
dryRun: true,
1718
} as Options
1819
);

packages/integration-tests/fixtures/basic-release-injection/setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ const outputDir = path.resolve(__dirname, "./out");
88
createCjsBundles({ index: entryPointPath }, outputDir, {
99
release: "I AM A RELEASE!",
1010
include: outputDir,
11+
dryRun: true,
1112
} as Options);

packages/integration-tests/fixtures/function-entries-option/setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ createCjsBundles(
1515
include: outputDir,
1616
entries: (entrypointPath) =>
1717
entrypointPath === entryPoint1Path || entrypointPath === entryPoint3Path,
18+
dryRun: true,
1819
} as Options
1920
);

packages/integration-tests/fixtures/regex-entries-option/setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ const outputDir = path.resolve(__dirname, "./out");
99
createCjsBundles({ entrypoint1: entryPoint1Path, entrypoint2: entryPoint2Path }, outputDir, {
1010
release: "I AM A RELEASE!",
1111
include: outputDir,
12+
dryRun: true,
1213
entries: /entrypoint1\.js/,
1314
} as Options);

packages/integration-tests/fixtures/string-entries-option/setup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ createCjsBundles({ entrypoint1: entryPoint1Path, entrypoint2: entryPoint2Path },
1010
release: "I AM A RELEASE!",
1111
include: outputDir,
1212
entries: entryPoint1Path,
13+
dryRun: true,
1314
} as Options);

0 commit comments

Comments
 (0)