diff --git a/.github/workflows/template-tauri-build-linux-x64.yml b/.github/workflows/template-tauri-build-linux-x64.yml index 303b001096..274aa36620 100644 --- a/.github/workflows/template-tauri-build-linux-x64.yml +++ b/.github/workflows/template-tauri-build-linux-x64.yml @@ -150,12 +150,6 @@ jobs: fi - name: Build app run: | - # Pin linuxdeploy version to prevent @tauri-apps/cli-linux-x64-gnu from pulling in an outdated version - TAURI_TOOLKIT_PATH="${XDG_CACHE_HOME:-$HOME/.cache}/tauri" - mkdir -p "$TAURI_TOOLKIT_PATH" - wget https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20250213-2/linuxdeploy-x86_64.AppImage -O "$TAURI_TOOLKIT_PATH/linuxdeploy-x86_64.AppImage" - chmod +x "$TAURI_TOOLKIT_PATH/linuxdeploy-x86_64.AppImage" - make build-tauri # Copy engines and bun to appimage wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O ./appimagetool diff --git a/.gitignore b/.gitignore index f09d958d00..e714bfdd6a 100644 --- a/.gitignore +++ b/.gitignore @@ -49,4 +49,5 @@ src-tauri/resources/bin # Helper tools .opencode OpenCode.md -archive/ \ No newline at end of file +archive/ +.cache/ \ No newline at end of file diff --git a/Makefile b/Makefile index 6e69c602dd..e2c3bc2819 100644 --- a/Makefile +++ b/Makefile @@ -82,6 +82,7 @@ else ifeq ($(shell uname -s),Linux) rm -rf ./src-tauri/target rm -rf "~/jan/extensions" rm -rf "~/.cache/jan*" + rm -rf "./.cache" else find . -name "node_modules" -type d -prune -exec rm -rf '{}' + find . -name ".next" -type d -exec rm -rf '{}' + diff --git a/package.json b/package.json index 7be0e769db..356aeff1c5 100644 --- a/package.json +++ b/package.json @@ -30,9 +30,10 @@ "copy:lib:win32": "cpx \"./lib/windows/*.dll\" \"./src-tauri/resources/lib/\"", "copy:lib:darwin": "mkdir -p \"./src-tauri/resources/lib/\"", "download:bin": "node ./scripts/download-bin.mjs", - "build:tauri:linux:win32": "yarn download:bin && yarn install:cortex && yarn build:icon && yarn copy:assets:tauri && yarn tauri build", - "build:tauri:darwin": "yarn install:cortex && yarn build:icon && yarn copy:assets:tauri && yarn tauri build --target universal-apple-darwin", - "build:tauri": "run-script-os", + "build:tauri:win32": "yarn download:bin && yarn tauri build", + "build:tauri:linux": "yarn download:bin && ./src-tauri/build-utils/shim-linuxdeploy.sh yarn tauri build", + "build:tauri:darwin": "yarn tauri build --target universal-apple-darwin", + "build:tauri": "yarn install:cortex && yarn build:icon && yarn copy:assets:tauri && run-script-os", "build:icon": "tauri icon ./src-tauri/icons/icon.png", "build:core": "cd core && yarn build && yarn pack", "build:web": "yarn workspace @janhq/web-app build", diff --git a/src-tauri/build-utils/shim-linuxdeploy.sh b/src-tauri/build-utils/shim-linuxdeploy.sh new file mode 100755 index 0000000000..fbbbd51734 --- /dev/null +++ b/src-tauri/build-utils/shim-linuxdeploy.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +# wrapper script to pin linuxdeploy version and inject environment variables into the +# build process. While yarn supports injecting environment vairables via env files, +# this applies to all yarn scripts. Using a wrapper allows granular control over +# when environment variables are injected, and avoids tainting the system .cache + +# avoid redownloading corepack if possible +export COREPACK_HOME=${COREPACK_HOME:-${XDG_CACHE_HOME:-$HOME/.cache}/node/corepack} +# move cache home to /.cache +export XDG_CACHE_HOME=${PWD}/.cache + +LINUXDEPLOY_VER="1-alpha-20250213-2" +LINUXDEPLOY="$XDG_CACHE_HOME/tauri/linuxdeploy-$LINUXDEPLOY_VER-x86_64.AppImage" +SYMLINK="$XDG_CACHE_HOME/tauri/linuxdeploy-x86_64.AppImage" + +mkdir -p "$XDG_CACHE_HOME/tauri" + +if [ ! -f $LINUXDEPLOY ]; then + GLOB_PATTERN="$XDG_CACHE_HOME/tauri/linuxdeploy-*-x86_64.AppImage" + rm $GLOB_PATTERN + wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/$LINUXDEPLOY_VER/linuxdeploy-x86_64.AppImage" -O "$LINUXDEPLOY" + chmod a+x "$LINUXDEPLOY" +fi + +rm $SYMLINK +ln -s "$LINUXDEPLOY" "$SYMLINK" + +"$@" \ No newline at end of file