#Prod Ready Github Action

22 messages · Page 1 of 1 (latest)

steep sorrel
#

Looking to produce my first Tauri App and I want to create a solid Github action. Using @quaint ridge template I have this current yml. I'm only building for mac and windows.

Current Action:

name: "prod-release"
on:
  pull_request:
    branches:
      - master

jobs:
  publish-tauri:
    strategy:
      fail-fast: false
      matrix:
        platform: [macos-latest, windows-latest]

    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v3
      - uses: pnpm/action-setup@v2.2.4
        with:
          version: 7.14.1
      - name: setup node
        uses: actions/setup-node@v3
        with:
          node-version: 16
      - name: install Rust stable
        uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
      - name: install app dependencies and build it
        run: pnpm i && pnpm build
      - uses: tauri-apps/tauri-action@v0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          VITE_GRAPHQL_ENDPOINT_CLOUD: ""
          VITE_REFRESH_ENDPOINT_CLOUD: ""
        with:
          tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
          releaseName: "App v__VERSION__"
          releaseBody: "See the assets to download this version and install."
          releaseDraft: true
          prerelease: false

what are some good ways to improve this? And ideally test before using on Github

quaint ridge
#

if you have configured beforeBuildCommand to build your frontend you can remove pnpm build, saving some seconds

#

other than that i guess there is not much to improve, depending on your goals ig.

sure you could remove the node and rust installations and trust that the runner has always a version installed you wanna use (which tbf is highly likely, and the actions should basically just skip the installation if that's the case)

if you want to always have the latest pnpm minor/patch version you can change it to version: 7.x.x but ofc that needs you to trust the pnpm guys to not push broken updates.

and depending on how regular you build the app using https://github.com/Swatinem/rust-cache could be cool. If you're building less often than every 7 days it's just wasting execution time tho

#

oh and the pull_request trigger seems to be a bit weird for a release action 🤔

steep sorrel
quaint ridge
#

good choice

steep sorrel
#

Is there a way to push the release zip to cloud storage. Say S3?

quaint ridge
#

yeah. there should be some helper action on the marketplace

#

for example i use an ftp action (on windows) and a rsync+ssh action (linux/macos) to push them on my own server

#

and using tauri-apps/tauri-action@dev it would even output all the generated file paths for you if you don't wanna hardcode them (it may end up a bit uglier than doing it manually tho - array of file paths vs a single dir path, if the actions support the latter)

steep sorrel
#

is it really possible to only use one runner like what @low gale was suggesting? I thought native OS binaries were required for all platforms

quaint ridge
#

no idea what exactly they meant, but generelly no. WiX (the current .msi bundler on windows) can only run on windows, and setting up wine for that seems not worth it / more complicated.
macos currently is not easy to compile on linux either, at least the bundled apps - the binary itself may be possible (but basically useless)

low gale
quaint ridge
#

yeah that should actually work for the windows binary. i'll write a guide for 1.3 for the new nsis target i added linux support for

#

ah actually, it will work in the future. There are some issues with tauri-build in 1.2 on non-windows hosts

low gale
#

If i am bundling the entire thing using tauri - i indeed use the matrix keys and something like this:

#
name: "tauri-build"
on:
  push:
    branches: [main]
    paths-ignore:
      - "*.md"
env:
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

jobs:
  build:
    defaults:
      run:
        working-directory: app
    strategy:
      fail-fast: false
      matrix:
        node-version: [16.x]
        platform: [windows-latest, macos-latest, ubuntu-latest]
    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v2
        with:
          token: ${{ env.GITHUB_TOKEN }}
      - name: use Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node-version }}
      - 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
          npm install -g typescript 
          yarn && yarn build
      - name: install dependencies (macos only)
        if: matrix.platform == 'macos-latest'
        run: |
          npm install -g typescript 
          yarn && yarn build
      - name: install dependencies (windows only)
        if: matrix.platform == 'windows-latest'
        run: |
          npm install -g typescript
          yarn && yarn build
      - name: Build
        uses: tauri-apps/tauri-action@v0
        with:
          tagName: appname-v__VERSION__
          releaseName: "app name v__VERSION__" # name of the release
          releaseBody: "some message" # message to include in the release
          releaseDraft: true # set to false to publish the release as a finished product
          prerelease: false # set to true to mark the release as a pre-release
#

then, for each os, just configure it accordingly. Typically though, i like bundling my own installers.

steep sorrel
#

so I have a SQLX database here and it threw an env variable error on dispatch. is this the correct way to handle setting env variables? Windows and Mac both want slightly different syntax and I've checked that they both work.


      - name: install app dependencies and build it (macos only)
        if: matrix.platform == "macos-latest"
        env:   
          DATABASE_URL: "sqlite:../src-tauri/resources/sqlite-internal.db"
        run: pnpm i && pnpm build

      - name: install app dependencies and build it (windows only)
        if: matrix.platform == "windows-latest"
        env:   
          DATABASE_URL: "sqlite://../src-tauri/resources/sqlite-internal.db"
        run: pnpm i && pnpm build
quaint ridge
#

shouldn't sqlite:// work on all platforms? iirc we use that for all platforms in the sql plugin and haven't heard any complains about that

#

other than that, yes you can set the env vars like that, but it's on the wrong step. this step only installs and builds your frontend, nothing related to rust

steep sorrel