Coder Social home page Coder Social logo

tauri-build's Introduction

tauri-build

A composable action to build your Tauri project.

Usage

As opposed to the offical tauri-action this action is as minimal as possible. Instead of creating a GitHub release and uploading artifacts all-in-one, it provides outputs to conveniently compose together with other actions such as actions/upload-artifact, actions/download-artifact or softprops/action-gh-release.

This action needs both Node.JS and Cargo to be already setup.

Minimal

The following example workflow builds artifacts on all 3 supported platforms (Window, macOS and Linux).

name: 'publish'

on:
  push:
    branches:
      - release

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build-binaries:
    strategy:
      fail-fast: false
      matrix:
        platform: [macos-latest, ubuntu-latest, windows-latest]

    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v2

      - name: setup node
        uses: actions/setup-node@v1
        with:
          node-version: 16

      - name: install Rust stable
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable

      - name: install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-latest'
        run: |
          sudo apt-get update
          sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf

      - uses: JonasKruckenberg/tauri-build@v1
        id: tauri_build

    # You can now use the JSON array of artifacts under `steps.tauri_build.outputs.artifacts` to post-process/upload your bundles

Bundling the app and creating a release

Chances are you want to do something with the artifacts that you produced. The following action will produce artifacts for Windows, macOS and Linux upload them as workflow artifacts, so that a final job (called publish) can create a GitHub release and attach all prouced artifacts to it. This would also be the place where you could upload artifacts to an AWS Bucket or similar.

name: 'publish'

on:
  push:
    branches:
      - release

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build-binaries:
    strategy:
      fail-fast: false
      matrix:
        platform: [macos-latest, ubuntu-latest, windows-latest]

    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v2

      - name: setup node
        uses: actions/setup-node@v1
        with:
          node-version: 16

      - name: install Rust stable
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable

      - name: install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-latest'
        run: |
          sudo apt-get update
          sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf

      - uses: JonasKruckenberg/tauri-build@v1
        id: tauri_build

      # The `artifacts` output can now be used by a different action to upload the artifacts
      - uses: actions/upload-artifact@v3
        with:
          name: artifacts
          path: "${{ join(fromJSON(steps.tauri_build.outputs.artifacts), '\n') }}"

  publish:
    needs: build-binaries
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      # Download the previously uploaded artifacts
      - uses: actions/download-artifact@v3
        id: download
        with:
          name: artifacts
          path: artifacts
      # And create a release with the artifacts attached
      - name: 'create release'
        uses: softprops/action-gh-release@master
        env:
          GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
        with:
          draft: false
          files: ./artifacts/**/*

Building for Apple Silicon

This example workflow will run produce binaries for Apple Silicon (aarch64) as well as the previously shown 3 platforms. This leverages the build matrix. This can be expanded to produce binaries for other target combinations too.

name: 'publish'

on:
  push:
    branches:
      - release

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build-binaries:
    strategy:
      fail-fast: false
      matrix:
        platform:
          - os: ubuntu-latest
            rust_target: x86_64-unknown-linux-gnu
          - os: macos-latest
            rust_target: x86_64-apple-darwin
          - os: macos-latest
            rust_target: aarch64-apple-darwin
          - os: windows-latest
            rust_target: x86_64-pc-windows-msvc

    runs-on: ${{ matrix.platform.os }}
    steps:
    - uses: actions/checkout@v3
    
    - name: setup node
      uses: actions/setup-node@v3
      with:
        node-version: 18

    - name: 'Setup Rust'
      uses: actions-rs/toolchain@v1
      with:
        default: true
        override: true
        profile: minimal
        toolchain: stable
        target: ${{ matrix.platform.rust_target }}

    - uses: Swatinem/rust-cache@v2

    - name: install dependencies (ubuntu only)
      if: matrix.platform.os == 'ubuntu-latest'
      run: |
        sudo apt-get update
        sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf

    - uses: JonasKruckenberg/[email protected]
      id: tauri_build
      with:
        target: ${{ matrix.platform.rust_target }}

    # The artifacts output can now be used to upload the artifacts
    - uses: actions/upload-artifact@v3
      with:
        name: artifacts
        path: "${{ join(fromJSON(steps.tauri_build.outputs.artifacts), '\n') }}"

  publish:
    needs: build-binaries
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      # Download the previously uploaded artifacts
      - uses: actions/download-artifact@v3
        id: download
        with:
          name: artifacts
          path: artifacts
      # And create a release with the artifacts attached
      - name: 'create release'
        uses: softprops/action-gh-release@master
        env:
          GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
        with:
          draft: false
          files: ./artifacts/**/*

Inputs

Name Type Description Default
runner String Binary to use to build the application
args String Additional arguments for the build command
projectPath String Path to the root of the Tauri project .
configPath String Path to the tauri.conf.json file, relative to projectPath tauri.conf.json
target String Rust target triple to build against
debug Boolean Wether to build debug or release binaries false

Outputs

Name Type Description
artifacts String JSON array of artifact paths produced by the build command

Permissions

This Action requires the following permissions on the GitHub integration token:

permissions:
  contents: write

License

MIT ยฉ Jonas Kruckenberg

