### Install UPX Only in GitHub Actions Workflow Source: https://github.com/crazy-max/ghaction-upx/blob/master/README.md This example shows how to use the crazy-max/ghaction-upx action solely for installing UPX without compressing any files. It's useful for workflows that need the UPX binary available for other purposes. The snippet includes checking out code, installing UPX, and verifying the installation. ```yaml name: upx on: push: jobs: upx: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Install UPX uses: crazy-max/ghaction-upx@v3 with: install-only: true - name: UPX version run: upx --version ``` -------------------------------- ### Download and Cache UPX Binary (TypeScript) Source: https://context7.com/crazy-max/ghaction-upx/llms.txt This TypeScript code snippet illustrates the use of the `getUPX` function from the `installer` module to download, extract, and cache UPX binaries. It shows how to get a specific version or the latest version and provides example paths for Linux and Windows. ```typescript import * as installer from './installer'; // Download and get path to UPX executable const upxPath = await installer.getUPX('v4.2.4'); console.log(upxPath); // Linux: /home/runner/.local/share/ghaction-upx/4.2.4/upx-4.2.4-amd64_linux/upx // Windows: C:\Users\runner\.local\share\ghaction-upx\4.2.4\upx-4.2.4-win64\upx.exe // Use latest version const latestUpx = await installer.getUPX('latest'); // Downloads from: https://github.com/upx/upx/releases/download/v5.0.1/upx-5.0.1-amd64_linux.tar.xz // Extracts and caches the binary // Returns path to executable ``` -------------------------------- ### Configure UPX Action Inputs (YAML) Source: https://context7.com/crazy-max/ghaction-upx/llms.txt This snippet demonstrates how to configure the crazy-max/ghaction-upx action using its input parameters. It shows how to specify the UPX version, target files using glob patterns, compression arguments, and an option to only install UPX. ```yaml - name: UPX with all options uses: crazy-max/ghaction-upx@v3 with: # UPX version to use (default: 'latest') # Available versions: latest, v5.0.1, v5.0.0, v4.2.4, v4.2.3, v4.2.2, # v4.2.1, v4.2.0, v4.1.0, v4.0.2, v4.0.1, v4.0.0, v3.96, v3.95, v3.94, # v3.93, v3.92, v3.91 version: 'latest' # Newline-delimited list of file globs to compress # Supports standard glob patterns: *, **, ? files: | ./bin/* ./dist/**/*.exe ./output/app-* # Arguments passed directly to UPX command # Common options: # -1 to -9 compression level (1=fastest, 9=best) # --best alias for -9 # --lzma use LZMA compression (better ratio) # -f force compression # -q quiet mode # -v verbose output # --brute try all compression methods args: '--best --lzma -fq' # Set to 'true' to only install UPX (default: 'false') # When true, 'files' and 'args' are ignored install-only: 'false' ``` -------------------------------- ### Parse Action Inputs and File Paths (TypeScript) Source: https://context7.com/crazy-max/ghaction-upx/llms.txt This TypeScript code snippet demonstrates functions from the `context` module for parsing action inputs and resolving file paths. It includes examples for getting all inputs, parsing newline or comma-separated lists, ignoring commas in paths, and resolving glob patterns. ```typescript import * as context from './context'; // Get all action inputs const inputs = await context.getInputs(); console.log(inputs); // { // version: 'latest', // files: ['./bin/*.exe', './dist/*'], // args: '-fq', // installOnly: false // } // Parse input list (newline or comma separated) const files = context.getInputList('file1.exe\nfile2.exe\nfile3.exe'); console.log(files); // ['file1.exe', 'file2.exe', 'file3.exe'] const commaList = context.getInputList('a.exe,b.exe,c.exe'); console.log(commaList); // ['a.exe', 'b.exe', 'c.exe'] // Ignore commas (for paths that might contain commas) const pathList = context.getInputList('./bin/app.exe\n./dist/tool.exe', true); console.log(pathList); // ['./bin/app.exe', './dist/tool.exe'] // Resolve glob patterns to actual file paths const patterns = ['./bin/*.exe', './dist/**/*']; const resolvedFiles = context.resolvePaths(patterns); console.log(resolvedFiles); // [ // './bin/app.exe', // './bin/tool.exe', // './dist/linux/app', // './dist/windows/app.exe' // ] // Sequential async iteration await context.asyncForEach(['file1', 'file2', 'file3'], async (file) => { console.log(`Processing ${file}...`); // Each iteration completes before the next starts }); ``` -------------------------------- ### Install UPX Only Mode - YAML Source: https://context7.com/crazy-max/ghaction-upx/llms.txt Installs a specific version of UPX without compressing files, making it available in the PATH for subsequent steps. Includes verification steps to confirm installation and version. ```yaml name: Custom UPX Usage on: push: jobs: custom-compression: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Install UPX uses: crazy-max/ghaction-upx@v3 with: version: v4.2.4 install-only: true - name: Verify UPX installation run: | which upx upx --version # Output: # /home/runner/.local/bin/upx # upx 4.2.4 # UCL data compression library 1.03 # zlib data compression library 1.2.13 # LZMA SDK version 4.43 - name: Build and compress with custom logic run: | go build -o ./myapp ./main.go # Only compress if file size > 1MB if [ $(stat -c%s "./myapp") -gt 1048576 ]; then upx --best --lzma ./myapp fi ``` -------------------------------- ### Fetch UPX Release Information (TypeScript) Source: https://context7.com/crazy-max/ghaction-upx/llms.txt This TypeScript code snippet shows how to use the `getRelease` function from the internal `installer` module to fetch UPX release details. It demonstrates fetching the latest release, a specific version, and handling errors for unknown versions. ```typescript import * as installer from './installer'; // Get latest release information const latestRelease = await installer.getRelease('latest'); console.log(latestRelease); // Output: // { // id: 216714091, // tag_name: "v5.0.1", // html_url: "https://github.com/upx/upx/releases/tag/v5.0.1", // assets: [ // "https://github.com/upx/upx/releases/download/v5.0.1/upx-5.0.1-amd64_linux.tar.xz", // "https://github.com/upx/upx/releases/download/v5.0.1/upx-5.0.1-win64.zip", // ... // ] // } // Get specific version const v395Release = await installer.getRelease('v3.95'); console.log(v395Release.tag_name); // "v3.95" console.log(v395Release.id); // 12577195 // Unknown version throws error try { await installer.getRelease('v999'); } catch (error) { console.error(error.message); // "Cannot find UPX release v999 in https://raw.githubusercontent.com/crazy-max/ghaction-upx/master/.github/upx-releases.json" } ``` -------------------------------- ### Run UPX in GitHub Actions Workflow Source: https://github.com/crazy-max/ghaction-upx/blob/master/README.md This snippet demonstrates how to use the crazy-max/ghaction-upx action to compress executable files within a GitHub Actions workflow. It checks out the code, runs the UPX action with specified version, files, and arguments, and assumes a standard Ubuntu environment. ```yaml name: upx on: push: jobs: upx: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Run UPX uses: crazy-max/ghaction-upx@v3 with: version: latest files: | ./bin/*.exe args: -fq ``` -------------------------------- ### Compress Executables with UPX - YAML Source: https://context7.com/crazy-max/ghaction-upx/llms.txt Compresses multiple executable files using glob patterns and UPX arguments. Requires checkout and application build steps prior to execution. Outputs compression results. ```yaml name: Build and Compress on: push: branches: [main] pull_request: jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Build application run: | go build -o ./bin/myapp-linux-amd64 ./cmd/myapp go build -o ./bin/myapp-linux-386 ./cmd/myapp - name: Compress executables with UPX uses: crazy-max/ghaction-upx@v3 with: version: latest files: | ./bin/myapp-* args: -fq # Output shows compression results: # Compressing ./bin/myapp-linux-amd64... # Ultimate Packer for eXecutables # File size Ratio Format Name # -------------------- ------ ----------- ----------- # 8234567 -> 2987654 36.28% linux/amd64 myapp-linux-amd64 ``` -------------------------------- ### Compress Windows Executables - YAML Source: https://context7.com/crazy-max/ghaction-upx/llms.txt Compresses Windows executables for multiple architectures (amd64 and 386) using the UPX action. Sets the UPX version to 'latest' and uses maximum compression arguments. ```yaml name: Windows Release on: push: tags: - 'v*' jobs: windows-build: runs-on: windows-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Go uses: actions/setup-go@v5 with: go-version: '1.21' - name: Build Windows binaries shell: bash run: | mkdir -p ./bin GOOS=windows GOARCH=amd64 go build -o ./bin/app-win64.exe ./cmd/app GOOS=windows GOARCH=386 go build -o ./bin/app-win32.exe ./cmd/app - name: Compress Windows executables uses: crazy-max/ghaction-upx@v3 with: version: latest files: | ./bin/*.exe args: -9 # -9 provides maximum compression # Output: # File size Ratio Format Name # 12582912 -> 4194304 33.33% win64/pe app-win64.exe # 8388608 -> 2796544 33.33% win32/pe app-win32.exe ``` -------------------------------- ### Pin UPX Version for Reproducible Builds - YAML Source: https://context7.com/crazy-max/ghaction-upx/llms.txt Pins the UPX action to a specific version (e.g., v3.96) for reproducible builds across different operating systems. Supports matrix strategy for running on multiple OS. ```yaml name: Version Pinned Build on: release: types: [published] jobs: release-build: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest] include: - os: ubuntu-latest artifact_suffix: linux - os: windows-latest artifact_suffix: windows steps: - name: Checkout uses: actions/checkout@v4 - name: Build run: | mkdir -p ./dist # Build commands here... - name: Compress with pinned UPX version uses: crazy-max/ghaction-upx@v3 with: version: v3.96 files: | ./dist/*.exe ./dist/*-linux-* args: --best --lzma - name: Upload artifacts uses: actions/upload-artifact@v4 with: name: binaries-${{ matrix.artifact_suffix }} path: ./dist/ ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.