Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions plugins/steam-deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ either locally or in Docker.

Credentials are read from the environment (never passed as CLI arguments, since argv
can leak through process listings and command logging).

For apps with non-consecutive depot IDs, set `--depotId` for the primary depot
and `--depotNId` alongside each extra `--depotNPath`. For example:

```sh
game-ci deploy steam steam-build \
--appId 1136510 --depotId 1136514 --depotPath windows \
--depot1Id 1136517 --depot1Path macos \
--depot2Id 1136518 --depot2Path linux --branch beta
```

If the primary depot is not part of the build, pass `--skipPrimaryDepot` and
configure at least one extra depot path. Extra depot IDs default to the primary
ID plus their slot number; empty slots do not renumber later depots.
13 changes: 10 additions & 3 deletions plugins/steam-deploy/src/parse-steamcmd-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ export function parseSteamCmdOutput(output: string, exitCode: number): SteamCmdP

const successConfirmed = /Successfully finished/.test(output);
const disconnected = /disconnected from steam/i.test(output);
const errorBuild = /ERROR!.*Build for depot.*failed/.test(output);
const errorChunks = /ERROR!.*Failed to get list of missing chunks/.test(output);
const errorBuildMatch = /ERROR!.*Build for depot\s+(\d+).*failed/i.exec(output);
const errorBuild = /ERROR!.*Build for depot.*failed/i.test(output);
const errorChunks = /ERROR!.*Failed to get list of missing chunks/i.test(output);
const loginFailed = /Logging in.*FAILED|Login Failure/i.exec(output);