tauri-build's People

Contributors

dependabot[bot] avatar jlarmstrongiv avatar jonaskruckenberg avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tauri-build's Issues

Failed to build on Windows using version 1.3

I'm sorry, I'm a beginner in github actions and I've encountered some issues.
After the tauri build update, its build on Windows systems failed.

Here are the logs and workflows.

Compiling tauriapp v0.1.0 (D:\a\tauriapp\tauriapp\src-tauri)
    Finished release [optimized] target(s) in 6m 02s
warning: the following packages contain code that will be rejected by a future version of Rust: buf_redux v0.8.4, multipart v0.18.0
note: to see what the problems were, use the option `--future-incompat-report`, or run `cargo report future-incompatibilities --id 1`
        Info Verifying wix package
 Downloading https://github.com/wixtoolset/wix3/releases/download/wix3112rtm/wix311-binaries.zip
        Info validating hash
        Info extracting WIX
        Info Target: x64
 Downloading https://go.microsoft.com/fwlink/p/?LinkId=2124703
     Running candle for "main.wxs"
     Running light to produce D:\a\tauriapp\tauriapp\src-tauri\target\release\bundle\msi\tauriapp_0.2.2_x64_zh-CN.msi
        Info Verifying NSIS package
 Downloading https://github.com/tauri-apps/binary-releases/releases/download/nsis-3/nsis-3.zip
        Info validating hash
        Info extracting NSIS
 Downloading https://github.com/tauri-apps/binary-releases/releases/download/nsis-plugins-v0/NSIS-ApplicationID.zip
        Info extracting NSIS ApplicationID plugin
 Downloading https://github.com/tauri-apps/nsis-tauri-utils/releases/download/nsis_tauri_utils-v0.1.1/nsis_tauri_utils.dll
        Info validating hash
        Info Target: x64
 Downloading https://go.microsoft.com/fwlink/p/?LinkId=2124703
     Running makensis.exe to produce D:\a\tauriapp\tauriapp\src-tauri\target\release\bundle\nsis\tauriapp_0.2.2_x64-setup.exe
File: output name must not begin with a quote, use "/oname=name with spaces".
Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
   /oname=outfile one_file_only)
