Skip to content

Commit 741ec6f

Browse files
committed
ref(core): Use Sentry-CLI to finalize release
1 parent 2a34662 commit 741ec6f

File tree

2 files changed

+3
-55
lines changed

2 files changed

+3
-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
@@ -81,36 +81,3 @@ export async function deleteAllReleaseArtifacts({
8181
throw e;
8282
}
8383
}
84-
85-
export async function updateRelease({
86-
release,
87-
org,
88-
authToken,
89-
sentryUrl,
90-
project,
91-
sentryHub,
92-
customHeader,
93-
}: {
94-
release: string;
95-
org: string;
96-
authToken: string;
97-
sentryUrl: string;
98-
project: string;
99-
sentryHub: Hub;
100-
customHeader: Record<string, string>;
101-
}): Promise<void> {
102-
const requestUrl = `${sentryUrl}${API_PATH}/projects/${org}/${project}/releases/${release}/`;
103-
104-
const releasePayload = {
105-
dateReleased: new Date().toISOString(),
106-
};
107-
108-
try {
109-
await sentryApiAxiosInstance({ authToken, customHeader }).put(requestUrl, releasePayload, {
110-
headers: { Authorization: `Bearer ${authToken}` },
111-
});
112-
} catch (e) {
113-
captureMinimalError(e, sentryHub);
114-
throw e;
115-
}
116-
}

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> {

0 commit comments

Comments
 (0)