Skip to content

Build and Release Tauri App #93

Build and Release Tauri App

Build and Release Tauri App #93

Workflow file for this run

name: Build and Release Tauri App
on:
workflow_dispatch:
jobs:
build-tauri:
permissions:
contents: write
strategy:
fail-fast: false
matrix:
include:
- platform: 'macos-latest' # Universal build for both ARM and Intel Macs
args: '--target universal-apple-darwin'
os: 'macos'
- platform: 'ubuntu-22.04' # for Tauri v1 you could replace this with ubuntu-20.04
args: ''
os: 'linux'
- platform: 'windows-latest'
args: ''
os: 'windows'
- platform: 'windows-latest'
args: '--target i686-pc-windows-msvc'
suffix: 'windows'
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9.15.4
run_install: false
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
src-tauri/target/
C:\Users\runneradmin\.cargo\registry\index\
C:\Users\runneradmin\.cargo\registry\cache\
C:\Users\runneradmin\.cargo\git\db\
key: ${{ runner.os }}-${{ matrix.args }}-${{ hashFiles('Cargo.lock') }}
- name: Export variable (unix)
if: matrix.platform != 'windows-latest'
run: echo "TAURI_SIGNING_PRIVATE_KEY=${{ secrets.TAURI_PRIVATE_KEY }}" >> $GITHUB_ENV
- name: Export variable (windows)
if: matrix.platform == 'windows-latest'
run: echo "TAURI_SIGNING_PRIVATE_KEY=${{ secrets.TAURI_PRIVATE_KEY }}" >> $GITHUB_ENV
shell: bash
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
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' || matrix.platform == 'windows-latest' && 'i686-pc-windows-msvc,x86_64-pc-windows-msvc' || '' }}
- 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.0-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libssl-dev
# 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: Install frontend dependencies
run: |
pnpm install
- name: Import Apple code signing certificates
if: matrix.platform == 'macos-latest'
uses: apple-actions/import-codesign-certs@v3
with:
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
keychain: build
# Identity must match the .p12 exactly. Derive from the keychain after import so it cannot drift from the APPLE_SIGNING_IDENTITY secret (e.g. "Mac Developer ID..." vs "Developer ID ... (TEAM)").
- name: Set APPLE_SIGNING_IDENTITY from imported certificate
if: matrix.platform == 'macos-latest'
run: |
security find-identity -v -p codesigning
ID=$(security find-identity -v -p codesigning | grep "Developer ID Application" | head -1 | awk -F'"' '{print $2}')
if [ -z "$ID" ]; then
echo "No Developer ID Application identity found after import."
exit 1
fi
echo "APPLE_SIGNING_IDENTITY=$ID" >> "$GITHUB_ENV"
- uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
APPLE_SIGNING_IDENTITY: ${{ env.APPLE_SIGNING_IDENTITY }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
with:
tagName: app-v__VERSION__ # the action automatically replaces __VERSION__ with the app version.
appName: 'switch-shuttle_${{ matrix.os }}'
releaseName: 'Release v__VERSION__'
releaseBody: 'See the assets to download this version and install.'
releaseDraft: true
prerelease: false
args: ${{ matrix.args }}
includeUpdaterJson: true
updaterJsonPreferNsis: true
includeDebug: false
includeRelease: true