From b68582f505e822ea41374ef61fb194b167434cd4 Mon Sep 17 00:00:00 2001 From: James Rose <92864596+RoseBlume@users.noreply.github.com> Date: Mon, 17 Jun 2024 11:28:59 -0400 Subject: [PATCH 01/16] Create snapcraft.mdx --- src/content/docs/distribute/snapcraft.mdx | 140 ++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 src/content/docs/distribute/snapcraft.mdx diff --git a/src/content/docs/distribute/snapcraft.mdx b/src/content/docs/distribute/snapcraft.mdx new file mode 100644 index 0000000000..36d3d49cab --- /dev/null +++ b/src/content/docs/distribute/snapcraft.mdx @@ -0,0 +1,140 @@ +--- +title: Snapcraft +sidebar: + order: 1 +--- +# Prerequisites + +import { Tabs, TabItem, Card } from '@astrojs/starlight/components'; + +**1. Install snap** + + +```sh + sudo apt install snapd +``` + + +```sh +sudo pacman -S --needed git base-devel + git clone https://aur.archlinux.org/snapd.git + cd snapd + makepkg -si + sudo systemctl enable --now snapd.socket + sudo systemctl start snapd.socket + sudo systemctl enable --now snapd.apparmor.service +``` + + +```sh + sudo dnf install snapd + sudo ln -s /var/lib/snapd/snap /snap # Enables classic snap support + #Reboot your system after doing this +``` + + +**2. Installing Core** + +```sh + sudo snap install core22 +``` + +**3. Installing snapcraft** +```sh + sudo snap install snapcraft --classic +``` +1. Create an UbuntuOne account +2. Go to the [Snapcraft](https://snapcraft.io) website and register an App name +3. Create a snapcraft.yaml file in your projects root. +4. Adjust the names in the snapcraft.yaml file + +```yaml +name: app +base: core22 +version: '2.0.4' +summary: Your summary # 79 char long summary +description: | + Your Description + +grade: stable +confinement: strict + +apps: + app: + command: bin/app + desktop: usr/share/applications/app.desktop + +package-repositories: + - type: apt + components: [main] + suites: [noble] + key-id: 78E1918602959B9C59103100F1831DDAFC42E99D + url: http://ppa.launchpad.net/snappy-dev/snapcraft-daily/ubuntu + +parts: + prep: + plugin: dump + build-snaps: + - node/20/stable + - rustup/latest/stable + build-packages: + - libwebkit2gtk-4.1-dev + - build-essential + - curl + - wget + - file + - libxdo-dev + - libssl-dev + - libayatana-appindicator3-dev + - librsvg2-dev + - dpkg + stage-packages: + - libwebkit2gtk-4.1-0 + - libglu1-mesa + - libsoup-3.0-0 + - freeglut3 + source: . + override-pull: | + set -eu + craftctl default + rustup default nightly + npm install + npm run tauri build -- --bundles deb + dpkg -x src-tauri/target/release/bundle/deb/*.deb here + sed -i -e "s|Icon=app|Icon=/usr/share/icons/hicolor/32x32/apps/app.png|g" here/usr/share/applications/app.desktop + cp -r here/* . + organize: + usr/bin/app: bin/app +``` +// TODO: ADD EXPLANATION + +# Explanation +- The `name` variable defines the name of your app and is required to be set to the name that you have registered earlier. +- The `base`variable defines which core you are using. +- The `Version variable` defines the version, and should be updated with each change to the source repository. +- The `apps` section allows you to expose the desktop and binary files to allow the user to run your app +- The `package-repositories` section allows you to add a package repository to help you satisfy your dependencies. This is not required for Tauri V1. +- `build-packages`/`build-snaps` defines the build dependencies for your snap. +- `stage-packages`/`stage-snaps` defines the runtime dependencies for your snap. +- The `override-pull` section runs a series of commands before the sources are pulled. +- `craftctl default` performs the default pull commands. +- The `organize` section moves your files to the proper directories so that the binary and desktop file can be exposed to the `apps` sections +### Building +```sh +sudo snapcraft +``` + +### Testing +```sh +snap run your-app +``` +### Releasing Manually +```sh +snapcraft login # Login with your UbuntuOne credentials +snapcraft upload --release=stable mysnap_latest_amd64.snap +``` + +### Building automatically +1. On your apps developer page click on the `builds` tab +2. Click `login with github` +3. Enter in your repository's details. From b33612be9c5d294484fa4f1d5ec50da1f1ed7074 Mon Sep 17 00:00:00 2001 From: James Rose Date: Mon, 17 Jun 2024 11:35:22 -0400 Subject: [PATCH 02/16] Fixing --- src/content/docs/distribute/snapcraft.mdx | 41 +++++++++++------------ 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/src/content/docs/distribute/snapcraft.mdx b/src/content/docs/distribute/snapcraft.mdx index 36d3d49cab..c8c8806152 100644 --- a/src/content/docs/distribute/snapcraft.mdx +++ b/src/content/docs/distribute/snapcraft.mdx @@ -9,38 +9,38 @@ import { Tabs, TabItem, Card } from '@astrojs/starlight/components'; **1. Install snap** - -```sh + +```shell sudo apt install snapd ``` - + -```sh +```shell sudo pacman -S --needed git base-devel - git clone https://aur.archlinux.org/snapd.git - cd snapd - makepkg -si - sudo systemctl enable --now snapd.socket - sudo systemctl start snapd.socket - sudo systemctl enable --now snapd.apparmor.service +git clone https://aur.archlinux.org/snapd.git +cd snapd +makepkg -si +sudo systemctl enable --now snapd.socket +sudo systemctl start snapd.socket +sudo systemctl enable --now snapd.apparmor.service ``` - + -```sh - sudo dnf install snapd - sudo ln -s /var/lib/snapd/snap /snap # Enables classic snap support - #Reboot your system after doing this +```shell +sudo dnf install snapd +sudo ln -s /var/lib/snapd/snap /snap # Enables classic snap support +#Reboot your system after doing this ``` - + **2. Installing Core** -```sh +```shell sudo snap install core22 ``` **3. Installing snapcraft** -```sh +```shell sudo snap install snapcraft --classic ``` 1. Create an UbuntuOne account @@ -106,7 +106,6 @@ parts: organize: usr/bin/app: bin/app ``` -// TODO: ADD EXPLANATION # Explanation - The `name` variable defines the name of your app and is required to be set to the name that you have registered earlier. @@ -125,11 +124,11 @@ sudo snapcraft ``` ### Testing -```sh +```shell snap run your-app ``` ### Releasing Manually -```sh +```shell snapcraft login # Login with your UbuntuOne credentials snapcraft upload --release=stable mysnap_latest_amd64.snap ``` From d1dc05e7bb52624c12ddfc8176a636827bf25bcf Mon Sep 17 00:00:00 2001 From: James Rose Date: Mon, 17 Jun 2024 11:36:39 -0400 Subject: [PATCH 03/16] Fixing --- .prettierignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.prettierignore b/.prettierignore index 1ef59e430b..2f036c5234 100644 --- a/.prettierignore +++ b/.prettierignore @@ -29,4 +29,5 @@ src/content/docs/learn/Security/using-plugin-permissions.mdx src/content/docs/learn/Security/writing-plugin-permissions.mdx src/content/docs/start/frontend/qwik.mdx src/content/docs/zh-cn/start/frontend/qwik.mdx -src/content/docs/learn/splashscreen.mdx \ No newline at end of file +src/content/docs/learn/splashscreen.mdx +src/content/docs/distribute/snapcraft.mdx From 44bd57eb93aabf54b8da5a237bea7efad9699e0f Mon Sep 17 00:00:00 2001 From: James Rose <92864596+RoseBlume@users.noreply.github.com> Date: Mon, 17 Jun 2024 12:06:24 -0400 Subject: [PATCH 04/16] Update snapcraft.mdx --- src/content/docs/distribute/snapcraft.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/distribute/snapcraft.mdx b/src/content/docs/distribute/snapcraft.mdx index c8c8806152..d4a7d60219 100644 --- a/src/content/docs/distribute/snapcraft.mdx +++ b/src/content/docs/distribute/snapcraft.mdx @@ -112,7 +112,7 @@ parts: - The `base`variable defines which core you are using. - The `Version variable` defines the version, and should be updated with each change to the source repository. - The `apps` section allows you to expose the desktop and binary files to allow the user to run your app -- The `package-repositories` section allows you to add a package repository to help you satisfy your dependencies. This is not required for Tauri V1. +- The `package-repositories` section allows you to add a package repository to help you satisfy your dependencies. - `build-packages`/`build-snaps` defines the build dependencies for your snap. - `stage-packages`/`stage-snaps` defines the runtime dependencies for your snap. - The `override-pull` section runs a series of commands before the sources are pulled. From 0b95cd4ad69af7da5e554ce035f98876170cd7cf Mon Sep 17 00:00:00 2001 From: James Rose <92864596+RoseBlume@users.noreply.github.com> Date: Mon, 17 Jun 2024 12:21:27 -0400 Subject: [PATCH 05/16] Update snapcraft.mdx --- src/content/docs/distribute/snapcraft.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content/docs/distribute/snapcraft.mdx b/src/content/docs/distribute/snapcraft.mdx index d4a7d60219..a2663b77cc 100644 --- a/src/content/docs/distribute/snapcraft.mdx +++ b/src/content/docs/distribute/snapcraft.mdx @@ -33,6 +33,7 @@ sudo ln -s /var/lib/snapd/snap /snap # Enables classic snap support ``` + **2. Installing Core** ```shell From 0c1e15d2577ee988b3ee0f877a08052c6e4c66ae Mon Sep 17 00:00:00 2001 From: James Rose <92864596+RoseBlume@users.noreply.github.com> Date: Tue, 18 Jun 2024 19:51:24 -0400 Subject: [PATCH 06/16] Create actions.mdx --- src/content/docs/develop/actions.mdx | 154 +++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 src/content/docs/develop/actions.mdx diff --git a/src/content/docs/develop/actions.mdx b/src/content/docs/develop/actions.mdx new file mode 100644 index 0000000000..eec9e47389 --- /dev/null +++ b/src/content/docs/develop/actions.mdx @@ -0,0 +1,154 @@ +--- +title: Actions +sidebar: + order: 1 +--- + + +## Contents +- Cross platform compilation and automating releases +- Compiling for arm using [Pguyots](https://github.com/pguyot) arm-runner +- Compiling on self hosted runners + +### Basic Cross Platform Compilation + +```yaml +name: 'publish' + +on: + push: + branches: + - release + +jobs: + publish-tauri: + permissions: + contents: write + strategy: + fail-fast: false + matrix: + settings: + - platform: 'macos-latest' # for Arm based macs (M1 and above). + args: '--target aarch64-apple-darwin' + - platform: 'macos-latest' # for Intel based macs. + args: '--target x86_64-apple-darwin' + - platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04. + args: '' + - platform: 'windows-latest' + args: '' + + runs-on: ${{ matrix.settings.platform }} + steps: + - uses: actions/checkout@v4 + + - name: install dependencies (ubuntu only) + if: matrix.settings.platform == 'ubuntu-22.04' # This must match the platform value defined above. + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf + # webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2. + # You can remove the one that doesn't apply to your app to speed up the workflow a bit. + + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: 'yarn' # Set this to npm, yarn or pnpm. + + - name: install Rust stable + uses: dtolnay/rust-toolchain@stable # Set this to dtolnay/rust-toolchain@nightly + with: + # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. + targets: ${{ matrix.settings.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} + + - name: Rust cache + uses: swatinem/rust-cache@v2 + with: + workspaces: './src-tauri -> target' + + - name: install frontend dependencies + # If you don't have `beforeBuildCommand` configured you may want to build your frontend here too. + run: yarn install # change this to npm or pnpm depending on which one you use. + + - uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + 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 + args: ${{ matrix.settings.args }} +``` + +### Arm Runner Compilation +The process in which you cross compile is quite similar to version 1, however one small change is +that the base_image uses `Bookworm` instead of `Bullseye`. It is important to note that the `VERSION` variable must be adjusted to your version in `tauri.conf.json` each time you update. + +```yaml +name: Raspberry Pi compile +on: + workflow_dispatch: +env: + VERSION: 2.0.5 +jobs: + build: + strategy: + matrix: + arch: [aarch64, armv7l] + include: + - arch: aarch64 + cpu: cortex-a72 + base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv8-Bookworm.img.xz + deb: arm64 + other: aarch64 + - arch: armv7l + cpu: cortex-a53 + deb: armhf + other: arm + base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv7-Bookworm.img.xz + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: pguyot/arm-runner-action@v2.5.2 + with: + base_image: ${{ matrix.base_image }} + cpu: ${{ matrix.cpu }} + bind_mount_repository: true + image_additional_mb: 10240 + optimize_image: false + commands: | + # Rust complains (rightly) that $HOME doesn't match eid home + export HOME=/root + # Workaround to CI worker being stuck on Updating crates.io index + export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse + # Install setup prerequisites + apt-get update -y --allow-releaseinfo-change + apt-get autoremove -y + apt-get install -y curl npm libwebkit2gtk-4.1-dev build-essential libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly + . "$HOME/.cargo/env" + # curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash + # Install framework specific packages + sudo npm install --force -g npm@latest + sudo npm install --force -g nodejs@latest + # Install Rust Nightly + rustup default nightly # Only Enable for nightly builds + # Install frontend dependencies + npm install + # Build the application + npm run tauri build -- --bundles deb rpm + - name: Upload deb bundle + uses: actions/upload-artifact@v3 + with: + name: Debian Bundle + path: ${{ github.workspace }}/src-tauri/target/release/bundle/deb/Rosary_${{ env.VERSION }}_${{ matrix.deb }}.deb + + - name: Upload rpm bundle + uses: actions/upload-artifact@v3 + with: + name: RPM Bundle + path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/rosary_${{ env.VERSION }}_${{ matrix.other }}.rpm +``` + From ce8189ecf9db0922c691d63836a375aef420c9ed Mon Sep 17 00:00:00 2001 From: James Rose <92864596+RoseBlume@users.noreply.github.com> Date: Tue, 18 Jun 2024 21:15:29 -0400 Subject: [PATCH 07/16] Delete src/content/docs/distribute/snapcraft.mdx --- src/content/docs/distribute/snapcraft.mdx | 140 ---------------------- 1 file changed, 140 deletions(-) delete mode 100644 src/content/docs/distribute/snapcraft.mdx diff --git a/src/content/docs/distribute/snapcraft.mdx b/src/content/docs/distribute/snapcraft.mdx deleted file mode 100644 index a2663b77cc..0000000000 --- a/src/content/docs/distribute/snapcraft.mdx +++ /dev/null @@ -1,140 +0,0 @@ ---- -title: Snapcraft -sidebar: - order: 1 ---- -# Prerequisites - -import { Tabs, TabItem, Card } from '@astrojs/starlight/components'; - -**1. Install snap** - - -```shell - sudo apt install snapd -``` - - -```shell -sudo pacman -S --needed git base-devel -git clone https://aur.archlinux.org/snapd.git -cd snapd -makepkg -si -sudo systemctl enable --now snapd.socket -sudo systemctl start snapd.socket -sudo systemctl enable --now snapd.apparmor.service -``` - - -```shell -sudo dnf install snapd -sudo ln -s /var/lib/snapd/snap /snap # Enables classic snap support -#Reboot your system after doing this -``` - - - -**2. Installing Core** - -```shell - sudo snap install core22 -``` - -**3. Installing snapcraft** -```shell - sudo snap install snapcraft --classic -``` -1. Create an UbuntuOne account -2. Go to the [Snapcraft](https://snapcraft.io) website and register an App name -3. Create a snapcraft.yaml file in your projects root. -4. Adjust the names in the snapcraft.yaml file - -```yaml -name: app -base: core22 -version: '2.0.4' -summary: Your summary # 79 char long summary -description: | - Your Description - -grade: stable -confinement: strict - -apps: - app: - command: bin/app - desktop: usr/share/applications/app.desktop - -package-repositories: - - type: apt - components: [main] - suites: [noble] - key-id: 78E1918602959B9C59103100F1831DDAFC42E99D - url: http://ppa.launchpad.net/snappy-dev/snapcraft-daily/ubuntu - -parts: - prep: - plugin: dump - build-snaps: - - node/20/stable - - rustup/latest/stable - build-packages: - - libwebkit2gtk-4.1-dev - - build-essential - - curl - - wget - - file - - libxdo-dev - - libssl-dev - - libayatana-appindicator3-dev - - librsvg2-dev - - dpkg - stage-packages: - - libwebkit2gtk-4.1-0 - - libglu1-mesa - - libsoup-3.0-0 - - freeglut3 - source: . - override-pull: | - set -eu - craftctl default - rustup default nightly - npm install - npm run tauri build -- --bundles deb - dpkg -x src-tauri/target/release/bundle/deb/*.deb here - sed -i -e "s|Icon=app|Icon=/usr/share/icons/hicolor/32x32/apps/app.png|g" here/usr/share/applications/app.desktop - cp -r here/* . - organize: - usr/bin/app: bin/app -``` - -# Explanation -- The `name` variable defines the name of your app and is required to be set to the name that you have registered earlier. -- The `base`variable defines which core you are using. -- The `Version variable` defines the version, and should be updated with each change to the source repository. -- The `apps` section allows you to expose the desktop and binary files to allow the user to run your app -- The `package-repositories` section allows you to add a package repository to help you satisfy your dependencies. -- `build-packages`/`build-snaps` defines the build dependencies for your snap. -- `stage-packages`/`stage-snaps` defines the runtime dependencies for your snap. -- The `override-pull` section runs a series of commands before the sources are pulled. -- `craftctl default` performs the default pull commands. -- The `organize` section moves your files to the proper directories so that the binary and desktop file can be exposed to the `apps` sections -### Building -```sh -sudo snapcraft -``` - -### Testing -```shell -snap run your-app -``` -### Releasing Manually -```shell -snapcraft login # Login with your UbuntuOne credentials -snapcraft upload --release=stable mysnap_latest_amd64.snap -``` - -### Building automatically -1. On your apps developer page click on the `builds` tab -2. Click `login with github` -3. Enter in your repository's details. From 11f0035073ad7083e6892c30ac0a6c1ccb65a5e2 Mon Sep 17 00:00:00 2001 From: James Rose <92864596+RoseBlume@users.noreply.github.com> Date: Tue, 18 Jun 2024 23:01:03 -0400 Subject: [PATCH 08/16] Update actions.mdx --- src/content/docs/develop/actions.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/develop/actions.mdx b/src/content/docs/develop/actions.mdx index eec9e47389..96d2a6029f 100644 --- a/src/content/docs/develop/actions.mdx +++ b/src/content/docs/develop/actions.mdx @@ -149,6 +149,6 @@ jobs: uses: actions/upload-artifact@v3 with: name: RPM Bundle - path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/rosary_${{ env.VERSION }}_${{ matrix.other }}.rpm + path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/rosary_${{ env.VERSION }}-1_${{ matrix.other }}.rpm ``` From a905e6c0492a078fb45274beca731276bdd9fa60 Mon Sep 17 00:00:00 2001 From: James Rose <92864596+RoseBlume@users.noreply.github.com> Date: Tue, 18 Jun 2024 23:05:26 -0400 Subject: [PATCH 09/16] Update actions.mdx --- src/content/docs/develop/actions.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/docs/develop/actions.mdx b/src/content/docs/develop/actions.mdx index 96d2a6029f..fe1d27615f 100644 --- a/src/content/docs/develop/actions.mdx +++ b/src/content/docs/develop/actions.mdx @@ -105,7 +105,7 @@ jobs: other: aarch64 - arch: armv7l cpu: cortex-a53 - deb: armhf + deb: armhfp other: arm base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv7-Bookworm.img.xz runs-on: ubuntu-latest From a0c7a5b46b457893d176b0d9e639180d2d3b1f37 Mon Sep 17 00:00:00 2001 From: James Rose <92864596+RoseBlume@users.noreply.github.com> Date: Wed, 19 Jun 2024 04:41:43 -0400 Subject: [PATCH 10/16] Update .prettierignore --- .prettierignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.prettierignore b/.prettierignore index 2f036c5234..7006505cbc 100644 --- a/.prettierignore +++ b/.prettierignore @@ -31,3 +31,4 @@ src/content/docs/start/frontend/qwik.mdx src/content/docs/zh-cn/start/frontend/qwik.mdx src/content/docs/learn/splashscreen.mdx src/content/docs/distribute/snapcraft.mdx +src/content/docs/develop/actions.mdx From eead1bbbeeb8699f773b8c9767d05e9a89a11450 Mon Sep 17 00:00:00 2001 From: Breno A Date: Tue, 25 Jun 2024 04:02:25 -0300 Subject: [PATCH 11/16] fix: building with actions syntax --- src/content/docs/develop/actions.mdx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/content/docs/develop/actions.mdx b/src/content/docs/develop/actions.mdx index fe1d27615f..ef0ea554ac 100644 --- a/src/content/docs/develop/actions.mdx +++ b/src/content/docs/develop/actions.mdx @@ -27,7 +27,7 @@ jobs: strategy: fail-fast: false matrix: - settings: + include: - platform: 'macos-latest' # for Arm based macs (M1 and above). args: '--target aarch64-apple-darwin' - platform: 'macos-latest' # for Intel based macs. @@ -37,12 +37,12 @@ jobs: - platform: 'windows-latest' args: '' - runs-on: ${{ matrix.settings.platform }} + runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 - name: install dependencies (ubuntu only) - if: matrix.settings.platform == 'ubuntu-22.04' # This must match the platform value defined above. + if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above. run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf @@ -59,7 +59,7 @@ jobs: uses: dtolnay/rust-toolchain@stable # Set this to dtolnay/rust-toolchain@nightly with: # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. - targets: ${{ matrix.settings.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} + targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} - name: Rust cache uses: swatinem/rust-cache@v2 @@ -79,7 +79,7 @@ jobs: releaseBody: 'See the assets to download this version and install.' releaseDraft: true prerelease: false - args: ${{ matrix.settings.args }} + args: ${{ matrix.args }} ``` ### Arm Runner Compilation From 7e63d046a6da5973d850f7da568a1bbdb10f87c7 Mon Sep 17 00:00:00 2001 From: FabianLars Date: Mon, 1 Jul 2024 16:05:20 +0200 Subject: [PATCH 12/16] move to dist/pipelines --- .prettierignore | 1 - src/content/docs/develop/actions.mdx | 154 ------------------ .../docs/distribute/Pipelines/github.mdx | 153 ++++++++++++++++- 3 files changed, 148 insertions(+), 160 deletions(-) delete mode 100644 src/content/docs/develop/actions.mdx diff --git a/.prettierignore b/.prettierignore index 42e71955b5..35fc508a5e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -31,4 +31,3 @@ src/content/docs/learn/Security/writing-plugin-permissions.mdx src/content/docs/start/frontend/qwik.mdx src/content/docs/zh-cn/start/frontend/qwik.mdx src/content/docs/learn/splashscreen.mdx -src/content/docs/develop/actions.mdx diff --git a/src/content/docs/develop/actions.mdx b/src/content/docs/develop/actions.mdx deleted file mode 100644 index ef0ea554ac..0000000000 --- a/src/content/docs/develop/actions.mdx +++ /dev/null @@ -1,154 +0,0 @@ ---- -title: Actions -sidebar: - order: 1 ---- - - -## Contents -- Cross platform compilation and automating releases -- Compiling for arm using [Pguyots](https://github.com/pguyot) arm-runner -- Compiling on self hosted runners - -### Basic Cross Platform Compilation - -```yaml -name: 'publish' - -on: - push: - branches: - - release - -jobs: - publish-tauri: - permissions: - contents: write - strategy: - fail-fast: false - matrix: - include: - - platform: 'macos-latest' # for Arm based macs (M1 and above). - args: '--target aarch64-apple-darwin' - - platform: 'macos-latest' # for Intel based macs. - args: '--target x86_64-apple-darwin' - - platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04. - args: '' - - platform: 'windows-latest' - args: '' - - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v4 - - - name: install dependencies (ubuntu only) - if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above. - run: | - sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf - # webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2. - # You can remove the one that doesn't apply to your app to speed up the workflow a bit. - - - name: setup node - uses: actions/setup-node@v4 - with: - node-version: lts/* - cache: 'yarn' # Set this to npm, yarn or pnpm. - - - name: install Rust stable - uses: dtolnay/rust-toolchain@stable # Set this to dtolnay/rust-toolchain@nightly - with: - # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. - targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} - - - name: Rust cache - uses: swatinem/rust-cache@v2 - with: - workspaces: './src-tauri -> target' - - - name: install frontend dependencies - # If you don't have `beforeBuildCommand` configured you may want to build your frontend here too. - run: yarn install # change this to npm or pnpm depending on which one you use. - - - uses: tauri-apps/tauri-action@v0 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - 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 - args: ${{ matrix.args }} -``` - -### Arm Runner Compilation -The process in which you cross compile is quite similar to version 1, however one small change is -that the base_image uses `Bookworm` instead of `Bullseye`. It is important to note that the `VERSION` variable must be adjusted to your version in `tauri.conf.json` each time you update. - -```yaml -name: Raspberry Pi compile -on: - workflow_dispatch: -env: - VERSION: 2.0.5 -jobs: - build: - strategy: - matrix: - arch: [aarch64, armv7l] - include: - - arch: aarch64 - cpu: cortex-a72 - base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv8-Bookworm.img.xz - deb: arm64 - other: aarch64 - - arch: armv7l - cpu: cortex-a53 - deb: armhfp - other: arm - base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv7-Bookworm.img.xz - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: pguyot/arm-runner-action@v2.5.2 - with: - base_image: ${{ matrix.base_image }} - cpu: ${{ matrix.cpu }} - bind_mount_repository: true - image_additional_mb: 10240 - optimize_image: false - commands: | - # Rust complains (rightly) that $HOME doesn't match eid home - export HOME=/root - # Workaround to CI worker being stuck on Updating crates.io index - export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse - # Install setup prerequisites - apt-get update -y --allow-releaseinfo-change - apt-get autoremove -y - apt-get install -y curl npm libwebkit2gtk-4.1-dev build-essential libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly - . "$HOME/.cargo/env" - # curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - # Install framework specific packages - sudo npm install --force -g npm@latest - sudo npm install --force -g nodejs@latest - # Install Rust Nightly - rustup default nightly # Only Enable for nightly builds - # Install frontend dependencies - npm install - # Build the application - npm run tauri build -- --bundles deb rpm - - name: Upload deb bundle - uses: actions/upload-artifact@v3 - with: - name: Debian Bundle - path: ${{ github.workspace }}/src-tauri/target/release/bundle/deb/Rosary_${{ env.VERSION }}_${{ matrix.deb }}.deb - - - name: Upload rpm bundle - uses: actions/upload-artifact@v3 - with: - name: RPM Bundle - path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/rosary_${{ env.VERSION }}-1_${{ matrix.other }}.rpm -``` - diff --git a/src/content/docs/distribute/Pipelines/github.mdx b/src/content/docs/distribute/Pipelines/github.mdx index ed5eb12e0c..ef024d1e67 100644 --- a/src/content/docs/distribute/Pipelines/github.mdx +++ b/src/content/docs/distribute/Pipelines/github.mdx @@ -1,11 +1,154 @@ --- title: GitHub sidebar: - badge: - text: Stub - variant: caution + order: 1 --- -import Stub from '@components/Stub.astro'; +## Contents - +- Cross platform compilation and automating releases +- Compiling for arm using [Pguyots](https://github.com/pguyot) arm-runner +- Compiling on self hosted runners + +### Basic Cross Platform Compilation + +```yaml +name: 'publish' + +on: + push: + branches: + - release + +jobs: + publish-tauri: + permissions: + contents: write + strategy: + fail-fast: false + matrix: + include: + - platform: 'macos-latest' # for Arm based macs (M1 and above). + args: '--target aarch64-apple-darwin' + - platform: 'macos-latest' # for Intel based macs. + args: '--target x86_64-apple-darwin' + - platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04. + args: '' + - platform: 'windows-latest' + args: '' + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v4 + + - name: install dependencies (ubuntu only) + if: matrix.platform == 'ubuntu-22.04' # This must match the platform value defined above. + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf + # webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2. + # You can remove the one that doesn't apply to your app to speed up the workflow a bit. + + - name: setup node + uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: 'yarn' # Set this to npm, yarn or pnpm. + + - name: install Rust stable + uses: dtolnay/rust-toolchain@stable # Set this to dtolnay/rust-toolchain@nightly + with: + # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. + targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} + + - name: Rust cache + uses: swatinem/rust-cache@v2 + with: + workspaces: './src-tauri -> target' + + - name: install frontend dependencies + # If you don't have `beforeBuildCommand` configured you may want to build your frontend here too. + run: yarn install # change this to npm or pnpm depending on which one you use. + + - uses: tauri-apps/tauri-action@v0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + 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 + args: ${{ matrix.args }} +``` + +### Arm Runner Compilation + +The process in which you cross compile is quite similar to version 1, however one small change is +that the base_image uses `Bookworm` instead of `Bullseye`. It is important to note that the `VERSION` variable must be adjusted to your version in `tauri.conf.json` each time you update. + +```yaml +name: Raspberry Pi compile +on: + workflow_dispatch: +env: + VERSION: 2.0.5 +jobs: + build: + strategy: + matrix: + arch: [aarch64, armv7l] + include: + - arch: aarch64 + cpu: cortex-a72 + base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv8-Bookworm.img.xz + deb: arm64 + other: aarch64 + - arch: armv7l + cpu: cortex-a53 + deb: armhfp + other: arm + base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv7-Bookworm.img.xz + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: pguyot/arm-runner-action@v2.5.2 + with: + base_image: ${{ matrix.base_image }} + cpu: ${{ matrix.cpu }} + bind_mount_repository: true + image_additional_mb: 10240 + optimize_image: false + commands: | + # Rust complains (rightly) that $HOME doesn't match eid home + export HOME=/root + # Workaround to CI worker being stuck on Updating crates.io index + export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse + # Install setup prerequisites + apt-get update -y --allow-releaseinfo-change + apt-get autoremove -y + apt-get install -y curl npm libwebkit2gtk-4.1-dev build-essential libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev + curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly + . "$HOME/.cargo/env" + # curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash + # Install framework specific packages + sudo npm install --force -g npm@latest + sudo npm install --force -g nodejs@latest + # Install Rust Nightly + rustup default nightly # Only Enable for nightly builds + # Install frontend dependencies + npm install + # Build the application + npm run tauri build -- --bundles deb rpm + - name: Upload deb bundle + uses: actions/upload-artifact@v3 + with: + name: Debian Bundle + path: ${{ github.workspace }}/src-tauri/target/release/bundle/deb/Rosary_${{ env.VERSION }}_${{ matrix.deb }}.deb + + - name: Upload rpm bundle + uses: actions/upload-artifact@v3 + with: + name: RPM Bundle + path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/rosary_${{ env.VERSION }}-1_${{ matrix.other }}.rpm +``` From 937ed2c84367075d7cb83b593336e0af7fb577fa Mon Sep 17 00:00:00 2001 From: FabianLars Date: Mon, 1 Jul 2024 23:36:06 +0200 Subject: [PATCH 13/16] a few touchups - wip (trying to fix appimage builds) --- src/content/docs/develop/sidecar.mdx | 14 +- .../docs/distribute/Pipelines/github.mdx | 137 +++++++++++++----- src/content/docs/distribute/flatpak.mdx | 2 +- src/content/docs/guides/distribute/index.mdx | 24 --- 4 files changed, 110 insertions(+), 67 deletions(-) delete mode 100644 src/content/docs/guides/distribute/index.mdx diff --git a/src/content/docs/develop/sidecar.mdx b/src/content/docs/develop/sidecar.mdx index d1e13a6f79..5ca4556d3b 100644 --- a/src/content/docs/develop/sidecar.mdx +++ b/src/content/docs/develop/sidecar.mdx @@ -14,14 +14,12 @@ Here is a sample to illustrate the configuration. This is not a complete `tauri. ```json title="src-tauri/tauri.conf.json" { - "tauri": { - "bundle": { - "externalBin": [ - "/absolute/path/to/sidecar", - "relative/path/to/binary", - "binaries/my-sidecar" - ] - } + "bundle": { + "externalBin": [ + "/absolute/path/to/sidecar", + "relative/path/to/binary", + "binaries/my-sidecar" + ] } } ``` diff --git a/src/content/docs/distribute/Pipelines/github.mdx b/src/content/docs/distribute/Pipelines/github.mdx index ef024d1e67..fc717b9483 100644 --- a/src/content/docs/distribute/Pipelines/github.mdx +++ b/src/content/docs/distribute/Pipelines/github.mdx @@ -1,21 +1,20 @@ --- title: GitHub -sidebar: - order: 1 --- -## Contents +This guide will show you how to use [tauri-action](https://github.com/tauri-apps/tauri-action) in GitHub Actions to easily build and upload your app, and how to make Tauri's updater query the newly created GitHub release for updates. -- Cross platform compilation and automating releases -- Compiling for arm using [Pguyots](https://github.com/pguyot) arm-runner -- Compiling on self hosted runners +Lastly, it will also show how to set up a more complicated build pipeline for Linux Arm AppImages. -### Basic Cross Platform Compilation +{/* TODO: Migrate more of the v1 guide (explanations etc.) */} + +## Basic Cross Platform Compilation ```yaml name: 'publish' on: + workflow_dispatch: push: branches: - release @@ -32,7 +31,7 @@ jobs: args: '--target aarch64-apple-darwin' - platform: 'macos-latest' # for Intel based macs. args: '--target x86_64-apple-darwin' - - platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04. + - platform: 'ubuntu-22.04' args: '' - platform: 'windows-latest' args: '' @@ -46,8 +45,6 @@ jobs: run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf - # webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2. - # You can remove the one that doesn't apply to your app to speed up the workflow a bit. - name: setup node uses: actions/setup-node@v4 @@ -82,19 +79,29 @@ jobs: args: ${{ matrix.args }} ``` -### Arm Runner Compilation +For more configuration options, check out the [`tauri-action`](https://github.com/tauri-apps/tauri-action) repository and its [examples](https://github.com/tauri-apps/tauri-action/blob/dev/examples/). + +## Arm Runner Compilation -The process in which you cross compile is quite similar to version 1, however one small change is -that the base_image uses `Bookworm` instead of `Bullseye`. It is important to note that the `VERSION` variable must be adjusted to your version in `tauri.conf.json` each time you update. +This workflow uses [`arm-runner-action`](https://github.com/pguyot/arm-runner-action) to compile directly on an emulated Arm runner. This bridges the gap for missing cross-architecture build support in the AppImage tooling. + +:::danger +`arm-runner-action` is **much** slower than GitHub's standard runners, so be careful in private repositories where you're invoiced for build minutes. An uncached build for a fresh `create-tauri-app` project needs ~1 hour. +::: ```yaml -name: Raspberry Pi compile +name: 'publish Linux Arm builds' + on: workflow_dispatch: -env: - VERSION: 2.0.5 + push: + branches: + - release + jobs: build: + runs-on: ubuntu-22.04 + strategy: matrix: arch: [aarch64, armv7l] @@ -103,52 +110,114 @@ jobs: cpu: cortex-a72 base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv8-Bookworm.img.xz deb: arm64 - other: aarch64 + rpm: aarch64 + appimage: aarch64 - arch: armv7l cpu: cortex-a53 deb: armhfp - other: arm + rpm: arm + appimage: armhf base_image: https://dietpi.com/downloads/images/DietPi_RPi-ARMv7-Bookworm.img.xz - runs-on: ubuntu-latest + steps: - uses: actions/checkout@v3 - - uses: pguyot/arm-runner-action@v2.5.2 + + - name: Setup cache dir on /mnt + run: | + sudo mkdir /mnt/cache + WORKSPACE_OWNER="$(stat -c '%U:%G' "${GITHUB_WORKSPACE}")" + sudo chown -R "${WORKSPACE_OWNER}" /mnt/cache + + - name: Setup image cache + uses: actions/cache@v4 + id: cache + with: + path: /mnt/cache/cache.img + key: image-cache-${{ matrix.arch }}-1 + save-always: true + + - name: Setup image + uses: pguyot/arm-runner-action@v2.6.5 + id: install_deps + if: steps.cache.outputs.cache-hit != 'true' with: base_image: ${{ matrix.base_image }} cpu: ${{ matrix.cpu }} bind_mount_repository: true - image_additional_mb: 10240 - optimize_image: false + image_additional_mb: 4096 + optimize_image: no commands: | - # Rust complains (rightly) that $HOME doesn't match eid home + # Prevent Rust from complaining about $HOME not matching eid home export HOME=/root + # Workaround to CI worker being stuck on Updating crates.io index export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse + # Install setup prerequisites apt-get update -y --allow-releaseinfo-change apt-get autoremove -y - apt-get install -y curl npm libwebkit2gtk-4.1-dev build-essential libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly + apt-get install -y curl libwebkit2gtk-4.1-dev build-essential libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf libfuse2 + curl https://sh.rustup.rs -sSf | sh -s -- -y . "$HOME/.cargo/env" - # curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash - # Install framework specific packages - sudo npm install --force -g npm@latest - sudo npm install --force -g nodejs@latest - # Install Rust Nightly - rustup default nightly # Only Enable for nightly builds + curl -fsSL https://deb.nodesource.com/setup_lts.x | bash + apt-get install -y nodejs + + - name: Move and rename image with dependencies + if: steps.cache.outputs.cache-hit != 'true' + run: | + mv ${{ steps.install_deps.outputs.image }} /mnt/cache/cache.img + + - name: Cache rust build artifacts + uses: Swatinem/rust-cache@v2 + with: + workspaces: src-tauri + cache-on-failure: true + + - name: Build app + uses: pguyot/arm-runner-action@v2.6.5 + with: + base_image: file:///mnt/cache/cache.img + cpu: ${{ matrix.cpu }} + bind_mount_repository: true + image_additional_mb: 15360 + optimize_image: no + exit_on_fail: no + commands: | + # Prevent Rust from complaining about $HOME not matching eid home + export HOME=/root + + # Workaround to CI worker being stuck on Updating crates.io index + export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse + + . "$HOME/.cargo/env" + # Install frontend dependencies npm install + # Build the application - npm run tauri build -- --bundles deb rpm + npm run tauri build -- --verbose + + ls src-tauri/target/release/bundle/deb + ls src-tauri/target/release/bundle/rpm + ls src-tauri/target/release/bundle/appimage + + # TODO: Combine this with the basic workflow and upload the files to the Release. + # TODO: Read the version from tauri.conf.json - name: Upload deb bundle uses: actions/upload-artifact@v3 with: name: Debian Bundle - path: ${{ github.workspace }}/src-tauri/target/release/bundle/deb/Rosary_${{ env.VERSION }}_${{ matrix.deb }}.deb + path: ${{ github.workspace }}/src-tauri/target/release/bundle/deb/appname_0.0.0_${{ matrix.deb }}.deb - name: Upload rpm bundle uses: actions/upload-artifact@v3 with: name: RPM Bundle - path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/rosary_${{ env.VERSION }}-1_${{ matrix.other }}.rpm + path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/appname_0.0.0-1_${{ matrix.rpm }}.rpm + + - name: Upload appimage bundle + uses: actions/upload-artifact@v3 + with: + name: AppImage Bundle + path: ${{ github.workspace }}/src-tauri/target/release/bundle/appimage/appname_0.0.0-_${{ matrix.appimage }}.AppImage ``` diff --git a/src/content/docs/distribute/flatpak.mdx b/src/content/docs/distribute/flatpak.mdx index 4c51bda407..1d63397357 100644 --- a/src/content/docs/distribute/flatpak.mdx +++ b/src/content/docs/distribute/flatpak.mdx @@ -10,7 +10,7 @@ For detailed information on how Flatpak works, you can read [Building your first This guide assumes you want to distribute your Flatpak via [Flathub](https://flathub.org/), the most commonly used platform for Flatpak distribution. If you plan on using other platforms, please consult their documentation instead. -### Prerequisites +## Prerequisites To test your app inside the Flatpak runtime you can build the Flatpak locally first before uploading your app to Flathub. This can also be helpful if you want to quickly share development builds. diff --git a/src/content/docs/guides/distribute/index.mdx b/src/content/docs/guides/distribute/index.mdx deleted file mode 100644 index 6c1f93d0a9..0000000000 --- a/src/content/docs/guides/distribute/index.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: Distributing -description: Tips and tricks for your debugging workflow ---- - -import { LinkCard, CardGrid } from '@astrojs/starlight/components'; - - - - - -import Stub from '@components/Stub.astro'; - - - -- Distribution and Code Signing for... - - Linux - - macOS - - Windows - - Android `pnpm tauri [ios|android] build` - - iOS -- Updater (link to recipe) - - From 8d016063c94babdca09c336c0a1fd879c6d3397a Mon Sep 17 00:00:00 2001 From: FabianLars Date: Wed, 3 Jul 2024 15:29:51 +0200 Subject: [PATCH 14/16] fix workflow (gave up on image caching) --- .../docs/distribute/Pipelines/github.mdx | 63 +++---------------- 1 file changed, 10 insertions(+), 53 deletions(-) diff --git a/src/content/docs/distribute/Pipelines/github.mdx b/src/content/docs/distribute/Pipelines/github.mdx index fc717b9483..9c711c9b51 100644 --- a/src/content/docs/distribute/Pipelines/github.mdx +++ b/src/content/docs/distribute/Pipelines/github.mdx @@ -122,30 +122,21 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Setup cache dir on /mnt - run: | - sudo mkdir /mnt/cache - WORKSPACE_OWNER="$(stat -c '%U:%G' "${GITHUB_WORKSPACE}")" - sudo chown -R "${WORKSPACE_OWNER}" /mnt/cache - - - name: Setup image cache - uses: actions/cache@v4 - id: cache + - name: Cache rust build artifacts + uses: Swatinem/rust-cache@v2 with: - path: /mnt/cache/cache.img - key: image-cache-${{ matrix.arch }}-1 - save-always: true + workspaces: src-tauri + cache-on-failure: true - - name: Setup image + - name: Build app uses: pguyot/arm-runner-action@v2.6.5 - id: install_deps - if: steps.cache.outputs.cache-hit != 'true' with: base_image: ${{ matrix.base_image }} cpu: ${{ matrix.cpu }} bind_mount_repository: true - image_additional_mb: 4096 + image_additional_mb: 10240 optimize_image: no + #exit_on_fail: no commands: | # Prevent Rust from complaining about $HOME not matching eid home export HOME=/root @@ -156,53 +147,19 @@ jobs: # Install setup prerequisites apt-get update -y --allow-releaseinfo-change apt-get autoremove -y - apt-get install -y curl libwebkit2gtk-4.1-dev build-essential libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf libfuse2 + apt-get install -y --no-install-recommends --no-install-suggests curl libwebkit2gtk-4.1-dev build-essential libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev patchelf libfuse2 file curl https://sh.rustup.rs -sSf | sh -s -- -y . "$HOME/.cargo/env" curl -fsSL https://deb.nodesource.com/setup_lts.x | bash apt-get install -y nodejs - - name: Move and rename image with dependencies - if: steps.cache.outputs.cache-hit != 'true' - run: | - mv ${{ steps.install_deps.outputs.image }} /mnt/cache/cache.img - - - name: Cache rust build artifacts - uses: Swatinem/rust-cache@v2 - with: - workspaces: src-tauri - cache-on-failure: true - - - name: Build app - uses: pguyot/arm-runner-action@v2.6.5 - with: - base_image: file:///mnt/cache/cache.img - cpu: ${{ matrix.cpu }} - bind_mount_repository: true - image_additional_mb: 15360 - optimize_image: no - exit_on_fail: no - commands: | - # Prevent Rust from complaining about $HOME not matching eid home - export HOME=/root - - # Workaround to CI worker being stuck on Updating crates.io index - export CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse - - . "$HOME/.cargo/env" - # Install frontend dependencies npm install # Build the application npm run tauri build -- --verbose - ls src-tauri/target/release/bundle/deb - ls src-tauri/target/release/bundle/rpm - ls src-tauri/target/release/bundle/appimage - # TODO: Combine this with the basic workflow and upload the files to the Release. - # TODO: Read the version from tauri.conf.json - name: Upload deb bundle uses: actions/upload-artifact@v3 with: @@ -213,11 +170,11 @@ jobs: uses: actions/upload-artifact@v3 with: name: RPM Bundle - path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/appname_0.0.0-1_${{ matrix.rpm }}.rpm + path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/appname-0.0.0-1.${{ matrix.rpm }}.rpm - name: Upload appimage bundle uses: actions/upload-artifact@v3 with: name: AppImage Bundle - path: ${{ github.workspace }}/src-tauri/target/release/bundle/appimage/appname_0.0.0-_${{ matrix.appimage }}.AppImage + path: ${{ github.workspace }}/src-tauri/target/release/bundle/appimage/appname_0.0.0_${{ matrix.appimage }}.AppImage ``` From 0db8c424e53451adacc10815d6a7903fabdf597c Mon Sep 17 00:00:00 2001 From: FabianLars Date: Thu, 4 Jul 2024 17:10:17 +0200 Subject: [PATCH 15/16] port more v1 stuff --- .../docs/distribute/Pipelines/github.mdx | 89 +++++++++++++++++-- 1 file changed, 81 insertions(+), 8 deletions(-) diff --git a/src/content/docs/distribute/Pipelines/github.mdx b/src/content/docs/distribute/Pipelines/github.mdx index 9c711c9b51..59446c6415 100644 --- a/src/content/docs/distribute/Pipelines/github.mdx +++ b/src/content/docs/distribute/Pipelines/github.mdx @@ -2,13 +2,64 @@ title: GitHub --- -This guide will show you how to use [tauri-action](https://github.com/tauri-apps/tauri-action) in GitHub Actions to easily build and upload your app, and how to make Tauri's updater query the newly created GitHub release for updates. +This guide will show you how to use [tauri-action](https://github.com/tauri-apps/tauri-action) in [GitHub Actions](https://docs.github.com/en/actions) to easily build and upload your app, and how to make Tauri's updater query the newly created GitHub release for updates. Lastly, it will also show how to set up a more complicated build pipeline for Linux Arm AppImages. -{/* TODO: Migrate more of the v1 guide (explanations etc.) */} +:::note[Code Signing] -## Basic Cross Platform Compilation +To set up code signing for Windows and macOS in your workflow, follow the specific guide for each platform: + +- TODO: Windows Code Signing +- TODO: macOS Code Signing + +::: + +## Getting Started + +To set up `tauri-action` you must first set up a GitHub repository. You can also use this action on a repository that does not have Tauri configured yet since it can automatically initialize Tauri for you, please see the [action's readme](https://github.com/tauri-apps/tauri-action/#project-initialization) for necessary configuration options. + +Go to the Actions tab on your GitHub project page and select "New workflow", then choose "Set up a workflow yourself". Replace the file with the workflow from [below](#example-workflow) or from one of the [action's examples](https://github.com/tauri-apps/tauri-action/tree/dev/examples). + +## Configuration + +Please see the `tauri-action` [readme](https://github.com/tauri-apps/tauri-action/#inputs) for all available configuration options. + +When your app is not on the root of the repository, use the `projectPath` input. + +You may freely modify the worfklow name, change its triggers, and add more steps such as `npm run lint` or `npm run test`. The important part is that you keep the below line at the end of the workflow since this runs the build script and releases your app. + +### How to Trigger + +The release workflow shown below and in the `tauri-action` examples is triggered by pushed to the `release` branch. The action automatically creates a git tag and a title for the GitHub release using the application version. + +As another example, you can also change the trigger to run the workflow on the push of a version git tag such as `app-v0.7.0`: + +```yaml +name: 'publish' + +on: + push: + tags: + - 'app-v*' +``` + +For a full list of possible trigger configurations, check out the official [GitHub documentation](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows). + +## Example Workflow + +Below is an example workflow that has been set up to run every time you push to the `release` branch. + +This workflow will build and release your app for Linux x64, Windows x64, macOS x64 and macOS Arm64 (M1 and above). + +The steps this workflow takes are: + +1. Checkout the repository using `actions/checkout@v4`. +2. Install Linux system dependencies required to build the app. +3. Set up Node.js LTS and a cache for global npm/yarn/pnpm package data using `actions/setup-node@v4`. +4. Set up Rust and a cache for Rust's build artifacts using `dtolnay/rust-toolchain@stable` and `swatinem/rust-cache@v2`. +5. Install the frontend dependencies and, if not configured as [`beforeBuildCommand`](../../reference/config.md#beforebuildcommand), run the web app's build script. +6. Lastly, it uses `tauri-apps/tauri-action@v0` to run `tauri build`, generate the artifacts, and create a GitHub release. ```yaml name: 'publish' @@ -81,16 +132,22 @@ jobs: For more configuration options, check out the [`tauri-action`](https://github.com/tauri-apps/tauri-action) repository and its [examples](https://github.com/tauri-apps/tauri-action/blob/dev/examples/). +:::caution + +Carefully read through the [Usage limits, billing, and administration](https://docs.github.com/en/actions/learn-github-actions/usage-limits-billing-and-administration) documentation for GitHub Actions. + +::: + ## Arm Runner Compilation -This workflow uses [`arm-runner-action`](https://github.com/pguyot/arm-runner-action) to compile directly on an emulated Arm runner. This bridges the gap for missing cross-architecture build support in the AppImage tooling. +This workflow uses [`pguyot/arm-runner-action`](https://github.com/pguyot/arm-runner-action) to compile directly on an emulated Arm runner. This bridges the gap for missing cross-architecture build support in the AppImage tooling. :::danger `arm-runner-action` is **much** slower than GitHub's standard runners, so be careful in private repositories where you're invoiced for build minutes. An uncached build for a fresh `create-tauri-app` project needs ~1 hour. ::: ```yaml -name: 'publish Linux Arm builds' +name: 'Publish Linux Arm builds' on: workflow_dispatch: @@ -159,22 +216,38 @@ jobs: # Build the application npm run tauri build -- --verbose + - name: Get app version + run: echo "APP_VERSION=$(jq -r .version src-tauri/tauri.conf.json)" >> $GITHUB_ENV + # TODO: Combine this with the basic workflow and upload the files to the Release. - name: Upload deb bundle uses: actions/upload-artifact@v3 with: name: Debian Bundle - path: ${{ github.workspace }}/src-tauri/target/release/bundle/deb/appname_0.0.0_${{ matrix.deb }}.deb + path: ${{ github.workspace }}/src-tauri/target/release/bundle/deb/appname_${{ env.APP_VERSION }}_${{ matrix.deb }}.deb - name: Upload rpm bundle uses: actions/upload-artifact@v3 with: name: RPM Bundle - path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/appname-0.0.0-1.${{ matrix.rpm }}.rpm + path: ${{ github.workspace }}/src-tauri/target/release/bundle/rpm/appname-${{ env.APP_VERSION }}-1.${{ matrix.rpm }}.rpm - name: Upload appimage bundle uses: actions/upload-artifact@v3 with: name: AppImage Bundle - path: ${{ github.workspace }}/src-tauri/target/release/bundle/appimage/appname_0.0.0_${{ matrix.appimage }}.AppImage + path: ${{ github.workspace }}/src-tauri/target/release/bundle/appimage/appname_${{ env.APP_VERSION }}_${{ matrix.appimage }}.AppImage +``` + +## Troubleshooting + +### GitHub Environment Token + +The GitHub Token is automatically issued by GitHub for each workflow run without further configuration, which means there is no risk of secret leakage. This token however only has read permissions by default and you may get a "Resource not accessible by integration" error when running the workflow. If this happens, you may need to add write permissions to this token. To do this, go to your GitHub project settings, select `Actions`, scroll down to `Workflow permissions`, and check "Read and write permissions". + +You can see the GitHub Token being passed to the workflow via this line in the workflow: + +```yaml +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` From 29f77eeed8acd3b1972a2051183086d089e0ac62 Mon Sep 17 00:00:00 2001 From: FabianLars Date: Thu, 4 Jul 2024 17:14:29 +0200 Subject: [PATCH 16/16] fmt --- astro.config.mjs | 5 ++++- src/content/docs/distribute/rpm.mdx | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/astro.config.mjs b/astro.config.mjs index aa42e6544d..8778efdacc 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -123,7 +123,10 @@ export default defineConfig({ }, ], editLink: { - baseUrl: process.env.NODE_ENV === 'development' ? `vscode://file/${path.dirname(fileURLToPath(import.meta.url))}` : 'https://github.com/tauri-apps/tauri-docs/edit/v2', + baseUrl: + process.env.NODE_ENV === 'development' + ? `vscode://file/${path.dirname(fileURLToPath(import.meta.url))}` + : 'https://github.com/tauri-apps/tauri-docs/edit/v2', }, customCss: ['./src/styles/custom.scss'], expressiveCode: { diff --git a/src/content/docs/distribute/rpm.mdx b/src/content/docs/distribute/rpm.mdx index 99f0e33573..7272bad307 100644 --- a/src/content/docs/distribute/rpm.mdx +++ b/src/content/docs/distribute/rpm.mdx @@ -166,13 +166,14 @@ edition = "2021" license = "MIT" # add the license here # ... rest of the file ``` -And for `src-tauri/tauri.conf.json` + +And for `src-tauri/tauri.conf.json` ```json title="src-tauri/tauri.conf.json" { "bundle": { "licenseFile": "../LICENSE", // put the path to the license file here - "license": "MIT", // add the license here + "license": "MIT" // add the license here } } ```