Error in script "D:\a\tauriapp\tauriapp\src-tauri\target\release\nsis\x64\installer.nsi" on line 355 -- aborting creation process
Error: failed to bundle project: `The system cannot find the file specified. (os error 2)`
jobs:
  build-binaries:
    strategy:
      fail-fast: false
      matrix:
        platform: [macos-latest, ubuntu-latest, windows-latest]
    runs-on: ${{ matrix.platform }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-latest'
        run: |
          sudo apt-get update
          sudo apt-get install -y libgtk-3-dev webkit2gtk-4.0 libappindicator3-dev librsvg2-dev patchelf
      - name: Rust setup
        uses: dtolnay/rust-toolchain@stable

      - name: Rust cache
        uses: swatinem/rust-cache@v2
        with:
          workspaces: './src-tauri -> target'

      - name: Pnpm setup
        uses: pnpm/action-setup@v2
        with:
          version: 8

      - name: Sync node version and setup cache
        uses: actions/setup-node@v3
        with:
          node-version: 18
          cache: 'pnpm'

      - name: Install app dependencies and build web
        run: pnpm i

      - uses: JonasKruckenberg/tauri-build@v1
        id: tauri_build

      - uses: actions/upload-artifact@v3
        with:
          name: 'artifacts-${{ matrix.platform }}'
          path: "${{ join(fromJSON(steps.tauri_build.outputs.artifacts), '\n') }}"

Thank you for reading. How should I solve this problem?

NSIS Installer Output not picked up as output

Hi,

I have the following issue when trying to upload the artifacts of this action when using a a Nsis installer output (the upload works fine for macOS and linux builds btw).

The build for windows works fine, we can see that the artifacts are created in the github log:

    Finished 1 bundle at:
        D:\a\projectname\projectname\src-tauri\target\release\bundle\nsis\projectname_0.7.0-BETA_x64-setup.exe
        D:\a\projectname\projectname\src-tauri\target\release\bundle\nsis\projectname_0.7.0-BETA_x64-setup.nsis.zip (updater)

    Finished 1 updater signature at:
        D:\a\projectname\projectname\src-tauri\target\release\bundle\nsis\projectname_0.7.0-BETA_x64-setup.nsis.zip.sig

But the upload artifact action fails:

Run actions/upload-artifact@v3
Error: Input required and not supplied: path

The github workflow code was taken from the README.md and modified to only produce the nsis &updater output (-b nsis,updater), the relevant sections look like this:

      - uses: JonasKruckenberg/tauri-build@main
        id: tauri_build
        with:
          args: "${{ matrix.platform == 'windows-latest' && '-b nsis,updater --ci' || '' }}"

      - uses: actions/upload-artifact@v3
        with:
          name: artifacts
          path: "${{ join(fromJSON(steps.tauri_build.outputs.artifacts), '\n') }}"

My assumption is, that the output variable of tauri_build is not correctly set for the nsis installer output.

I've found issue: #266 which mentions that the output of the nsis installer should be fixed - I've tried out main and v1.4 and verified that the problem persists.

I've cloned the tauri-build action and took a look at the code and found the windows extensions code in build-projects.ts:

  const windowsExts = ['exe', 'exe.zip', 'exe.zip.sig', 'msi', 'msi.zip', 'msi.zip.sig']

Which is IMHO missing some relevant entries for the nsis output as shown in the github action log above, like nsis.zip and nsis.zip.sig.

For comparison, I've looked at the "official" github action tauri-action, the relevant code in build.ts looks like:

    ...
    winArtifacts.push(
      join(
        artifactsPath,
        `bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.exe`
      )
    );
    winArtifacts.push(
      join(
        artifactsPath,
        `bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.nsis.zip`
      )
    );
    winArtifacts.push(
      join(
        artifactsPath,
        `bundle/nsis/${fileAppName}_${app.version}_${arch}-setup.nsis.zip.sig`
      )
    );

I think that at least nsis.zip and nsis.zip.sig are missing in the windowsExts variable.

What I don't yet understand is, why is the output completely empty? Shouldn't at least the nsis .exe be picked up?

I just started using the github ci yesterday and I am new to github actions don't know how I would go about testing a potential fix of the action?

Any pointers are welcome, thanks!

Take care,
Martin

Failed to build tauri 1.4 version

I use src-tauri/tauri.conf.json > tauri > bundle > dev > desktopTemplate to make my app support files handling in system. Not sure about other features I've used.

Please, update the runner.

Uploading file on Windows

Tauri build correctly artifact

     Running candle for "main.wxs"
     Running light to produce D:\a\Sparus\Sparus\src-tauri\target\release\bundle/msi/sparus_0.1.0_x64_en-US.msi
    Finished 1 bundle at:
        D:\a\Sparus\Sparus\src-tauri\target\release\bundle/msi/sparus_0.1.0_x64_en-US.msi

When using softprops action-gh-release I get

Pattern 'D:\a\Sparus\Sparus\src-tauri\target\release\bundle\msi\sparus_0.1.0_x64_en-US.msi' does not match any files.
๐Ÿค” D:\a\Sparus\Sparus\src-tauri\target\release\bundle\msi\sparus_0.1.0_x64_en-US.msi not include valid file.

I don't know if it come from tauri-build or softprop action

Documentation: Issue with tagging

I had an issue running the yml in the readme. On running "publish", I got "Error: โš ๏ธ GitHub Releases requires a tag". Action-gh-release requires a pushed existing tag (specified by tag_name). I switched to ncipollo. For a tag, I just chose something random. I might have missed something, but I'll put this here in case someone has a better idea for updating the readme. Hopefully this unsticks some people :)

  • name: 'create release'
    uses: ncipollo/release-action@v1
    with:
    token: ${{ secrets.GITHUB_TOKEN }}
    tag: ${{ github.run_id }}-${{ github.run_attempt }}
    draft: false
    artifacts: ./artifacts/**/*

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • Update dependency typescript to v5.4.5
  • Update dependency @typescript-eslint/parser to v7
  • Update dependency eslint to v9
  • Update dependency eslint-plugin-github to v5
  • Update pnpm/action-setup action to v4
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codeql-analysis.yml
  • actions/checkout v4
  • github/codeql-action v3
  • github/codeql-action v3
  • github/codeql-action v3
.github/workflows/covector-status.yml
  • actions/checkout v4
.github/workflows/covector-version-or-publish.yml
  • actions/checkout v4
  • actions/setup-node v4.0.1
  • pnpm/action-setup v2.4.0
  • actions/cache v3
  • peter-evans/create-pull-request v5
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions-rs/toolchain v1
  • Swatinem/rust-cache v2
  • actions/upload-artifact v3
npm
package.json
  • @actions/core ^1.10.1
  • @tauri-apps/cli 1.5.11
  • @tauri-apps/cli-darwin-x64 1.5.11
  • @tauri-apps/cli-linux-x64-gnu 1.5.11
  • @tauri-apps/cli-win32-x64-msvc 1.5.11
  • string-argv ^0.3.2
  • tiny-glob ^0.2.9
  • @types/node 20.11.3
  • @typescript-eslint/parser 6.7.0
  • @vercel/ncc 0.38.1
  • eslint 8.49.0
  • eslint-plugin-github 4.10.1
  • js-yaml 4.1.0
  • prettier 3.0.3
  • typescript 5.3.3

  • Check this box to trigger a request for Renovate to run again on this repository

`tauri-build` can't find vite

Steps to reproduce

Run JonasKruckenberg/tauri-build@v1
  with:
    target: x86_6[4](https://github.com/dcl10/fastq-analyser-gui/runs/7771374183?check_suite_focus=true#step:6:4)-pc-windows-msvc
    debug: false
running builtin runner with args: build --target x8[6](https://github.com/dcl10/fastq-analyser-gui/runs/7771374183?check_suite_focus=true#step:6:7)_64-pc-windows-msvc
     Running beforeBuildCommand `npm run build`

> [email protected] build
> vite build

sh: vite: command not found

There are similar errors for the other two OS's as well.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.