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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ jobs:
go-version: "1.23"
- name: Cosign install
uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
- name: Install UPX
run: |
sudo apt-get update
sudo apt-get install -y upx
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
distribution: goreleaser-pro
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
3 changes: 3 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.

dockers:
- image_templates: ["trufflesecurity/{{ .ProjectName }}:{{ .Version }}-amd64"]
dockerfile: Dockerfile.goreleaser
Expand Down
Loading