Cross-platform archive extraction supporting multiple formats including ZIP, tar with various compression schemes, 7z, and XAR for comprehensive tool setup workflows.
Extracts ZIP compressed files to a specified or auto-generated directory.
/**
* Extracts a ZIP compressed file
* @param file - Path to the ZIP file to extract
* @param dest - Optional destination directory (auto-generated if not provided)
* @returns Promise resolving to the path of the extracted directory
*/
function extractZip(file: string, dest?: string): Promise<string>;Usage Examples:
import { extractZip } from "@actions/tool-cache";
// Basic ZIP extraction
const extractedPath = await extractZip("/path/to/tool.zip");
// Extract to specific directory
const extractedPath = await extractZip("/path/to/tool.zip", "/opt/myapp");Extracts tar compressed files with support for various compression formats (gz, bz2, xz).
/**
* Extracts a tar compressed file with optional compression
* @param file - Path to the tar file to extract
* @param dest - Optional destination directory (auto-generated if not provided)
* @param flags - Optional tar extraction flags (string or array of strings)
* @returns Promise resolving to the path of the extracted directory
*/
function extractTar(
file: string,
dest?: string,
flags?: string | string[]
): Promise<string>;Usage Examples:
import { extractTar } from "@actions/tool-cache";
// Basic tar extraction (auto-detects compression)
const extractedPath = await extractTar("/path/to/tool.tar.gz");
// Extract with custom flags
const extractedPath = await extractTar(
"/path/to/tool.tar.bz2",
"/opt/myapp",
["--strip-components=1"]
);
// Extract with single flag
const extractedPath = await extractTar(
"/path/to/tool.tar.xz",
undefined,
"--strip-components=1"
);Extracts 7z compressed files with optional custom 7z executable path. Windows only.
/**
* Extracts a 7z compressed file (Windows only)
* @param file - Path to the 7z file to extract
* @param dest - Optional destination directory (auto-generated if not provided)
* @param _7zPath - Optional path to 7z executable (uses system 7z if not provided)
* @returns Promise resolving to the path of the extracted directory
* @throws Error if called on non-Windows platforms
*/
function extract7z(
file: string,
dest?: string,
_7zPath?: string
): Promise<string>;Usage Examples:
import { extract7z } from "@actions/tool-cache";
// Basic 7z extraction
const extractedPath = await extract7z("/path/to/tool.7z");
// Extract to specific directory
const extractedPath = await extract7z("/path/to/tool.7z", "/opt/myapp");
// Use custom 7z executable
const extractedPath = await extract7z(
"/path/to/tool.7z",
"/opt/myapp",
"/usr/local/bin/7z"
);Extracts XAR compressed files (commonly used for macOS .pkg files) with optional flags.
/**
* Extracts a XAR compressed file (macOS .pkg files)
* @param file - Path to the XAR file to extract
* @param dest - Optional destination directory (auto-generated if not provided)
* @param flags - Optional xar extraction flags (string or array of strings)
* @returns Promise resolving to the path of the extracted directory
*/
function extractXar(
file: string,
dest?: string,
flags?: string | string[]
): Promise<string>;Usage Examples:
import { extractXar } from "@actions/tool-cache";
// Basic XAR extraction
const extractedPath = await extractXar("/path/to/installer.pkg");
// Extract with custom flags
const extractedPath = await extractXar(
"/path/to/installer.pkg",
"/opt/myapp",
["-x"]
);
// Extract with single flag
const extractedPath = await extractXar(
"/path/to/installer.pkg",
undefined,
"-x"
);"--strip-components=1")["--strip-components=1", "--verbose"])--strip-components to modify structure