Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

improve ci & prebuild (#166)

Brendan Allanfbdfbcf1a837
diff --git a/.github/actions/install-desktop-deps/action.yml b/.github/actions/install-desktop-deps/action.yml
index 8e8c89f74..726db4e24 100644
--- a/.github/actions/install-desktop-deps/action.yml
+++ b/.github/actions/install-desktop-deps/action.yml
@@ -7,5 +7,15 @@ runs:
if: ${{ runner.os == 'Linux' }}
shell: bash
run: |
- sudo apt-get update
- sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf libasound2-dev libxtst-dev libevdev-dev libxdo-dev libsoup-3.0-dev
+ sudo apt update
+ sudo apt install libwebkit2gtk-4.1-dev \
+ build-essential \
+ curl \
+ wget \
+ file \
+ libxdo-dev \
+ libssl-dev \
+ libayatana-appindicator3-dev \
+ librsvg2-dev \
+ libpipewire-0.3-dev \
+ ffmpeg clang libavcodec-dev libavformat-dev libavutil-dev libavfilter-dev libavdevice-dev pkg-config libasound2-dev
diff --git a/.github/prebuild.js b/.github/prebuild.js
index 46754bf5c..dcddb625d 100644
--- a/.github/prebuild.js
+++ b/.github/prebuild.js
@@ -12,42 +12,16 @@ const keychain = env.APPLE_KEYCHAIN ? `--keychain ${env.APPLE_KEYCHAIN}` : "";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
-async function symlinkSharedLibsMacOS(nativeDeps) {
- // Framework
- const framework = path.join(nativeDeps, "Spacedrive.framework");
-
- // Sign dylibs (Required for them to work on macOS 13+)
- await fs
- .readdir(path.join(framework, "Libraries"), {
- recursive: true,
- withFileTypes: true,
- })
- .then((files) =>
- Promise.all(
- files
- .filter((entry) => entry.isFile() && entry.name.endsWith(".dylib"))
- .map((entry) =>
- exec(
- `codesign ${keychain} -s "${signId}" -f "${path.join(
- entry.path,
- entry.name
- )}"`
- )
- )
- )
- );
-}
-
const __root = path.resolve(path.join(__dirname, ".."));
const nativeDeps = path.join(__root, "native-deps");
+const srcTauri = path.join(__root, "apps/desktop/src-tauri");
async function main() {
await fs.mkdir(path.join(__root, ".cargo"), { recursive: true });
await fs.writeFile(
path.join(__root, ".cargo/config.toml"),
- `
-[env]
+ `[env]
FFMPEG_DIR = { force = true, value = "${nativeDeps}" }
[target.x86_64-apple-darwin]
@@ -65,38 +39,65 @@ rustflags = [
]`
);
+ const os = process.argv[2];
+ const arch = process.argv[3];
+
+ if (!os) throw new Error("OS not provided");
+ if (!arch) throw new Error("Arch not provided");
+
await fs.rm(nativeDeps, { recursive: true, force: true });
await fs.mkdir(nativeDeps, { recursive: true });
- const res = await fetch(
- `${NATIVE_DEPS_URL}/${NATIVE_DEPS_ASSETS.Darwin[process.argv[2]]}`
- );
+ const res = await fetch(`${NATIVE_DEPS_URL}/${NATIVE_DEPS_ASSETS[os][arch]}`);
const body = await res.blob();
await fs.writeFile(
`${__root}/native-deps.tar.xz`,
Buffer.from(await body.arrayBuffer())
);
- await exec(`tar xf ${__root}/native-deps.tar.xz -C ${nativeDeps}`);
- await symlinkSharedLibsMacOS(nativeDeps).catch((e) => {
- console.error(`Failed to symlink shared libs.`);
- throw e;
- });
+ await exec(`tar xf ${__root}/native-deps.tar.xz -C ${nativeDeps}`);
- await fs.writeFile(
- `${__root}/apps/desktop/src-tauri/tauri.macos.conf.json`,
- JSON.stringify(
- {
- bundle: {
- macOS: {
- frameworks: [path.join(nativeDeps, "Spacedrive.framework")],
+ if (os === "darwin") {
+ await symlinkSharedLibsMacOS(nativeDeps).catch((e) => {
+ console.error(`Failed to symlink shared libs.`);
+ throw e;
+ });
+
+ await fs.writeFile(
+ `${srcTauri}/tauri.macos.conf.json`,
+ JSON.stringify(
+ {
+ bundle: {
+ macOS: {
+ frameworks: [path.join(nativeDeps, "Spacedrive.framework")],
+ },
},
},
- },
- null,
- 4
- )
- );
+ null,
+ 4
+ )
+ );
+ } else if (os === "windows") {
+ const binFiles = await fs.readdir(path.join(nativeDeps, "bin"));
+
+ await fs.writeFile(
+ `${srcTauri}/tauri.windows.conf.json`,
+ JSON.stringify(
+ {
+ bundle: {
+ resources: binFiles.filter(
+ (f) =>
+ f.endsWith(".dll") && (f.startsWith("av") || f.startsWith("sw"))
+ ),
+ },
+ },
+ null,
+ 4
+ )
+ );
+
+ console.log();
+ }
}
main();
@@ -105,8 +106,38 @@ const NATIVE_DEPS_URL =
"https://github.com/spacedriveapp/native-deps/releases/latest/download";
const NATIVE_DEPS_ASSETS = {
- Darwin: {
+ darwin: {
x86_64: "native-deps-x86_64-darwin-apple.tar.xz",
aarch64: "native-deps-aarch64-darwin-apple.tar.xz",
},
+ windows: {
+ x86_64: "native-deps-x86_64-windows-gnu.tar.xz",
+ aarch64: "native-deps-aarch64-windows-gnu.tar.xz",
+ },
};
+
+async function symlinkSharedLibsMacOS(nativeDeps) {
+ // Framework
+ const framework = path.join(nativeDeps, "Spacedrive.framework");
+
+ // Sign dylibs (Required for them to work on macOS 13+)
+ await fs
+ .readdir(path.join(framework, "Libraries"), {
+ recursive: true,
+ withFileTypes: true,
+ })
+ .then((files) =>
+ Promise.all(
+ files
+ .filter((entry) => entry.isFile() && entry.name.endsWith(".dylib"))
+ .map((entry) =>
+ exec(
+ `codesign ${keychain} -s "${signId}" -f "${path.join(
+ entry.path,
+ entry.name
+ )}"`
+ )
+ )
+ )
+ );
+}
diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml
index 10aad21a7..2872fa99c 100644
--- a/.github/workflows/debug.yml
+++ b/.github/workflows/debug.yml
@@ -68,7 +68,7 @@ jobs:
working-directory: apps/desktop
run: |
export TARGET_TRIPLE=aarch64-apple-darwin
- node ${{ github.workspace }}/.github/prebuild.js aarch64
+ node ${{ github.workspace }}/.github/prebuild.js darwin aarch64
pnpm tauri build --target aarch64-apple-darwin --debug
env:
CI: false
@@ -90,4 +90,4 @@ jobs:
with:
name: debug-build-aarch64-apple-darwin
path: apps/desktop/src-tauri/target/aarch64-apple-darwin/debug/bundle/**/*.app
- if-no-files-found: error
\ No newline at end of file
+ if-no-files-found: error
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index 1a8c8d759..cbc5895f3 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -146,7 +146,7 @@ jobs:
working-directory: apps/desktop
run: |
export TARGET_TRIPLE=${{ matrix.settings.target }}
- node ${{ github.workspace }}/.github/prebuild.js ${{ matrix.settings.prebuild }}
+ node ${{ github.workspace }}/.github/prebuild.js darwin ${{ matrix.settings.prebuild }}
pnpm tauri build --target ${{ matrix.settings.target }} --config src-tauri/tauri.conf.prod.json
env:
# https://github.com/tauri-apps/tauri-action/issues/740
diff --git a/.gitignore b/.gitignore
index cfed069cb..d1b883741 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,5 +32,6 @@ pnpm-lock.yaml
.zed
.output
.vinxi
-native-deps
-apps/storybook/storybook-static
\ No newline at end of file
+native-deps*
+apps/storybook/storybook-static
+tauri.*.conf.json