import { curseforgeClient } from "@/services/clients"; import { uploadFile } from "@/lib/curseforge"; import { resolveVersionName, buildJarPath } from "@/lib/utils/format"; import { readJarBlob } from "@/lib/utils/file"; import type { UploadMetadata } from "@/types"; import type { PlatformContext } from "./types"; export async function publishCurseForgeVersion( ctx: PlatformContext, mcVersion: string, ): Promise { const { input, config } = ctx; const displayName = resolveVersionName( config.curseforge.version_name, { filename_format: config.filename_format }, { version: input.version, mc_version: mcVersion }, ); const primaryPath = buildJarPath( config.project_dir, config.filename_format, input.version, mcVersion, ); const primaryBlob = readJarBlob(primaryPath); const metadata: UploadMetadata = { changelog: input.changelog, changelogType: "markdown", displayName, releaseType: input.versionType, relations: config.curseforge.relations, }; await uploadFile( curseforgeClient, config.curseforge.project_id, metadata, primaryBlob, ); }