Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress release with UPX #3456

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Compress release with UPX #3456

wants to merge 3 commits into from

Conversation

dustin-decker
Copy link
Contributor

Description:

Compresses the release binary with UPX. On my machine, I had a 48% compression ratio!
I've omitted Darwin because we've seen issues with OSX signing on our Enterprise build when using UPX.

In this PR i've updated the UPX command to allow failure.
I've also changed CI to use the gorelease-pro distribution. That will allow us to parallelize builds later on as well.

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@dustin-decker dustin-decker requested a review from a team as a code owner October 17, 2024 16:21
@@ -11,6 +11,9 @@ builds:
goarch:
- amd64
- arm64
hooks:
post:
- bash -c 'if [ "{{ .Env.GGOOS }}" != "darwin" ]; then upx -q "{{ .Path }}" || true; fi'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dustin-decker I like the UPX optimization. Couple of comments:

  1. Are we sure this works for windows? The UPX readme suggests that windows arm64 isn't supported.
  2. I find this oneliner to be a little hard on the eyes. WDYT about specifically defining a darwin build like:
builds:
  - id: trufflehog-upx
    binary: trufflehog
    ldflags:
      - -X 'github.com/trufflesecurity/trufflehog/v3/pkg/version.BuildVersion={{ .Version }}'
    env: [CGO_ENABLED=0]
    goos:
    - linux
    goarch:
    - amd64
    - arm64
    hooks:
      post:
        - upx "{{ .Path }}"
  - id: trufflehog
    binary: trufflehog
    ldflags:
      - -X 'github.com/trufflesecurity/trufflehog/v3/pkg/version.BuildVersion={{ .Version }}'
    env: [CGO_ENABLED=0]
    goos:
    - darwin
    - windows
    goarch:
    - amd64
    - arm64

This could be split out differently too like on OS rather than upx enabled - trufflehog-linux, trufflehog-darwin, trufflehog-windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants