Skip to content

Commit 8aee3d9

Browse files
setup-steamcmd@v1.0.4 (#5)
- fix caching on self hosted linux runners
1 parent d7971a7 commit 8aee3d9

File tree

5 files changed

+43
-22
lines changed

5 files changed

+43
-22
lines changed

dist/index.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28858,15 +28858,15 @@ const toolExtension = IS_WINDOWS ? '.exe' : '.sh';
2885828858
const toolPath = `${steamcmd}${toolExtension}`;
2885928859
async function Run() {
2886028860
const [toolDirectory, steamDir] = await findOrDownload();
28861-
core.debug(`${STEAM_CMD} -> ${toolDirectory}`);
28861+
core.info(`${STEAM_CMD} -> ${toolDirectory}`);
2886228862
core.addPath(toolDirectory);
2886328863
const steam_cmd = path.join(toolDirectory, steamcmd, '..');
2886428864
core.exportVariable(STEAM_CMD, steam_cmd);
28865-
core.debug(`${STEAM_DIR} -> ${steamDir}`);
28865+
core.info(`${STEAM_DIR} -> ${steamDir}`);
2886628866
core.exportVariable(STEAM_DIR, steamDir);
2886728867
const steam_temp = path.join(process.env.RUNNER_TEMP, '.steamworks');
2886828868
await fs.promises.mkdir(steam_temp);
28869-
core.debug(`${STEAM_TEMP} -> ${steam_temp}`);
28869+
core.info(`${STEAM_TEMP} -> ${steam_temp}`);
2887028870
core.exportVariable(STEAM_TEMP, steam_temp);
2887128871
await exec.exec(steamcmd, ['+help', '+quit']);
2887228872
}
@@ -28901,19 +28901,30 @@ async function findOrDownload() {
2890128901
}
2890228902
core.debug(`Successfully extracted ${steamcmd} to ${downloadDirectory}`);
2890328903
tool = path.join(downloadDirectory, toolPath);
28904-
if (IS_LINUX) {
28905-
const exe = path.join(downloadDirectory, steamcmd);
28906-
await fs.promises.writeFile(exe, `#!/bin/bash\nexec "${tool}" "$@"`);
28907-
await fs.promises.chmod(exe, 0o755);
28908-
}
2890928904
const downloadVersion = await getVersion(tool);
2891028905
core.debug(`Setting tool cache: ${downloadDirectory} | ${steamcmd} | ${downloadVersion}`);
2891128906
toolDirectory = await tc.cacheDir(downloadDirectory, steamcmd, downloadVersion);
2891228907
}
2891328908
else {
2891428909
tool = path.join(toolDirectory, toolPath);
2891528910
}
28916-
await fs.promises.access(tool);
28911+
if (IS_LINUX) {
28912+
const exe = path.join(toolDirectory, steamcmd);
28913+
core.debug(`Creating ${exe} to point to ${tool}`);
28914+
try {
28915+
await fs.promises.access(exe);
28916+
await fs.promises.unlink(exe);
28917+
}
28918+
catch (error) {
28919+
if (error.code !== 'ENOENT') {
28920+
throw error;
28921+
}
28922+
}
28923+
await fs.promises.writeFile(exe, `#!/bin/bash\nexec "${tool}" "$@"`);
28924+
await fs.promises.chmod(exe, 0o777);
28925+
await fs.promises.access(exe, fs.constants.X_OK);
28926+
}
28927+
await fs.promises.access(tool, fs.constants.X_OK);
2891728928
core.debug(`Found ${tool} in ${toolDirectory}`);
2891828929
const steamDir = await getSteamDir(toolDirectory);
2891928930
return [toolDirectory, steamDir];

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "setup-steamcmd",
3-
"version": "1.0.3",
3+
"version": "1.0.4",
44
"description": "A GitHub Action to setup the steamcmd command alias.",
55
"author": "buildalon",
66
"repository": {

src/setup.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ const toolPath = `${steamcmd}${toolExtension}`;
1717

1818
async function Run(): Promise<void> {
1919
const [toolDirectory, steamDir] = await findOrDownload();
20-
core.debug(`${STEAM_CMD} -> ${toolDirectory}`);
20+
core.info(`${STEAM_CMD} -> ${toolDirectory}`);
2121
core.addPath(toolDirectory);
2222
const steam_cmd = path.join(toolDirectory, steamcmd, '..');
2323
core.exportVariable(STEAM_CMD, steam_cmd);
24-
core.debug(`${STEAM_DIR} -> ${steamDir}`);
24+
core.info(`${STEAM_DIR} -> ${steamDir}`);
2525
core.exportVariable(STEAM_DIR, steamDir);
2626
const steam_temp = path.join(process.env.RUNNER_TEMP, '.steamworks');
2727
await fs.promises.mkdir(steam_temp);
28-
core.debug(`${STEAM_TEMP} -> ${steam_temp}`);
28+
core.info(`${STEAM_TEMP} -> ${steam_temp}`);
2929
core.exportVariable(STEAM_TEMP, steam_temp);
3030
await exec.exec(steamcmd, ['+help', '+quit']);
3131
}
@@ -60,18 +60,28 @@ async function findOrDownload(): Promise<[string, string]> {
6060
}
6161
core.debug(`Successfully extracted ${steamcmd} to ${downloadDirectory}`);
6262
tool = path.join(downloadDirectory, toolPath);
63-
if (IS_LINUX) {
64-
const exe = path.join(downloadDirectory, steamcmd);
65-
await fs.promises.writeFile(exe, `#!/bin/bash\nexec "${tool}" "$@"`);
66-
await fs.promises.chmod(exe, 0o755);
67-
}
6863
const downloadVersion = await getVersion(tool);
6964
core.debug(`Setting tool cache: ${downloadDirectory} | ${steamcmd} | ${downloadVersion}`);
7065
toolDirectory = await tc.cacheDir(downloadDirectory, steamcmd, downloadVersion);
7166
} else {
7267
tool = path.join(toolDirectory, toolPath);
7368
}
74-
await fs.promises.access(tool);
69+
if (IS_LINUX) {
70+
const exe = path.join(toolDirectory, steamcmd);
71+
core.debug(`Creating ${exe} to point to ${tool}`);
72+
try {
73+
await fs.promises.access(exe);
74+
await fs.promises.unlink(exe);
75+
} catch (error) {
76+
if (error.code !== 'ENOENT') {
77+
throw error;
78+
}
79+
}
80+
await fs.promises.writeFile(exe, `#!/bin/bash\nexec "${tool}" "$@"`);
81+
await fs.promises.chmod(exe, 0o777);
82+
await fs.promises.access(exe, fs.constants.X_OK);
83+
}
84+
await fs.promises.access(tool, fs.constants.X_OK);
7585
core.debug(`Found ${tool} in ${toolDirectory}`);
7686
const steamDir = await getSteamDir(toolDirectory);
7787
return [toolDirectory, steamDir];

0 commit comments

Comments
 (0)