Skip to content

Commit 96885c9

Browse files
committed
ci: only download llama.cpp release once
1 parent bc9cbd8 commit 96885c9

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

.github/workflows/build.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44

55
workflow_dispatch:
66

7-
8-
9-
concurrency: release-${{ github.ref }}
107
jobs:
118
build:
129
name: Build
@@ -20,11 +17,18 @@ jobs:
2017
run: npm ci --ignore-scripts
2118
- name: Build
2219
run: npm run build
23-
- name: Publish artifact
20+
- name: Download latest llama.cpp release
21+
run: node ./dist/cli/cli.js download --release latest --skipBuild
22+
- name: Upload build artifact
2423
uses: actions/upload-artifact@v3
2524
with:
2625
name: "build"
2726
path: "dist"
27+
- name: Upload llama.cpp artifact
28+
uses: actions/upload-artifact@v3
29+
with:
30+
name: "llama.cpp"
31+
path: "llama/llama.cpp"
2832

2933
build-binaries:
3034
name: Build binaries - ${{ matrix.config.name }}
@@ -61,11 +65,18 @@ jobs:
6165
with:
6266
node-version: "20"
6367

64-
- uses: actions/download-artifact@v3
68+
- name: Download build artifact
69+
uses: actions/download-artifact@v3
6570
with:
6671
name: build
6772
path: dist
6873

74+
- name: Download llama.cpp artifact
75+
uses: actions/download-artifact@v3
76+
with:
77+
name: llama.cpp
78+
path: llama/llama.cpp
79+
6980
- uses: actions/setup-python@v4
7081
with:
7182
python-version: "3.10"
@@ -159,7 +170,7 @@ jobs:
159170
const majorNodeVersion = parseInt(nodeVersion.slice("v".length))
160171
161172
const binName = `${process.env.ARTIFACT_NAME}-${arch}-${majorNodeVersion}.node`;
162-
await $`node ./dist/cli/cli.js download --arch ${arch} --nodeTarget ${nodeVersion}`;
173+
await $`node ./dist/cli/cli.js build --arch ${arch} --nodeTarget ${nodeVersion}`;
163174
await $`mv ./llama/build/Release/llama.node ${"./llamaBins/" + binName}`;
164175
}
165176
}

src/cli/commands/DownloadCommand.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ type DownloadCommandArgs = {
1616
repo: string,
1717
release: "latest" | string,
1818
arch?: string,
19-
nodeTarget?: string
19+
nodeTarget?: string,
20+
skipBuild?: boolean
2021
};
2122

2223
export const DownloadCommand: CommandModule<object, DownloadCommandArgs> = {
@@ -41,12 +42,17 @@ export const DownloadCommand: CommandModule<object, DownloadCommandArgs> = {
4142
.option("nodeTarget", {
4243
type: "string",
4344
description: "The Node.js version to compile llama.cpp for. Example: v18.0.0"
45+
})
46+
.option("skipBuild", {
47+
type: "boolean",
48+
default: false,
49+
description: "Skip building llama.cpp after downloading it"
4450
});
4551
},
4652
handler: DownloadLlamaCppCommand
4753
};
4854

49-
export async function DownloadLlamaCppCommand({repo, release, arch, nodeTarget}: DownloadCommandArgs) {
55+
export async function DownloadLlamaCppCommand({repo, release, arch, nodeTarget, skipBuild}: DownloadCommandArgs) {
5056
const octokit = new Octokit();
5157
const [githubOwner, githubRepo] = repo.split("/");
5258

@@ -124,13 +130,6 @@ export async function DownloadLlamaCppCommand({repo, release, arch, nodeTarget}:
124130
await unzipLlamaReleaseZipFile(path.join(tempDownloadDirectory, "llama.cpp.zip"), llamaCppDirectory);
125131
});
126132

127-
console.log(chalk.blue("Compiling llama.cpp"));
128-
await compileLlamaCpp({
129-
arch: arch ? arch : undefined,
130-
nodeTarget: nodeTarget ? nodeTarget : undefined,
131-
setUsedBingFlag: true
132-
});
133-
134133
await withOra({
135134
loading: chalk.blue("Removing temporary files"),
136135
success: chalk.blue("Removed temporary files"),
@@ -139,6 +138,15 @@ export async function DownloadLlamaCppCommand({repo, release, arch, nodeTarget}:
139138
await clearTempFolder();
140139
});
141140

141+
if (!skipBuild) {
142+
console.log(chalk.blue("Compiling llama.cpp"));
143+
await compileLlamaCpp({
144+
arch: arch ? arch : undefined,
145+
nodeTarget: nodeTarget ? nodeTarget : undefined,
146+
setUsedBingFlag: true
147+
});
148+
}
149+
142150
console.log();
143151
console.log();
144152
console.log(`${chalk.yellow("Repo:")} ${repo}`);

0 commit comments

Comments
 (0)