Skip to content

Commit cd1c5b2

Browse files
committed
fix build
1 parent f95bbe2 commit cd1c5b2

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

.github/workflows/CI.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,12 @@ jobs:
108108
with:
109109
bun-version: latest
110110

111+
- run: bun install
112+
- run: bun run build
113+
- run: bun run ./downloaddufs.ts
114+
- run: rm -rf node_modules
111115
- run: bun install --production --filter=./
112-
116+
113117
# 登录到 Docker Hub
114118
- name: Login to Docker Hub
115119
uses: docker/login-action@v3

downloaddufs.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { remove, exists, chmod } from "fs-extra";
2+
import { downloadRelease } from "@terascope/fetch-github-release";
3+
import { arch, platform } from "os";
4+
import { spawnSync } from "child_process";
5+
import { isArray } from "es-toolkit/compat";
6+
import { join } from "path";
7+
8+
const dld = async (targetPath: string) => {
9+
const dufsName = platform() === "win32" ? "dufs.exe" : "dufs";
10+
const dufsPath = join(targetPath, dufsName);
11+
const dufsExists = await exists(dufsPath);
12+
if (dufsExists) return;
13+
14+
// 下载最新 dufs
15+
const user = "sigoden";
16+
const repo = "dufs";
17+
const leaveZipped = false;
18+
const disableLogging = false;
19+
20+
const a = arch()
21+
.replace("arm64", "aarch64")
22+
.replace("ia32", "i686")
23+
.replace("x64", "x86_64");
24+
25+
const p = platform().replace("win32", "windows");
26+
27+
const names = await downloadRelease(
28+
user,
29+
repo,
30+
targetPath,
31+
(release) => release.prerelease === false,
32+
(asset) => asset.name.includes(p) && asset.name.includes(a),
33+
leaveZipped,
34+
disableLogging
35+
);
36+
37+
const target = (isArray(names) ? names : names.assetFileNames).at(0);
38+
39+
if (target && (await exists(target))) {
40+
spawnSync("tar", ["-zxvf", target, "-C", targetPath], {
41+
stdio: "inherit",
42+
});
43+
await remove(target);
44+
await chmod(join(targetPath, dufsName), 777);
45+
}
46+
};
47+
48+
await dld("dist/main");

0 commit comments

Comments
 (0)