Giter Site home page Giter Site logo

upx-action's Introduction

Strip and run UPX on executables GitHub Actions Workflow

This action allows you to select an executable file which is then stripped and run through upx which drastically decreases the size of those executables. It runs on all operating systems types offered by GitHub.

Input variables

  • files: Newline-delimited list of path globs for files to compress. It's compressed in-place. If on Windows, provide Unix style paths (c:/something). either files or file required
  • file: The file you want to compress. It's compressed in-place. Deprecated, prefer files.
  • args: Arguments to pass to UPX. optional
  • strip: Whether or not "strip" symbols from object file (default true). optional
  • strip_args: Arguments to pass to strip. optional

Usage

This Action is meant to be ran on just-compiled executables in the same CI job.

Simple example:

name: Publish

on:
  push:
    tags:
      - '*'

jobs:
  build:
    name: Publish binaries
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Build
      run: cargo build --release --locked
    - name: Compress binaries
      uses: svenstaro/upx-action@v2
      with:
        files: |
          target/release/mything
          target/release/*

Complex example with more operating systems and inputs:

name: Publish

on:
  push:
    tags:
      - '*'

jobs:
  build:
    name: Publish binaries for ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            files: |
                target/release/mything
            args: --best --lzma
            strip: true
          - os: windows-latest
            files: |
                target/release/mything.exe
            args: -9
            strip: false
          - os: macos-latest
            files: |
                target/release/mything
            args: --best
            strip: true
    steps:
    - uses: actions/checkout@v3
    - name: Build
      run: cargo build --release --locked
    - name: Compress binaries
      uses: svenstaro/upx-action@v2
      with:
        files: |
            ${{ matrix.file }}
        args: ${{ matrix.args }}
        strip: ${{ matrix.strip }}

Releasing and publishing

To release this Action:

  • Bump version in package.json
  • Create CHANGELOG.md entry
  • npm update
  • npm run all
  • git commit -am <version>
  • git tag -sm <version> <version>
  • git push --follow-tags
  • Go to https://github.com/svenstaro/upx-action/releases and publish the new version

upx-action's People

Contributors

amesgen avatar crazy-max avatar dependabot[bot] avatar lanwen avatar svenstaro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

upx-action's Issues

Unable to run on Windows

Thanks for making this action!

I'm having an issue running it on Windows:

Run svenstaro/upx-action@v2
  with:
    files: target/x86_64-pc-windows-gnu/release/taskwarrior-tui.exe
  
    args: -9
    strip: false
  env:
    RUSTFLAGS: -C target-feature=+crt-static
    MACOSX_DEPLOYMENT_TARGET: 10.7
Downloading UPX...
C:\ProgramData\Chocolatey\bin\choco.exe install upx --no-progress --version=4.2.2
Chocolatey v2.2.2
Installing the following packages:
upx
By installing, you accept licenses for the packages.
[NuGet] Error downloading 'upx.4.2.2' from 'https://community.chocolatey.org/api/v2/package/upx/4.2.2'.
[NuGet] Response status code does not indicate success: 503 (Service Unavailable: Back-end server is at capacity).
[NuGet] Error downloading 'upx.4.2.2' from 'https://community.chocolatey.org/api/v2/package/upx/4.2.2'.
[NuGet] Response status code does not indicate success: 503 (Service Unavailable: Back-end server is at capacity).
upx not installed. An error occurred during installation:
 Error downloading 'upx.4.2.2' from 'https://community.chocolatey.org/api/v2/package/upx/4.2.2'.
upx package files install failed with exit code 1. Performing other installation steps.
The install of upx was NOT successful.
upx not installed. An error occurred during installation:
 Error downloading 'upx.4.2.2' from 'https://community.chocolatey.org/api/v2/package/upx/4.2.2'.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - upx (exited 1) - upx not installed. An error occurred during installation:
 Error downloading 'upx.4.2.2' from 'https://community.chocolatey.org/api/v2/package/upx/4.2.2'.
Error: The process 'C:\ProgramData\Chocolatey\bin\choco.exe' failed with exit code 1
D:\a\_actions\svenstaro\upx-action\v2\dist\index.js:1825
                error = new Error(`The process '${this.toolPath}' failed with exit code ${this.processExitCode}`);
                        ^

Error: The process 'C:\ProgramData\Chocolatey\bin\choco.exe' failed with exit code 1
    at ExecState._setResult (D:\a\_actions\svenstaro\upx-action\v2\dist\index.js:1825:25)
    at ExecState.CheckComplete (D:\a\_actions\svenstaro\upx-action\v2\dist\index.js:1808:18)
    at ChildProcess.<anonymous> (D:\a\_actions\svenstaro\upx-action\v2\dist\index.js:1702:27)
    at ChildProcess.emit (node:events:514:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)

Node.js v20.8.1

Do you happen to know what is going on?

Response code 404 (Not Found)

Looks like UPX binaries are not available.

Run svenstaro/upx-action@v1-release
⬇️ Downloading UPX...
##[error]Response code 404 (Not Found)
(node:3188) UnhandledPromiseRejectionWarning: HTTPError: Response code 404 (Not Found)
    at EventEmitter.<anonymous> (d:\a\_actions\svenstaro\upx-action\v1-release\node_modules\got\index.js:482:24)
    at EventEmitter.emit (events.js:210:5)
    at getResponse (d:\a\_actions\svenstaro\upx-action\v1-release\node_modules\got\index.js:320:5)
    at Immediate.<anonymous> (d:\a\_actions\svenstaro\upx-action\v1-release\node_modules\got\index.js:147:6)
    at processImmediate (internal/timers.js:439:21)
(node:3188) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:3188) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
##[error]Node run failed with exit code 1

Upgrade to Node.js 20

Hi, any plans for updating the action to Node.js 20 to avoid this GitHub warning?

Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: svenstaro/upx-action@v2. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.

Edit: Just noticed that someone already submitted a PR for this.

Error on action run

Thank you a lot for this action! This is a very useful one.

I tried to use it for the releasing workflow, but unfortunately, I got the error, which I can't understand the nature of:

Run svenstaro/upx-action@v2
internal/modules/cjs/loader.js:1025
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: dlopen(/Users/runner/work/_actions/svenstaro/upx-action/v2/dist/binding-v4.0.6-node-v72-linux-x64/lzma_native.node, 1): no suitable image found.  Did find:
	/Users/runner/work/_actions/svenstaro/upx-action/v2/dist/binding-v4.0.6-node-v72-linux-x64/lzma_native.node: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
	/Users/runner/work/_actions/svenstaro/upx-action/v2/dist/binding-v4.0.6-node-v72-linux-x64/lzma_native.node: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:1025:18)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/Users/runner/work/_actions/svenstaro/upx-action/v2/dist/index.js:24701:18)
    at __webpack_require__ (/Users/runner/work/_actions/svenstaro/upx-action/v2/dist/index.js:24:31)
    at /Users/runner/work/_actions/svenstaro/upx-action/v2/dist/index.js:29883:14
    at Object.<anonymous> (/Users/runner/work/_actions/svenstaro/upx-action/v2/dist/index.js:30467:3)
    at __webpack_require__ (/Users/runner/work/_actions/svenstaro/upx-action/v2/dist/index.js:24:31)

Hope you can help me with that 🙂

Oh, and the workflow is here: https://github.com/kowainik/stan/runs/853748578?check_suite_focus=true

Support for multiple binaries

Hi, as I understand the action is meant for stripping / compressing a single binary, which is the most general case, of course.

Is it viable to add support for multiple files?

No big deal if not, it's easy to add a step that uses this action for each binary.

How to set the UPX version

Hi, I've started using this action, and it generally works fine. However, I see this warning in the CI log:

Downloading UPX...
/usr/local/bin/brew install upx
Warning: upx has been deprecated because it is crashing for macOS Ventura or above!
==> Downloading https://ghcr.io/v2/homebrew/core/upx/manifests/4.1.0

Is there a way to use a newer version of UPX, or specify which version to use?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.