|
| 1 | +name: "Publish APP" |
| 2 | + |
| 3 | +on: |
| 4 | + # release: |
| 5 | + # types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +# `tauri-action` can also upload app bundles to an existing GitHub release. |
| 9 | +# This workflow uses different actions to create and publish the release. |
| 10 | +# `tauri-action` will only build and upload the app bundles to the specified release. |
| 11 | + |
| 12 | +jobs: |
| 13 | + create-release: |
| 14 | + permissions: |
| 15 | + contents: write |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + release_id: ${{ steps.create-release.outputs.result }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: setup node |
| 24 | + uses: actions/setup-node@v4 |
| 25 | + with: |
| 26 | + node-version: lts/* |
| 27 | + |
| 28 | + - name: get version |
| 29 | + run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV |
| 30 | + |
| 31 | + - name: create release |
| 32 | + id: create-release |
| 33 | + uses: actions/github-script@v6 |
| 34 | + with: |
| 35 | + script: | |
| 36 | + const { data } = await github.rest.repos.createRelease({ |
| 37 | + owner: context.repo.owner, |
| 38 | + repo: context.repo.repo, |
| 39 | + tag_name: `app-v${process.env.PACKAGE_VERSION}`, |
| 40 | + name: `Desktop App v${process.env.PACKAGE_VERSION}`, |
| 41 | + body: 'Take a look at the assets to download and install this app.', |
| 42 | + draft: true, |
| 43 | + prerelease: false |
| 44 | + }) |
| 45 | + return data.id |
| 46 | +
|
| 47 | + build-tauri: |
| 48 | + needs: create-release |
| 49 | + permissions: |
| 50 | + contents: write |
| 51 | + strategy: |
| 52 | + fail-fast: false |
| 53 | + matrix: |
| 54 | + settings: |
| 55 | + - platform: "macos-latest" # for Arm based macs (M1 and above). |
| 56 | + args: "--target aarch64-apple-darwin" |
| 57 | + - platform: "macos-latest" # for Intel based macs. |
| 58 | + args: "--target x86_64-apple-darwin" |
| 59 | + - platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04. |
| 60 | + args: "" |
| 61 | + - platform: "windows-latest" |
| 62 | + args: "" |
| 63 | + |
| 64 | + runs-on: ${{ matrix.settings.platform }} |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + |
| 68 | + - name: Git submodule |
| 69 | + run: | |
| 70 | + git submodule update --init --recursive |
| 71 | +
|
| 72 | + - name: install Rust stable |
| 73 | + uses: dtolnay/rust-toolchain@stable |
| 74 | + with: |
| 75 | + # Those targets are only used on macos runners so it's in an `if` to slightly speed up windows and linux builds. |
| 76 | + targets: ${{ matrix.settings.platform == 'macos-latest' && 'aarch64-apple-darwin,x86_64-apple-darwin' || '' }} |
| 77 | + - name: install wasm32 |
| 78 | + uses: actions-rs/toolchain@v1 |
| 79 | + with: |
| 80 | + toolchain: stable |
| 81 | + target: wasm32-unknown-unknown |
| 82 | + |
| 83 | + - name: install dependencies (ubuntu only) |
| 84 | + if: matrix.settings.platform == 'ubuntu-22.04' # This must match the platform value defined above. |
| 85 | + run: | |
| 86 | + sudo apt-get update |
| 87 | + sudo apt-get install -y libwebkit2gtk-4.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf |
| 88 | + # webkitgtk 4.0 is for Tauri v1 - webkitgtk 4.1 is for Tauri v2. |
| 89 | + # You can remove the one that doesn't apply to your app to speed up the workflow a bit. |
| 90 | + - name: Install Trunk |
| 91 | + uses: jetli/trunk-action@v0.4.0 |
| 92 | + with: |
| 93 | + # Optional version of trunk to install(eg. 'v0.16.0', 'latest') |
| 94 | + version: "latest" |
| 95 | + - name: Install tauri-cli from crates.io |
| 96 | + uses: baptiste0928/cargo-install@v3 |
| 97 | + with: |
| 98 | + crate: tauri-cli |
| 99 | + version: "^2.0.0-beta.12" # You can specify any semver range |
| 100 | + - uses: tauri-apps/tauri-action@v0 |
| 101 | + env: |
| 102 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + with: |
| 104 | + tauriScript: cargo tauri |
| 105 | + releaseId: ${{ needs.create-release.outputs.release_id }} |
| 106 | + args: ${{ matrix.settings.args }} |
| 107 | + |
| 108 | + publish-release: |
| 109 | + permissions: |
| 110 | + contents: write |
| 111 | + runs-on: ubuntu-latest |
| 112 | + needs: [create-release, build-tauri] |
| 113 | + |
| 114 | + steps: |
| 115 | + - name: publish release |
| 116 | + id: publish-release |
| 117 | + uses: actions/github-script@v6 |
| 118 | + env: |
| 119 | + release_id: ${{ needs.create-release.outputs.release_id }} |
| 120 | + with: |
| 121 | + script: | |
| 122 | + github.rest.repos.updateRelease({ |
| 123 | + owner: context.repo.owner, |
| 124 | + repo: context.repo.repo, |
| 125 | + release_id: process.env.release_id, |
| 126 | + draft: false, |
| 127 | + prerelease: false |
| 128 | + }) |
0 commit comments