tauri-action icon indicating copy to clipboard operation
tauri-action copied to clipboard

Adding portable build alongside with installers

Open Sparkenstein opened this issue 3 years ago • 16 comments

When tauri builds an app, it also generates a portable build executable that you can just double click open (src-tauri/release/appname). It would be easier if tauri actions can release these builds as well so that devs can test the application before installing.

it's fine if they don't check if webview is installed/available or even autoupdater doesn't work, as these will be mostly quick testing purpose.

Sparkenstein avatar Sep 21 '22 10:09 Sparkenstein

As long as it's obvious that this would be basically some kind of unstable/dangerous option, i think this would be a cool small addition 👍

FabianLars avatar Sep 21 '22 10:09 FabianLars

unstable is understandable, but why would it be dangerous? any security implications?

Sparkenstein avatar Sep 21 '22 14:09 Sparkenstein

couldn't think of a better word - we just need to make it obvious that the exe is not actually redistributable (or 100% "portable")

FabianLars avatar Sep 21 '22 14:09 FabianLars

That's fair. I was looking into the source, if I am right is this the right place to add the files into release?

https://github.com/tauri-apps/tauri-action/blob/dev/packages/action/src/create-release.ts#L61

if tauri team is interested in this feature I can just go ahead and implement it. note I have no experience in github actions I am assuming it will Just Work

Sparkenstein avatar Sep 21 '22 15:09 Sparkenstein

The most relevant part for adding the file itself would be here iirc https://github.com/tauri-apps/tauri-action/blob/dev/packages/core/index.ts#L424

Adding the flag to include it is a little more involved, but i guess most of the stuff for includeDebug can be copied.

FabianLars avatar Sep 21 '22 15:09 FabianLars

As long as it's obvious that this would be basically some kind of unstable/dangerous option, i think this would be a cool small addition 👍

unstable/dangerous? But the msi installer of the app is just ship the same single executable .exe file. Sometimes it's more convenience to share a green portable app instead of an installer.

liudonghua123 avatar Oct 13 '22 03:10 liudonghua123