if (successConfirmed) {
Expand All @@ -46,7 +47,13 @@ export function parseSteamCmdOutput(output: string, exitCode: number): SteamCmdP
const reasons: string[] = [];
if (disconnected) reasons.push("Steam connection dropped (request revoked)");
if (errorChunks) reasons.push("failed to get list of missing chunks (lost connection)");
if (errorBuild) reasons.push("depot build reported failure");
if (errorBuild) {
reasons.push(
errorBuildMatch
? `depot build reported failure for depot ${errorBuildMatch[1]}`
: "depot build reported failure",
);
}
if (loginFailed) reasons.push("login failed");
if (reasons.length === 0) {
// No known failure signature matched - surface the tail of the actual
Expand Down
72 changes: 61 additions & 11 deletions plugins/steam-deploy/src/steam-deploy-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface SteamDeployOptions {
* sequence starts - matches steam-deploy's own firstDepotIdOverride input.
*/
firstDepotIdOverride?: string;
/** Do not build the primary --depotId depot; useful when only extra depots are configured. */
skipPrimaryDepot?: boolean;
depotPath?: string;
depotInstallScriptPath?: string;
/** Each entry "localPath=depotPath" - replaces the primary depot's single depotPath mapping with explicit FileMapping blocks. */
Expand Down Expand Up @@ -89,6 +91,11 @@ export class SteamDeployCommand {
"Depot ID to start numbering extra depots (depot1Path..depot9Path) from. Defaults to depotId+1, depotId+2, ...",
type: "string",
})
.option("skipPrimaryDepot", {
describe: "Do not include the primary --depotId depot in this app build.",
type: "boolean",
default: false,
})
.option("depotPath", {
describe: "Path (relative to the build) mapped by the primary --depotId depot. Defaults to the whole build.",
type: "string",
Expand All @@ -112,6 +119,10 @@ export class SteamDeployCommand {

for (let index = 1; index <= MAX_EXTRA_DEPOTS; index++) {
yargs
.option(`depot${index}Id`, {
describe: `Explicit Steam depot ID for extra depot #${index}. Defaults to depotId+${index} (or firstDepotIdOverride+${index - 1}).`,
type: "string",
})
.option(`depot${index}Path`, {
describe: `Path (relative to the build) mapped by extra depot #${index}, beyond the primary --depotId depot.`,
type: "string",
Expand Down Expand Up @@ -152,6 +163,14 @@ export class SteamDeployCommand {

const appId = options.appId!;
const depotId = options.depotId!;
if (!/^\d+$/.test(depotId)) {
throw new Error(`Invalid Steam depot ID "${depotId}": depot IDs must contain digits only.`);
}
if (options.firstDepotIdOverride && !/^\d+$/.test(options.firstDepotIdOverride)) {
throw new Error(
`Invalid first depot ID override "${options.firstDepotIdOverride}": depot IDs must contain digits only.`,
);
}
const branch = options.branch ?? "default";
const description = options.description ?? `${branch} build ${new Date().toISOString()}`;
const mode = (options.mode ?? "auto") as "auto" | "local" | "docker";
Expand All @@ -161,31 +180,57 @@ export class SteamDeployCommand {
const includeDebugSymbols = options.debugBranch ?? false;
const fileMappings = this.parseFileMappings(options.fileMapping);
const fileProperties = this.parseFileProperties(options.fileProperty);
const skipPrimaryDepot = options.skipPrimaryDepot ?? false;

if (
skipPrimaryDepot &&
(options.depotPath || options.depotInstallScriptPath || fileMappings || fileProperties || extraExclusions)
) {
throw new Error(
"--skipPrimaryDepot cannot be combined with --depotPath, --depotInstallScriptPath, --fileMapping, --fileProperty, or --extraExclusions.",
);
}

const absoluteBuildPath = path.resolve(buildPath);
const contentRoot = resolveUseDocker(mode, options.steamCmdPath) ? "/build" : absoluteBuildPath.replace(/\\/g, "/");

const extraDepots = this.collectExtraDepots(options, depotId);
const primaryLocalPath = options.depotPath ? `./${options.depotPath.replace(/^\.?\/*/, "")}/*` : undefined;
const allDepots = [
{ depotId, localPath: primaryLocalPath, installScript: options.depotInstallScriptPath },
...extraDepots,
...(skipPrimaryDepot
? []
: [{ depotId, localPath: primaryLocalPath, installScript: options.depotInstallScriptPath, isPrimary: true }]),
...extraDepots.map((depot) => ({ ...depot, isPrimary: false })),
];

if (allDepots.length === 0) {
throw new Error("At least one depot path must be configured when --skipPrimaryDepot is set.");
}

const configuredDepotIds = new Set<string>();
for (const depot of allDepots) {
if (!/^\d+$/.test(depot.depotId)) {
throw new Error(`Invalid Steam depot ID "${depot.depotId}": depot IDs must contain digits only.`);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}
if (configuredDepotIds.has(depot.depotId)) {
throw new Error(`Duplicate Steam depot ID "${depot.depotId}" in this app build.`);
}
configuredDepotIds.add(depot.depotId);
}

const depotEntries = allDepots.map((depot) => ({
depotId: depot.depotId,
vdfFileName: `depot_build_${depot.depotId}.vdf`,
}));

for (const depot of allDepots) {
const isPrimaryDepot = depot.depotId === depotId;
const depotVdf = generateDepotVdf({
depotId: depot.depotId,
localPath: depot.localPath,
fileMappings: isPrimaryDepot ? fileMappings : undefined,
fileProperties: isPrimaryDepot ? fileProperties : undefined,
fileMappings: depot.isPrimary ? fileMappings : undefined,
fileProperties: depot.isPrimary ? fileProperties : undefined,
installScript: depot.installScript,
extraExclusions: isPrimaryDepot ? extraExclusions : undefined,
extraExclusions: depot.isPrimary ? extraExclusions : undefined,
includeDebugSymbols,
});
fs.writeFileSync(path.join(absoluteBuildPath, `depot_build_${depot.depotId}.vdf`), depotVdf, "utf8");
Expand Down Expand Up @@ -264,9 +309,8 @@ export class SteamDeployCommand {

/**
* Reads depot1Path..depot9Path (+ matching depot{n}InstallScriptPath) and
* assigns each a sequential depot ID after the primary --depotId, starting
* from --firstDepotIdOverride if given - matches steam-deploy's own
* up-to-9-extra-depots convention.
* assigns each its explicit depotNId when supplied, otherwise deriving its
* ID from its slot (so unset slots do not renumber later depots).
*/
private collectExtraDepots(
options: SteamDeployOptions,
Expand All @@ -279,10 +323,16 @@ export class SteamDeployCommand {
const extras: Array<{ depotId: string; localPath: string; installScript?: string }> = [];
for (let index = 1; index <= MAX_EXTRA_DEPOTS; index++) {
const localPath = options[`depot${index}Path`] as string | undefined;
if (!localPath) continue;
const explicitDepotId = options[`depot${index}Id`] as string | undefined;
if (!localPath) {
if (explicitDepotId) {
throw new Error(`--depot${index}Id requires --depot${index}Path.`);
}
continue;
}

extras.push({
depotId: String(firstExtraId + extras.length),
depotId: explicitDepotId ?? String(firstExtraId + index - 1),
localPath: `./${localPath.replace(/^\.?\/*/, "")}/*`,
installScript: options[`depot${index}InstallScriptPath`] as string | undefined,
});
Expand Down
Loading