Skip to content

Commit 360bb5f

Browse files
chore(gh-action): add text from readme (tauri-apps#218)
The front page links here and its currently rather empty.
1 parent 281e390 commit 360bb5f

File tree

1 file changed

+190
-1
lines changed

1 file changed

+190
-1
lines changed

docs/en/usage/ci-cd/cross-platform.md

Lines changed: 190 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,193 @@
22
title: Cross-Platform Compilation
33
---
44

5-
How to use GH Action for Building: a glance at Tauri Action.
5+
https://github.com/tauri-apps/tauri-action
6+
7+
# Tauri GitHub Action
8+
9+
The GitHub Action builds your Web application as a Tauri native binary for MacOS, Linux and Windows.
10+
If your project doesn't include the Tauri files, we create it at compile time, so if you don't need to use Tauri's API, you can just ship native apps through this Action.
11+
12+
# Usage
13+
14+
This GitHub Action has three main usages: test the build pipeline of your Tauri app, uploading Tauri artifacts to an existing release, and creating a new release with the Tauri artifacts.
15+
16+
## Testing the Build
17+
18+
```yml
19+
name: "test-on-pr"
20+
on: [pull_request]
21+
22+
jobs:
23+
test-tauri:
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
platform: [macos-latest, ubuntu-latest, windows-latest]
28+
29+
runs-on: ${{ matrix.platform }}
30+
steps:
31+
- uses: actions/checkout@v2
32+
- name: setup node
33+
uses: actions/setup-node@v1
34+
with:
35+
node-version: 12
36+
- name: install Rust stable
37+
uses: actions-rs/toolchain@v1
38+
with:
39+
toolchain: stable
40+
- name: install webkit2gtk (ubuntu only)
41+
if: matrix.platform == 'ubuntu-latest'
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y webkit2gtk-4.0
45+
- name: install app dependencies and build it
46+
run: yarn && yarn build
47+
- uses: tauri-apps/tauri-action@v0
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
```
51+
52+
## Creating a release and uploading the Tauri bundles
53+
54+
```yml
55+
name: "publish"
56+
on:
57+
push:
58+
branches:
59+
- release
60+
61+
jobs:
62+
publish-tauri:
63+
strategy:
64+
fail-fast: false
65+
matrix:
66+
platform: [macos-latest, ubuntu-latest, windows-latest]
67+
68+
runs-on: ${{ matrix.platform }}
69+
steps:
70+
- uses: actions/checkout@v2
71+
- name: setup node
72+
uses: actions/setup-node@v1
73+
with:
74+
node-version: 12
75+
- name: install Rust stable
76+
uses: actions-rs/toolchain@v1
77+
with:
78+
toolchain: stable
79+
- name: install webkit2gtk (ubuntu only)
80+
if: matrix.platform == 'ubuntu-latest'
81+
run: |
82+
sudo apt-get update
83+
sudo apt-get install -y webkit2gtk-4.0
84+
- name: install app dependencies and build it
85+
run: yarn && yarn build
86+
- uses: tauri-apps/tauri-action@v0
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
with:
90+
tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
91+
releaseName: "App v__VERSION__"
92+
body: "See the assets to download this version and install."
93+
draft: true
94+
prerelease: false
95+
```
96+
97+
## Uploading the artifacts to a release
98+
99+
Note that `actions/create-release` isn't maintained so you should find an alternative or let the Tauri Action handle the release.
100+
101+
```yml
102+
name: "test-on-pr"
103+
on: [pull_request]
104+
105+
jobs:
106+
create-release:
107+
runs-on: ubuntu-latest
108+
outputs:
109+
RELEASE_UPLOAD_ID: ${{ steps.create_release.outputs.id }}
110+
111+
steps:
112+
- uses: actions/checkout@v2
113+
- name: setup node
114+
uses: actions/setup-node@v1
115+
with:
116+
node-version: 12
117+
- name: get version
118+
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
119+
- name: create release
120+
id: create_release
121+
uses: actions/[email protected]
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
with:
125+
tag_name: app-v${{ env.PACKAGE_VERSION }}
126+
release_name: "Desktop app v${{ env.PACKAGE_VERSION }}"
127+
body: "See the assets to download this version and install."
128+
draft: true
129+
prerelease: false
130+
build-tauri:
131+
needs: create-release
132+
strategy:
133+
fail-fast: false
134+
matrix:
135+
platform: [macos-latest, ubuntu-latest, windows-latest]
136+
137+
runs-on: ${{ matrix.platform }}
138+
steps:
139+
- uses: actions/checkout@v2
140+
- name: setup node
141+
uses: actions/setup-node@v1
142+
with:
143+
node-version: 12
144+
- name: install Rust stable
145+
uses: actions-rs/toolchain@v1
146+
with:
147+
toolchain: stable
148+
- name: install webkit2gtk (ubuntu only)
149+
if: matrix.platform == 'ubuntu-latest'
150+
run: |
151+
sudo apt-get update
152+
sudo apt-get install -y webkit2gtk-4.0
153+
- name: install app dependencies and build it
154+
run: yarn && yarn build
155+
- uses: tauri-apps/tauri-action@v0
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158+
with:
159+
releaseId: ${{ needs.create-release.outputs.RELEASE_UPLOAD_ID }}
160+
```
161+
162+
## Inputs
163+
164+
| Name | Required | Description | Type | Default |
165+
| ------------------ | :------: | ------------------------------------------------------------------------------------------- | ------ | --------------------- |
166+
| `projectPath` | false | Path to the root of the project that will be built | string | . |
167+
| `configPath` | false | Path to the tauri.conf.json file if you want a configuration different from the default one | string | tauri.conf.json |
168+
| `distPath` | false | Path to the distributable folder with your index.html and JS/CSS | string | |
169+
| `releaseId` | false | The id of the release to upload artifacts as release assets | string | |
170+
| `tagName` | false | The tag name of the release to create | string | |
171+
| `releaseName` | false | The name of the release to create | string | |
172+
| `releaseBody` | false | The body of the release to create | string | |
173+
| `releaseDraft` | false | Whether the release to create is a draft or not | bool | false |
174+
| `prerelease` | false | Whether the release to create is a prerelease or not | bool | false |
175+
| `releaseCommitish` | false | Any branch or commit SHA the Git tag is created from, unused if the Git tag already exists | string | SHA of current commit |
176+
| `iconPath` | false | path to the PNG icon to use as app icon, relative to the projectPath | string | |
177+
| `includeDebug` | false | whether to include a debug build or not | bool | |
178+
| `npmScript` | false | the package.json script to run to build the Tauri app | string | |
179+
180+
## Outputs
181+
182+
| Name | Description |
183+
| ------------------ | ------------------------------------------------------------------ |
184+
| `releaseId` | The ID of the created release |
185+
| `releaseHtmlUrl` | The URL users can navigate to in order to view the created release |
186+
| `releaseUploadUrl` | The URL for uploading assets to the created release |
187+
188+
# Caveats
189+
190+
- You can use this Action on a repo that doesn't have Tauri configured. We automatically initialize Tauri before building, and configure it to use your Web artifacts.
191+
- You can configure Tauri with the `configPath`, `distPath` and `iconPath` options.
192+
- You can run custom NPM scripts with the `npmScript` option. So instead of running `yarn tauri build` or `npx tauri build`, we'll execute `yarn ${npmScript}`.
193+
- Useful when you need custom build functionality when creating Tauri apps e.g. a `desktop:build` script.
194+
- When your app isn't on the root of the repo, use the `projectPath` input.

0 commit comments

Comments
 (0)