@liudonghua123 As i said in another comment, i just couldn't think of a better word. It's just that it must be obvious that the majority of devs don't actually want the .exe because it's not portable in a traditional sense, primarily because it will just crash if WebView2 is not installed (WV2 is only pre-installed on Windows 11, and even there you can't really count on it). And of course some features will not work, like Sidecars, Resources and the Notification API (it will display the wrong icon/name for some reason)

FabianLars avatar Oct 13 '22 08:10 FabianLars

Thanks, I see now. 😄

I remember that I run .exe in windows 10 which does have WebView2 installed a few months ago, the .exe open the webview2 page and instruct me to download and install it.

Other features like you said are not available when running a .exe should be right.

liudonghua123 avatar Oct 13 '22 10:10 liudonghua123

the .exe open the webview2 page and instruct me to download and install it.

This is not the case unless the developer of the exe you downloaded implemented this in Rust themselves. In general Tauri apps will just panic/crash if WebView2 is not installed.

FabianLars avatar Oct 13 '22 10:10 FabianLars

If the webview2 is not installed on some old windows like windows 7 or 10, whether the .msi installer will instruct to download and install webview2?

liudonghua123 avatar Oct 13 '22 10:10 liudonghua123

The msi will install it automatically without any user interaction required.

FabianLars avatar Oct 13 '22 11:10 FabianLars

Need help!

I tried to add some customization to my version of tauri-apps/tauri-action, release executables and add target argument support. Now almost everything works except when building linux 32-bit app.

The detail logs are on https://github.com/liudonghua123/CyberChef-desktop/actions/runs/3243902709/jobs/5319292830.

The following screenshot is from https://github.com/liudonghua123/CyberChef-desktop/releases/tag/app-v9.46.5.

image

Now I got errors when run yarn tauri build -t i686-unknown-linux-gnu in the liudonghua123/tauri-action@v0 action.

But it's strange because I can build successfully almost use the same commands, see also https://github.com/liudonghua123/cyberchef-app/blob/main/.github/workflows/build_and_deploy.yml.

   Compiling deflate v0.7.20
   Compiling cfb v0.6.1
   Compiling foreign-types v0.3.2
   Compiling open v3.0.3
error: failed to run custom build command for `libdbus-sys v0.2.2`

Caused by:
  process didn't exit successfully: `/home/runner/work/CyberChef-desktop/CyberChef-desktop/src-tauri/target/release/build/libdbus-sys-f5f362d6caae23b6/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=DBUS_1_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_i686-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_i686_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_i686-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_i686_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_i686-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_i686_unknown_linux_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR

  --- stderr
  pkg_config failed: pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.
  One possible solution is to check whether packages
  'libdbus-1-dev' and 'pkg-config' are installed:
  On Ubuntu:
  sudo apt install libdbus-1-dev pkg-config
  On Fedora:
  sudo dnf install dbus-devel pkgconf-pkg-config

  thread 'main' panicked at 'explicit panic', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/libdbus-sys-0.2.2/build.rs:16:9
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
       Error failed to build app: failed to build app

liudonghua123 avatar Oct 13 '22 16:10 liudonghua123

Now I fixed the linux 32-bit build problems, I modified execCommand in packages\core\index.ts, append the process.env to env option like the following code. Then try to set PKG_CONFIG_PATH and PKG_CONFIG_SYSROOT_DIR env.

export function execCommand(
  command: string,
  args: string[],
  { cwd }: { cwd?: string } = {}
): Promise<void> {
  console.log(`running ${command}`, args)
  console.log(process.env)
  return execa(command, args, {
    cwd,
    stdio: 'inherit',
    env: { ...process.env, FORCE_COLOR: '0' },
  }).then()
}

    - name: Patch for Linux 32-bit env
      if: matrix.os == 'ubuntu-22.04' && matrix.target == 'i686-unknown-linux-gnu'
      run: |
        echo "PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH" >> $GITHUB_ENV
        echo "PKG_CONFIG_SYSROOT_DIR=/" >> $GITHUB_ENV
        export PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/share/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:$PKG_CONFIG_PATH
        export PKG_CONFIG_SYSROOT_DIR=/
        ls -l $GITHUB_ENV
        cat $GITHUB_ENV
        ls -l /usr/lib/pkgconfig /usr/share/pkgconfig /usr/lib/i386-linux-gnu/pkgconfig /usr/lib/x86_64-linux-gnu/pkgconfig
      shell: bash

liudonghua123 avatar Oct 13 '22 17:10 liudonghua123

Hello !

Any update of this feature ?

MathieuAndrade avatar Jun 22 '23 18:06 MathieuAndrade

This is my current workaround, my project doesn't even use a GUI, I'm just using Tauri for the simple bundler and actions, so a portable exe would both still work on Windows 7, and I wouldn't care if it didn't

on:
  release:
    types: [ created ]

jobs:
  release:
    env:
      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    strategy:
      fail-fast: false
      matrix:
        include:
          - name: Linux-x86_64
            target: x86_64-unknown-linux-gnu
            runner: ubuntu-latest

          - name: macOS-Apple
            target: aarch64-apple-darwin
            runner: macos-latest

          - name: macOS-Intel
            target: x86_64-apple-darwin
            runner: macos-latest

          - name: Windows-x86_64
            target: x86_64-pc-windows-msvc
            runner: windows-latest

    name: ${{ matrix.name }}
    runs-on: ${{ matrix.runner }}
    steps:
      - name: Fetch Repository
        uses: actions/checkout@v3

      - name: Update and Install Dependencies (Linux)
        if: ${{ matrix.runner == 'ubuntu-latest' }}
        run: |
          sudo apt-get update
          sudo apt-get install -y libwebkit2gtk-4.0-dev

      - name: Update Rust Toolchain
        run: rustup update stable

      - name: Add Rust Target
        run: rustup target add ${{ matrix.target }}

      - name: Build Tauri Installers/Bundles/Images
        uses: tauri-apps/tauri-action@dev
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          args: --target ${{ matrix.target }}
          releaseId: ${{ github.event.release.id }}
          tagName: ${{ github.ref_name }}

      - name: Build Portable Binaries (Windows)
        if: ${{ matrix.runner == 'windows-latest' }}
        run: |
          cargo build --target ${{ matrix.target }}
          cargo build --release --target ${{ matrix.target }}
          mv ./target/${{ matrix.target }}/debug/wooting-profile-switcher.exe ./target/${{ matrix.target }}/debug/WootingProfileSwitcher_${{ github.ref_name }}_x64-portable.exe
          mv ./target/${{ matrix.target }}/release/wooting-profile-switcher.exe ./target/${{ matrix.target }}/release/WootingProfileSwitcher_${{ github.ref_name }}_x64-portable.exe

      - name: Upload Portable Binaries (Windows)
        if: ${{ matrix.runner == 'windows-latest' }}
        run: bash -c 'gh release upload ${{ github.ref_name }} ./target/${{ matrix.target }}/{debug/WootingProfileSwitcher_${{ github.ref_name }}_x64-portable.exe,release/WootingProfileSwitcher_${{ github.ref_name }}_x64-portable.exe} --clobber'

You may have to do some tweaking

ShayBox avatar Jul 02 '23 20:07 ShayBox