Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding portable build alongside with installers #302

Open
Sparkenstein opened this issue Sep 21, 2022 · 16 comments
Open

Adding portable build alongside with installers #302

Sparkenstein opened this issue Sep 21, 2022 · 16 comments
Labels
good first issue Good for newcomers type: feature request New feature or request

Comments

@Sparkenstein
Copy link

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.

@FabianLars FabianLars added type: feature request New feature or request good first issue Good for newcomers labels Sep 21, 2022
@FabianLars
Copy link
Member

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 👍

@Sparkenstein
Copy link
Author

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

@FabianLars
Copy link
Member

FabianLars commented Sep 21, 2022

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

@Sparkenstein
Copy link
Author

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

@FabianLars
Copy link
Member

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.

@liudonghua123
Copy link
Contributor

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.

@FabianLars
Copy link
Member

@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)

@liudonghua123
Copy link
Contributor

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.

@FabianLars
Copy link
Member

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.

@liudonghua123
Copy link
Contributor

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?

@FabianLars
Copy link
Member

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

@liudonghua123
Copy link
Contributor

liudonghua123 commented Oct 13, 2022

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
Copy link
Contributor

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

@MathieuAndrade
Copy link

MathieuAndrade commented Jun 22, 2023

Hello !

Any update of this feature ?

@ShayBox
Copy link

ShayBox commented Jul 2, 2023

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

@luas10c
Copy link

luas10c commented Sep 24, 2024

I'm interested in contributing to embedding the portable build for windows x86_64 inside tauri-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers type: feature request New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants