### Usage examples for getTargetInfo Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Examples showing how getTargetInfo behaves with and without a target path argument. ```typescript const info1 = getTargetInfo(); // → { arch: "arm64", platform: "macos" } (on Apple Silicon macOS) const info2 = getTargetInfo('aarch64-apple-darwin'); // → { arch: "aarch64", platform: "macos" } const info3 = getTargetInfo('x86_64-unknown-linux-gnu'); // → { arch: "x86_64", platform: "linux" } ``` -------------------------------- ### Usage Example for getInfo Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Demonstrates how to invoke getInfo with target platform information and optional configuration overrides. ```typescript const info = getInfo( { arch: 'aarch64', platform: 'macos' }, ['config/prod.json5'] ); console.log(`${info.name} v${info.version} for ${info.targetPlatform}-${info.arch}`); ``` -------------------------------- ### Example Usage of getOrCreateRelease Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/release-management.md Demonstrates how to invoke the function to create or retrieve a release and access its properties. ```typescript import { getOrCreateRelease } from './create-release'; const release = await getOrCreateRelease( 'v1.2.3', 'Version 1.2.3', '## Release Notes\n\nBug fixes and improvements.' ); console.log(`Release ID: ${release.id}`); console.log(`View at: ${release.htmlUrl}`); console.log(`Upload to: ${release.uploadUrl}`); ``` -------------------------------- ### uploadVersionJSON Usage Example Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/release-management.md Demonstrates how to invoke uploadVersionJSON after building project artifacts and retrieving application info. ```typescript import { uploadVersionJSON } from './upload-version-json'; import { buildProject } from './build'; import { getInfo } from './utils'; const artifacts = await buildProject(); const info = getInfo(targetInfo, configArgs); await uploadVersionJSON( '1.2.3', '## v1.2.3\n\nBug fixes and improvements.', releaseId, artifacts, info, true ); ``` -------------------------------- ### Command Execution Usage Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Demonstrates invoking npm install and tauri build commands with specific working directories and environment variables. ```typescript import { execCommand } from './utils'; await execCommand('npm', ['install'], { cwd: '/path/to/project' }); await execCommand('tauri', ['build'], undefined, { RUST_LOG: 'debug' }); ``` -------------------------------- ### Execute a Tauri build command Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/runner.md Example of initializing a Runner with npm and executing a build command with specific options and retry attempts. ```typescript import { Runner } from './runner'; const runner = new Runner('npm', ['run', 'tauri']); await runner.execTauriCommand( ['build'], ['--target', 'x86_64-unknown-linux-gnu'], '/path/to/project', undefined, 3 ); ``` -------------------------------- ### Detect environment and execute command Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/runner.md Example of using the getRunner factory to automatically detect the environment and execute a build command. ```typescript import { getRunner } from './runner'; const runner = await getRunner(); await runner.execTauriCommand(['build'], [], process.cwd(), undefined, 2); ``` -------------------------------- ### Create an Artifact Instance Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Example usage of the createArtifact function to generate an artifact object. ```typescript import { createArtifact } from './utils'; const artifact = createArtifact({ info: { name: 'MyApp', version: '1.0.0', mainBinaryName: 'myapp', targetPlatform: 'macos', // ... }, path: '/build/target/release/bundle/dmg/MyApp_1.0.0_aarch64.dmg', arch: 'aarch64', bundle: 'dmg', }); ``` -------------------------------- ### Execute buildProject and process artifacts Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/build.md Example usage of buildProject to trigger a build and iterate through the resulting artifact metadata. ```typescript import { buildProject } from './build'; async function release() { try { const artifacts = await buildProject(); console.log(`Built ${artifacts.length} artifacts:`); artifacts.forEach(a => { console.log(` ${a.name} v${a.version} (${a.platform}-${a.arch}): ${a.path}`); }); } catch (error) { console.error('Build failed:', error.message); } } release(); ``` -------------------------------- ### View parsedArgs structure Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/inputs.md Example of how command-line arguments are parsed into a record, including handling of multiple config values. ```typescript // Input: "--target aarch64-apple-darwin -c config1.json -c config2.json --release" // parsedArgs: { // target: "aarch64-apple-darwin", // config: ["config1.json", "config2.json"], // debug: false // not present, so default false // } ``` -------------------------------- ### Get target platform and architecture Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Determines the target platform and architecture from CLI arguments or the current environment. ```typescript function getTargetInfo(targetPath?: string): TargetInfo ``` -------------------------------- ### Visualize Module Dependency Graph Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/INDEX.md Displays the hierarchical structure of the project's TypeScript modules starting from the entry point. ```text index.ts (entry point) ├─ build.ts │ ├─ runner.ts │ │ └─ utils.ts │ └─ utils.ts ├─ create-release.ts ├─ upload-release-assets.ts │ └─ utils.ts ├─ upload-version-json.ts │ ├─ utils.ts │ └─ upload-release-assets.ts ├─ upload-workflow-artifacts.ts │ └─ utils.ts ├─ inputs.ts (module constants) └─ utils.ts Supporting modules: config.ts (no dependencies on other src/ modules) types.d.ts (pure type definitions) ``` -------------------------------- ### Artifact Interface Definition Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/types.md Defines the structure for built binaries and installers, including platform, architecture, and path metadata. ```typescript interface Artifact { name: string; mainBinaryName: string; mode: 'debug' | 'release'; platform: Exclude | 'darwin'; arch: string; bundle: string; ext: string; version: string; setup: '-setup' | ''; _setup: '_setup' | ''; path: string; workflowArtifactName?: string; } ``` -------------------------------- ### Get or Create Release Function Signature Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/release-management.md Defines the interface for retrieving or creating a GitHub release. ```typescript async function getOrCreateRelease( tagName: string, releaseName?: string, body?: string ): Promise ``` -------------------------------- ### Get Tauri Directory Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Locates the Tauri project directory by searching for configuration files while ignoring specific directories. ```typescript function getTauriDir(): string | null ``` -------------------------------- ### View rawArgs parsing result Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/inputs.md Example of how shell-aware parsing splits input strings into an array of arguments. ```typescript // Input: "--target aarch64-apple-darwin --features updater" // rawArgs: ["--target", "aarch64-apple-darwin", "--features", "updater"] ``` -------------------------------- ### Render Naming Pattern Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Defines the function signature for pattern rendering and provides an example of substituting placeholders. ```typescript function renderNamePattern( pattern: string, replacements: Record ): string ``` ```typescript const pattern = 'MyApp-[version]_[platform]_[arch][ext]'; const rendered = renderNamePattern(pattern, { version: '1.0.0', platform: 'macos', arch: 'aarch64', ext: '.dmg', }); // → "MyApp-1.0.0_macos_aarch64.dmg" ``` -------------------------------- ### Get Cargo Manifest Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Parses a Cargo.toml file and resolves workspace-inherited package values. ```typescript function getCargoManifest(dir: string): CargoManifest ``` ```typescript interface CargoManifest { workspace?: { package?: { version?: string; name?: string } }; package: { version: string; name: string; 'default-run': string }; bin: Array<{ name: string }>; } ``` -------------------------------- ### Get Target Directory Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Calculates the absolute path to the Cargo build target directory based on environment variables and configuration files. ```typescript function getTargetDir( workspacePath: string, tauriPath: string, targetArgSet: boolean ): string ``` ```typescript const targetDir = getTargetDir( '/path/to/workspace', '/path/to/workspace/src-tauri', false ); // → "/path/to/workspace/target/x86_64-unknown-linux-gnu" or similar ``` -------------------------------- ### Invoke uploadWorkflowArtifacts Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/release-management.md Example usage of the uploadWorkflowArtifacts function within a workflow context. ```typescript import { uploadWorkflowArtifacts } from './upload-workflow-artifacts'; await uploadWorkflowArtifacts(artifacts); console.log('Workflow artifacts uploaded.'); ``` -------------------------------- ### constructor(identifier: string) Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/tauri-config.md Initializes a new instance of the TauriConfig class with a required bundle identifier. ```APIDOC ## constructor(identifier: string) ### Description Initializes a new instance of the TauriConfig class with a required bundle identifier. ### Parameters - **identifier** (string) - Required - Bundle identifier for the Tauri app ``` -------------------------------- ### Module Execution Entry Point Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/entry-point.md The action executes immediately upon import of the main module. ```typescript await run(); ``` -------------------------------- ### Create or Update Release Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/README.md Initializes or retrieves an existing GitHub release. ```typescript import { getOrCreateRelease } from './create-release'; const release = await getOrCreateRelease('v1.0.0', 'Release v1.0.0'); ``` -------------------------------- ### Configure .cargo/config.toml Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/configuration.md Cargo build configuration for custom targets and directories. ```toml [build] target = "x86_64-unknown-linux-gnu" target-dir = "custom-target" ``` -------------------------------- ### GitHub Action Configuration Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/entry-point.md Defines the runtime environment and entry point for the GitHub Action. ```yaml runs: using: 'node24' main: 'dist/index.js' ``` -------------------------------- ### Configure Command-Line Arguments Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/configuration.md Use the args input to pass complex shell arguments as a string. The action uses string-argv for parsing. ```yaml # Single argument args: '--release' # Multiple arguments args: '--target aarch64-unknown-linux-gnu --features updater' # Config flag with path args: '--config ./config/prod.json5' # Complex quoted strings args: '--config "{ productName: \"My App\" }"' ``` -------------------------------- ### Get Workspace Directory Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Finds the root of a Cargo workspace by traversing directory trees for workspace membership. ```typescript function getWorkspaceDir(dir: string): string | null ``` -------------------------------- ### Visualize the GitHub Action execution flow Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/architecture.md A high-level representation of the build, packaging, and release process triggered by the GitHub workflow. ```text GitHub Workflow Trigger ↓ [entry-point.ts] run() ↓ [build.ts] buildProject() ├─ [runner.ts] getRunner() ├─ Invoke Tauri CLI └─ Scan and create Artifacts ↓ Validate artifacts exist ↓ macOS-only: Tar .app directories ↓ [upload-workflow-artifacts.ts] (optional) ↓ [create-release.ts] getOrCreateRelease() ↓ [upload-release-assets.ts] uploadAssets() ↓ [upload-version-json.ts] uploadVersionJSON() ↓ Set GitHub Actions outputs ↓ Success or error report via core.setFailed() ``` -------------------------------- ### TauriConfig.fromBaseConfig Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/tauri-config.md Detects and loads the base Tauri configuration file from the specified directory. ```APIDOC ## static fromBaseConfig(tauriDir: string) ### Description Detects and loads the base Tauri configuration file (JSON, JSON5, or TOML) from the provided directory. ### Parameters - **tauriDir** (string) - Required - Directory containing the Tauri configuration. ### Return Type - **TauriConfig** - An initialized configuration instance. ### Search Order 1. tauri.conf.json 2. tauri.conf.json5 3. Tauri.toml ``` -------------------------------- ### execCommand(command, args, options, env) Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Executes an external command with support for environment variables, working directory configuration, and output streaming. ```APIDOC ## execCommand ### Description Executes an external command with environment variables and output streaming. It automatically sets `FORCE_COLOR: '0'` to disable colored output and merges provided environment variables with the base process environment. ### Signature `async function execCommand(command: string, args: string[], { cwd }?: { cwd?: string }, env?: Record): Promise` ### Parameters - **command** (string) - Required - Executable name or path - **args** (string[]) - Required - Command-line arguments - **cwd** (string) - Optional - Working directory for execution - **env** (Record) - Optional - Environment variables to pass ### Throws - `Error` - Thrown if the command fails with a non-zero exit code. ``` -------------------------------- ### Sanitize Asset Name for GitHub Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Example of sanitizing an artifact name to ensure it meets GitHub Asset API requirements. ```typescript const name = ghAssetName(artifact); // Input: "My App-1.0.0_macOS_aarch64.dmg" // Output: "My.App-1.0.0_macOS_aarch64.dmg" ``` -------------------------------- ### Load Base Configuration Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/tauri-config.md Initializes a TauriConfig instance by searching for and parsing the first available configuration file in the specified directory. ```typescript static fromBaseConfig(tauriDir: string): TauriConfig ``` ```typescript import { TauriConfig } from './config'; const config = TauriConfig.fromBaseConfig('/path/to/src-tauri'); console.log(`App: ${config.productName || 'unknown'} v${config.version}`); ``` -------------------------------- ### Detect Platform and Architecture Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/README.md Retrieves target information and system metadata. ```typescript import { getTargetInfo, getInfo } from './utils'; const targetInfo = getTargetInfo(targetTriple); const info = getInfo(targetInfo, configFiles); ``` -------------------------------- ### Build Application Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/README.md Orchestrates the build process for the project. ```typescript import { buildProject } from './build'; const artifacts = await buildProject(); ``` -------------------------------- ### Execute build project Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/entry-point.md Invokes the Tauri CLI build process. ```typescript artifacts.push(...(await buildProject())); ``` -------------------------------- ### Project File Organization Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/SUMMARY.md Visual representation of the documentation directory structure. ```text output/ ├── README.md # Central hub & quick reference ├── INDEX.md # Comprehensive lookup table ├── SUMMARY.md # This file ├── architecture.md # System design & data flow ├── entry-point.md # Action execution sequence ├── configuration.md # All inputs, outputs, environment vars ├── types.md # Type definitions └── api-reference/ ├── build.md # buildProject() ├── runner.md # Runner class, getRunner() ├── tauri-config.md # TauriConfig class ├── release-management.md # Release & upload functions ├── utils.md # 40+ utility functions └── inputs.md # 14 input constants ``` -------------------------------- ### buildProject() Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/build.md Orchestrates the Tauri application build process, detects target platform information, locates build artifacts, and returns artifact metadata for upload and distribution. ```APIDOC ## buildProject() ### Description Orchestrates the Tauri application build process, detects target platform information, locates build artifacts, and returns artifact metadata for upload and distribution. ### Signature `async function buildProject(): Promise` ### Parameters None. ### Return Type `Promise` — Array of artifact objects representing built binaries and bundled installers. Each artifact contains metadata about file paths, architecture, bundle type, version, and platform-specific naming conventions. ### Throws - `Error` — If Tauri path cannot be detected ("Couldn't detect path of tauri app") - Command execution errors from the Tauri CLI build command ### Example ```typescript import { buildProject } from './build'; async function release() { try { const artifacts = await buildProject(); console.log(`Built ${artifacts.length} artifacts:`); artifacts.forEach(a => { console.log(` ${a.name} v${a.version} (${a.platform}-${a.arch}): ${a.path}`); }); } catch (error) { console.error('Build failed:', error.message); } } release(); ``` ``` -------------------------------- ### Configure release asset naming patterns Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/configuration.md Define custom naming conventions for release assets using bracketed placeholders. These patterns are applied to the releaseAssetNamePattern configuration key. ```yaml # Default naming (if not set, Tauri CLI names are preserved) releaseAssetNamePattern: '' # Custom format releaseAssetNamePattern: '[name]-[version]_[platform]_[arch][ext]' # With setup suffix releaseAssetNamePattern: '[name]_[version]_[platform]_[arch][_setup][ext]' # Flat namespace releaseAssetNamePattern: '[name]-[version]-[platform]-[arch][ext]' ``` -------------------------------- ### getInfo(targetInfo, configFlag?) Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Extracts and merges application metadata from Tauri configuration files and the Cargo manifest. ```APIDOC ## getInfo(targetInfo, configFlag?) ### Description Extracts and merges application metadata from Tauri config and Cargo manifest. It follows a specific resolution order starting from base config, merging platform-specific and user-provided overrides, and falling back to Cargo.toml. ### Signature `function getInfo(targetInfo: TargetInfo, configFlag?: string[]): Info` ### Parameters - **targetInfo** (TargetInfo) - Required - Platform and architecture info - **configFlag** (string[]) - Optional - Array of config overrides (inline or file paths) ### Return Type - **tauriPath** (string) - **name** (string) - **mainBinaryName** (string) - **version** (string) - **wixLanguage** (string | string[] | { [language: string]: unknown }) - **rpmRelease** (string) - **unzippedSigs** (boolean) - **targetPlatform** (TargetPlatform) ### Errors - Throws Error if package name and version cannot be determined. - Throws Error if Tauri directory cannot be detected. ``` -------------------------------- ### Package macOS applications Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/entry-point.md Archives .app directories into .tar.gz files for upload compatibility. ```typescript if (targetInfo.platform === 'macos') { for (const artifact of artifacts) { if (artifact.path.endsWith('.app') && !existsSync(`${artifact.path}.tar.gz`)) { await execCommand('tar', ['czf', `${artifact.path}.tar.gz`, ...]); artifact.path += '.tar.gz'; artifact.ext += '.tar.gz'; } } } ``` -------------------------------- ### execTauriCommand Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/runner.md Executes a Tauri CLI command using the configured runner, supporting custom environment variables, working directories, and automatic retries. ```APIDOC ## async execTauriCommand(command: string[], commandOptions: string[], cwd?: string, env?: Record, retryAttempts?: number): Promise ### Description Executes a Tauri CLI command with the configured runner, applying retries on failure using exponential backoff. ### Parameters - **command** (string[]) - Required - The Tauri command to execute (e.g., ['build']). - **commandOptions** (string[]) - Required - Additional CLI options to pass to the Tauri command. - **cwd** (string) - Optional - Working directory for command execution. - **env** (Record) - Optional - Environment variables to pass to the process. - **retryAttempts** (number) - Optional - Number of retry attempts on command failure (Default: 0). ### Returns - **Promise** - Resolves when the command completes successfully. ``` -------------------------------- ### Create or retrieve release Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/entry-point.md Performs template substitution on release metadata and manages the GitHub release. ```typescript const templates = [{ key: '__VERSION__', value: info.version }]; templates.forEach(({ key, value }) => { tagName = tagName.replace(new RegExp(key, 'g'), value); releaseName = releaseName.replace(new RegExp(key, 'g'), value); body = body.replace(new RegExp(key, 'g'), value); }); const releaseData = await getOrCreateRelease(tagName, releaseName || undefined, body); releaseId = releaseData.id; ``` -------------------------------- ### Define run function Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/entry-point.md The primary entry point for the GitHub Action workflow. ```typescript async function run(): Promise ``` -------------------------------- ### Project Directory Structure Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/README.md Visual representation of the project's source code organization and build artifacts. ```text tauri-action/ ├── src/ │ ├── index.ts # Entry point │ ├── build.ts # Build orchestration │ ├── runner.ts # Runner abstraction │ ├── config.ts # Configuration parsing │ ├── inputs.ts # Input parsing │ ├── create-release.ts # Release management │ ├── upload-release-assets.ts # Asset upload │ ├── upload-version-json.ts # Updater manifest │ ├── upload-workflow-artifacts.ts # Workflow artifacts │ ├── utils.ts # Utilities (20+ functions) │ └── types.d.ts # Type definitions ├── dist/ │ └── index.js # Compiled entry point (built by ncc) ├── action.yml # GitHub Actions manifest ├── package.json # npm metadata └── tsconfig.json # TypeScript config ``` -------------------------------- ### Handle Asset Naming Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/README.md Utilities for generating and formatting asset names. ```typescript import { getAssetName, ghAssetName, renderNamePattern } from './utils'; const displayName = getAssetName(artifact, pattern); const ghName = ghAssetName(artifact, pattern); ``` -------------------------------- ### Access Action Outputs Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/README.md Retrieve release information and artifact paths generated by the tauri-action using an ID reference. ```yaml - id: tauri uses: tauri-apps/tauri-action@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | echo "Release ID: ${{ steps.tauri.outputs.releaseId }}" echo "URL: ${{ steps.tauri.outputs.releaseHtmlUrl }}" echo "Version: ${{ steps.tauri.outputs.appVersion }}" echo "Artifacts: ${{ steps.tauri.outputs.artifactPaths }}" ``` -------------------------------- ### Compile Tauri Action Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/README.md Compiles the source code from the src directory into a single dist/index.js file. ```bash pnpm build # Compiles src/ → dist/index.js ``` -------------------------------- ### Runner Class Constructor Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/runner.md Initializes a new Runner instance to manage the execution environment for Tauri CLI commands. ```APIDOC ## constructor(bin: string, tauriScript?: string[]) ### Description Creates a new Runner instance configured with a specific binary and optional script arguments. ### Parameters - **bin** (string) - Required - The package manager or binary to execute (e.g., 'npm', 'yarn', 'pnpm', 'bun', 'cargo', or 'tauri'). - **tauriScript** (string[]) - Optional - Additional arguments to prepend before the Tauri command. ``` -------------------------------- ### Define Tauri configuration in TOML Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/tauri-config.md TOML format for Tauri configuration. ```toml identifier = "com.myapp" productName = "My Application" version = "1.0.0" [build] frontendDist = "../dist" [bundle.linux.rpm] release = "1" [bundle.windows.wix] language = "en-US" ``` -------------------------------- ### Generate Asset Names Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Demonstrates generating artifact names using default behavior and custom patterns. ```typescript import { getAssetName } from './utils'; // With default naming const name1 = getAssetName(artifact); // → "MyApp_1.0.0_aarch64.dmg" // With custom pattern const name2 = getAssetName(artifact, '[name]-[version]_[platform]_[arch][ext]'); // → "MyApp-1.0.0_macos_aarch64.dmg" ``` -------------------------------- ### Enable workflow artifact uploads Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/inputs.md Configures whether to upload build outputs as GitHub Actions workflow artifacts. ```typescript export const shouldUploadWorkflowArtifacts: boolean ``` -------------------------------- ### Set GitHub Actions outputs Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/entry-point.md Exports artifact paths and application version for downstream workflow steps. ```typescript core.setOutput('artifactPaths', JSON.stringify(artifacts.map((a) => a.path))); core.setOutput('appVersion', info.version); ``` -------------------------------- ### Define Typical Tauri Workflow Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/configuration.md A standard GitHub Actions workflow for building and publishing Tauri applications across multiple platforms. ```yaml name: Publish on: push: tags: - 'v*' jobs: publish: permissions: contents: write strategy: matrix: include: - platform: macos-latest args: '--target aarch64-apple-darwin' - platform: ubuntu-22.04 args: '' - platform: windows-latest args: '' runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: lts/* - uses: dtolnay/rust-toolchain@stable - uses: tauri-apps/tauri-action@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tagName: ${{ github.ref_name }} releaseName: 'Release ${{ github.ref_name }}' releaseBody: | See the assets to download this version releaseDraft: false prerelease: false args: ${{ matrix.args }} ``` -------------------------------- ### Toggle updater signature uploads Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/inputs.md Determines if .sig files should be uploaded alongside release assets. ```typescript export const uploadUpdaterSignatures: boolean ``` -------------------------------- ### Define Asset interface Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/types.md Represents a release asset with download URL and naming information for the updater system. ```typescript interface Asset { downloadUrl: string; assetName: string; path: string; arch: string; bundle: string; } ``` -------------------------------- ### Configure Tauri Build and Release Workflow Source: https://github.com/tauri-apps/tauri-action/blob/dev/README.md A complete GitHub Actions workflow configuration that builds a Tauri application and creates a release on push to the release branch. ```yml name: 'publish' on: push: branches: - release # This workflow will trigger on each push to the `release` branch to create or update a GitHub release, build your app, and upload the artifacts to the 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' args: '' - platform: 'windows-latest' args: '' runs-on: ${{ matrix.platform }} steps: - uses: actions/checkout@v4 - name: setup node uses: actions/setup-node@v4 with: node-version: lts/* - 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' || '' }} - 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 xdg-utils - name: install frontend dependencies run: yarn install # change this to npm, pnpm or bun depending on which one you use. - uses: tauri-apps/tauri-action@v1 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 }} ``` -------------------------------- ### createArtifact Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Constructs an artifact object from build metadata, determining file extensions, build modes, and platform normalization. ```APIDOC ## createArtifact ### Description Constructs an artifact object from build metadata. It determines file extensions, sets build modes, and normalizes platform names. ### Signature `createArtifact({ info, path, name, arch, bundle }): Artifact` ### Parameters - **info** (Info) - Required - Application metadata (version, platform, etc.) - **path** (string) - Required - Full path to the artifact file - **name** (string) - Optional - Display name (defaults to info.name) - **arch** (string) - Required - Architecture identifier (e.g., x64, arm64) - **bundle** (string) - Required - Bundle type (e.g., dmg, msi, deb, apk) ### Return Type Returns an `Artifact` object containing details like name, mode, platform, arch, bundle, ext, version, and path. ``` -------------------------------- ### Define Tauri configuration in JSON Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/tauri-config.md Standard JSON configuration format for Tauri applications. ```json { "identifier": "com.myapp", "productName": "My Application", "version": "1.0.0", "mainBinaryName": "myapp", "build": { "frontendDist": "../dist", "beforeBuildCommand": "npm run build" }, "bundle": { "createUpdaterArtifacts": true, "linux": { "rpm": { "release": "1" } }, "windows": { "wix": { "language": "en-US" } } } } ``` -------------------------------- ### getRunner Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/runner.md Factory function that detects the project's dependency configuration and returns an appropriate Runner instance. ```APIDOC ## async getRunner(): Promise ### Description Detects the project environment (npm, yarn, pnpm, bun, or global) and returns a configured Runner instance. It checks for local CLI dependencies and package manager lockfiles to determine the correct execution strategy. ### Returns - **Promise** - A configured instance of the Runner class. ``` -------------------------------- ### Define Tauri configuration in JSON5 Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/tauri-config.md JSON5 format allows for comments and unquoted keys. ```json5 { identifier: "com.myapp", productName: "My Application", // Version can reference package.json version: "package.json", // ... rest of config } ``` -------------------------------- ### Enable auto-generated release notes Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/inputs.md Toggles the use of GitHub's Release Notes API for release metadata. ```typescript export const generateReleaseNotes: boolean ``` -------------------------------- ### extensions Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md An ordered list of multi-character file extensions used for parsing Tauri artifacts. ```APIDOC ## extensions ### Description An ordered list of multi-character file extensions for Tauri artifacts. This is used to correctly parse file extensions when filenames contain multiple dots. ### Value Array of strings including: '.app.tar.gz.sig', '.app.tar.gz', '.dmg', '.AppImage.tar.gz.sig', '.AppImage.tar.gz', '.AppImage.sig', '.AppImage', '.deb.sig', '.deb', '.rpm.sig', '.rpm', '.msi.zip.sig', '.msi.zip', '.msi.sig', '.msi', '.nsis.zip.sig', '.nsis.zip', '.nsis.zip', '.exe.sig', '.exe'. ``` -------------------------------- ### Configure GitHub Base URL Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/inputs.md Sets the API base URL for self-hosted GitHub Enterprise instances. ```typescript export const githubBaseUrl: string ``` ```typescript // Self-hosted GitHub Enterprise githubBaseUrl = 'https://github.company.com/api/v3' ``` -------------------------------- ### Merge Platform Configuration Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/tauri-config.md Merges platform-specific overrides into the existing configuration instance based on the target platform. ```typescript mergePlatformConfig(tauriDir: string, target: TargetPlatform): void ``` ```typescript const config = TauriConfig.fromBaseConfig(tauriDir); config.mergePlatformConfig(tauriDir, 'macos'); config.mergePlatformConfig(tauriDir, 'windows'); ``` -------------------------------- ### getTargetInfo Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Determines the target platform and architecture based on CLI arguments or the current environment. ```APIDOC ## getTargetInfo(targetPath?: string) ### Description Determines target platform and architecture from CLI arguments or environment variables. ### Parameters - **targetPath** (string) - Optional - Rust target triple (e.g., `aarch64-apple-darwin`). ### Returns - **TargetInfo** (object) - An object containing: - **arch** (string) - The architecture (e.g., "aarch64", "x86_64"). - **platform** (TargetPlatform) - The detected platform. ``` -------------------------------- ### Access projectPath constant Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/inputs.md Import and use the resolved absolute path to the Tauri project root. ```typescript import { projectPath } from './inputs'; console.log(projectPath); // "/home/runner/work/my-app/src-tauri" ``` -------------------------------- ### Accessing Tauri Action Inputs Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/inputs.md Import and log action configuration values after the module has resolved them at load time. ```typescript import { projectPath, shouldUploadUpdaterJson, retryAttempts, parsedArgs, } from './inputs'; console.log(`Project: ${projectPath}`); console.log(`Target: ${parsedArgs.target || 'native'}`); console.log(`Retry attempts: ${retryAttempts}`); console.log(`Upload updater JSON: ${shouldUploadUpdaterJson}`); ``` -------------------------------- ### uploadVersionJSON(version, notes, releaseId, artifacts, info, unzippedSig) Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/release-management.md Generates and uploads a latest.json file for Tauri's auto-update system by merging new platform entries with existing ones and selecting signatures based on a priority system. ```APIDOC ## uploadVersionJSON(version, notes, releaseId, artifacts, info, unzippedSig) ### Description Generates and uploads a `latest.json` file for Tauri's auto-update system. It retrieves existing release data, merges new platform entries, and handles signature selection based on priority. ### Parameters - **version** (string) - Required - Application version string - **notes** (string) - Required - Release notes/changelog - **releaseId** (number) - Required - GitHub release ID - **artifacts** (Artifact[]) - Required - Array of built artifacts - **info** (Info) - Required - Application metadata (name, platform, etc.) - **unzippedSig** (boolean) - Required - Whether signatures are unzipped (Tauri v2+) ### Example ```typescript import { uploadVersionJSON } from './upload-version-json'; await uploadVersionJSON( '1.2.3', '## v1.2.3\n\nBug fixes and improvements.', releaseId, artifacts, info, true ); ``` ### Throws - `Error`: "GITHUB_TOKEN is required" - Warnings are logged if updater assets or signature files are missing. ``` -------------------------------- ### Upload workflow artifacts Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/entry-point.md Uploads build artifacts to the GitHub Actions workflow storage. ```typescript await uploadWorkflowArtifacts(artifacts); ``` -------------------------------- ### Define Artifact Extensions Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Provides an ordered list of multi-character file extensions used for parsing Tauri build artifacts. ```typescript const extensions = [ '.app.tar.gz.sig', '.app.tar.gz', '.dmg', '.AppImage.tar.gz.sig', '.AppImage.tar.gz', '.AppImage.sig', '.AppImage', '.deb.sig', '.deb', '.rpm.sig', '.rpm', '.msi.zip.sig', '.msi.zip', '.msi.sig', '.msi', '.nsis.zip.sig', '.nsis.zip', '.exe.sig', '.exe', ]; ``` -------------------------------- ### TauriConfig.mergePlatformConfig Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/tauri-config.md Merges platform-specific configuration overrides into the existing configuration instance. ```APIDOC ## mergePlatformConfig(tauriDir: string, target: TargetPlatform) ### Description Merges platform-specific configuration overrides into the base configuration. Values from the platform config override existing properties. ### Parameters - **tauriDir** (string) - Required - Directory containing the Tauri configuration. - **target** (TargetPlatform) - Required - Target platform: 'macos', 'windows', 'linux', 'android', 'ios'. ``` -------------------------------- ### Output Setting Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/entry-point.md Sets action outputs that can be consumed by downstream workflow steps. ```typescript core.setOutput('releaseId', releaseData.id.toString()); core.setOutput('releaseHtmlUrl', releaseData.htmlUrl); core.setOutput('releaseUploadUrl', releaseData.uploadUrl); core.setOutput('artifactPaths', JSON.stringify(artifacts.map((a) => a.path))); core.setOutput('appVersion', info.version); ``` -------------------------------- ### Define TauriConfigV2 interface Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/types.md Represents the structure of configuration files like tauri.conf.json or Tauri.toml. ```typescript interface TauriConfigV2 { identifier: string; productName?: string; version?: string; mainBinaryName?: string; build?: { frontendDist?: string; beforeBuildCommand?: string; }; bundle?: { createUpdaterArtifacts?: boolean | 'v1Compatible'; linux?: { rpm?: { release?: string; }; }; windows?: { wix?: { language?: string | string[] | { [language: string]: unknown }; }; }; }; } ``` -------------------------------- ### Configure tauri-action in GitHub Workflow Source: https://github.com/tauri-apps/tauri-action/blob/dev/README.md Use this YAML configuration within a GitHub Actions workflow file to build and release Tauri applications. Ensure GITHUB_TOKEN is provided in the environment for release operations. ```yaml - uses: tauri-apps/tauri-action@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: # The id of the release to upload artifacts as release assets. # If set, `tagName` and `releaseName` will NOT be considered to find a release. # # default: unset releaseId: '' # The tag name of the release to upload/create or the tag of the release belonging to `releaseId`. # If this points to an existing release `releaseDraft` must match the status of that release. # If `releaseId` is set but this is not, the `latest.json` file will # point to `releases/latest/download/` instead of the tag. # # default: unset tagName: '' # The name of the release to create. # Required if `releaseId` is not set and there's no existing release for `tagName`. # # default: "" releaseName: '' # The body of the release to create. # # default: "" releaseBody: '' # Any branch or commit SHA the Git tag is created from, unused if the Git tag already exists. # # default: SHA of current commit releaseCommitish: '' # Whether the release to find or create is a draft or not. # # default: false releaseDraft: false # Whether the release to create is a prerelease or not. # # default: false prerelease: false # Whether to use GitHub's Release Notes API to generate the release title and body. # If `releaseName` is set, it will overwrite the generated title. # If `releaseBody` is set, it will be pre-pended to the automatically generated notes. # This action is not responsible for the generated content. # # default: false generateReleaseNotes: false # The account owner of the repository the release will be uploaded to. # Requires `GITHUB_TOKEN` in env and a `releaseCommitish` target if it doesn't match the current repo. # # default: owner of the current repo owner: '' # The name of the repository the release will be uploaded to. # Requires `GITHUB_TOKEN` in env and a `releaseCommitish` target if it doesn't match the current repo. # # default: name of the current repo repo: '' # The base URL of the GitHub API to use. # This is useful if you want to use a self-hosted GitHub instance or a GitHub Enterprise server. # This applies to API calls in the action run and in the generated latest.json file. # # default: $GITHUB_API_URL or "https://api.github.com" githubBaseUrl: '' # The path to the root of the tauri project relative to the current working directory. # It must NOT be gitignored. Please open an issue if this causes problems. # # Relative paths provided via the `--config` flag will be resolved relative to this path. # # default: ./ projectPath: '' # The number of times to re-try building the app if the initial build fails or uploading assets if the upload fails. # Some small internal steps may be re-tried regardless of this config. # # default: 0 retryAttempts: 0 # Whether to upload a JSON file for the updater or not (only relevant if the updater is configured). # This file assume you're using the GitHub Release as your updater endpoint. # # default: true uploadUpdaterJson: true # Whether the action will use the NSIS (setup.exe) or WiX (.msi) bundles for the updater JSON if both types exist. # # default: false (for legacy reasons) updaterJsonPreferNsis: false # The script to execute the Tauri CLI. It must not include any args or commands like `build`. # It can also be an absolute path without spaces pointing to a `tauri-cli` binary. # # default: "npm|pnpm|yarn|bun tauri" or "tauri" if the action had to install the CLI. tauriScript: '' # Additional arguments to the current tauri build command. # Relative paths in the `--config` flag will be resolved relative to `projectPath`. # # default: "" args: '' ``` -------------------------------- ### Define Info interface Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/types.md Application metadata extracted from Tauri config and Cargo manifest, providing unified access to version, name, and platform-specific settings. ```typescript interface Info { tauriPath: string | null; name: string; mainBinaryName: string; version: string; wixLanguage: string | string[] | { [language: string]: unknown }; rpmRelease: string; unzippedSigs: boolean; targetPlatform: TargetPlatform; } ``` -------------------------------- ### Define Artifact Creation Function Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Defines the signature for creating an artifact object from build metadata. ```typescript function createArtifact({ info, path, name, arch, bundle, }: { info: Info; path: string; name?: string; arch: string; bundle: string; }): Artifact ``` -------------------------------- ### Execute Custom Tauri Commands Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/README.md Uses the runner abstraction to execute CLI commands. ```typescript import { Runner, getRunner } from './runner'; const runner = await getRunner(); await runner.execTauriCommand(['build'], [], cwd, env, retryAttempts); ``` -------------------------------- ### getTargetDir Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/utils.md Determines the Cargo build target directory based on configuration and environment variables. ```APIDOC ## getTargetDir(workspacePath: string, tauriPath: string, targetArgSet: boolean): string ### Description Determines the Cargo build target directory accounting for config and env var overrides. Priority is given to CARGO_TARGET_DIR, then .cargo/config settings, defaulting to the workspace target directory. ### Parameters - **workspacePath** (string) - Required - Path to Cargo workspace root - **tauriPath** (string) - Required - Path to Tauri src-tauri directory - **targetArgSet** (boolean) - Required - Whether --target was passed to build command ### Return Type string — Absolute path to target directory ``` -------------------------------- ### Upload release assets Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/entry-point.md Uploads build artifacts to a specific GitHub release. ```typescript await uploadReleaseAssets(releaseId, artifacts, retryAttempts); ``` -------------------------------- ### Define the execTauriCommand method signature Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/runner.md Method signature for executing Tauri CLI commands with optional working directory, environment variables, and retry logic. ```typescript async execTauriCommand( command: string[], commandOptions: string[], cwd?: string, env?: Record, retryAttempts?: number ): Promise ``` -------------------------------- ### TauriConfig.mergeUserConfig Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/api-reference/tauri-config.md Merges user-provided configuration, either as an inline string or from a file, into the current configuration. ```APIDOC ## mergeUserConfig(root: string, mergeConfig: string) ### Description Merges user-provided configuration into the current instance. It attempts to parse the input as inline JSON first, then falls back to treating it as a file path. ### Parameters - **root** (string) - Required - Root directory to resolve relative config paths against. - **mergeConfig** (string) - Required - Inline JSON/JSON5/TOML config OR path to config file. ``` -------------------------------- ### Configure GitHub Actions Permissions Source: https://github.com/tauri-apps/tauri-action/blob/dev/_autodocs/configuration.md Required permissions for the workflow to manage releases and assets. ```yaml permissions: contents: write ```