Files
trufflehog/.goreleaser.yml
Bryan Beverly 4d2a8ef686 Add man page generation for trufflehog (#4894)
* Add man page generation for trufflehog

Add a hidden --generate-man-page flag that uses an enhanced Kingpin
template to produce a standards-compliant roff man page. The man page
includes auto-generated OPTIONS and COMMANDS sections (synced with the
CLI definitions), plus hand-maintained EXAMPLES, EXIT STATUS,
ENVIRONMENT, FILES, BUGS, and SEE ALSO sections.

The DESCRIPTION and EXAMPLES sections call out the interactive TUI
that launches when trufflehog is run without a command in a terminal.

To keep the generated output deterministic, the --concurrency flag is
defined with a static "N" placeholder; the runtime.NumCPU() default is
applied at runtime instead of at flag-definition time. The usage line
also uses the lowercase binary name.

Distribution:
- Makefile `man` target to regenerate locally
- GoReleaser before hook to regenerate at release time with the
  correct version injected via ldflags
- Release archives explicitly include LICENSE, README.md, and
  docs/man/trufflehog.1
- Homebrew formula installs the man page to man1

The Makefile `test-release` target is also updated to GoReleaser v2
flag syntax (--skip=publish,sign), which is needed for the snapshot
release to succeed locally without cosign installed.

Made-with: Cursor

* Add man page maintenance guardrails

Add a CI job that regenerates the man page on every PR and fails if
the checked-in copy at docs/man/trufflehog.1 is out of date with the
current CLI definitions. Document the regeneration workflow in
CONTRIBUTING.md so contributors know to run `make man` and commit
the result when changing flags or subcommands.

Made-with: Cursor
2026-04-18 15:19:20 -07:00

147 lines
5.9 KiB
YAML

version: 2
before:
hooks:
- mkdir -p docs/man
- sh -c 'CGO_ENABLED=0 go run -ldflags "-X github.com/trufflesecurity/trufflehog/v3/pkg/version.BuildVersion={{ .Version }}" . --generate-man-page > docs/man/trufflehog.1'
release:
# GoReleaser creates the GitHub release before artifacts finish uploading.
# scripts/install.sh queries /releases/latest to find the current version, so
# a premature "latest" flag causes install failures during the upload window.
# The release workflow's mark-latest job promotes the release only after
# GoReleaser completes successfully.
make_latest: false
builds:
- id: trufflehog-upx
binary: trufflehog
ldflags:
- -s -w -X 'github.com/trufflesecurity/trufflehog/v3/pkg/version.BuildVersion={{ .Version }}'
env: [CGO_ENABLED=0]
goos:
- linux
goarch:
- amd64
- arm64
hooks:
post:
- upx -q "{{ .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
archives:
- files:
- LICENSE
- README.md
- docs/man/trufflehog.1
dockers:
- image_templates: ["trufflesecurity/{{ .ProjectName }}:{{ .Version }}-amd64"]
dockerfile: Dockerfile.goreleaser
extra_files:
- entrypoint.sh
use: buildx
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/trufflesecurity/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/trufflesecurity/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=AGPL-3.0
- --provenance=false
- image_templates: ["trufflesecurity/{{ .ProjectName }}:{{ .Version }}-arm64v8"]
goarch: arm64
dockerfile: Dockerfile.goreleaser
extra_files:
- entrypoint.sh
use: buildx
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/trufflesecurity/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/trufflesecurity/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=AGPL-3.0
- --provenance=false
- image_templates: ["ghcr.io/trufflesecurity/{{ .ProjectName }}:{{ .Version }}-amd64"]
dockerfile: Dockerfile.goreleaser
extra_files:
- entrypoint.sh
use: buildx
build_flag_templates:
- --platform=linux/amd64
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/trufflesecurity/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/trufflesecurity/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=AGPL-3.0
- --provenance=false
- image_templates: ["ghcr.io/trufflesecurity/{{ .ProjectName }}:{{ .Version }}-arm64v8"]
goarch: arm64
dockerfile: Dockerfile.goreleaser
extra_files:
- entrypoint.sh
use: buildx
build_flag_templates:
- --platform=linux/arm64/v8
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description={{ .ProjectName }}
- --label=org.opencontainers.image.url=https://github.com/trufflesecurity/{{ .ProjectName }}
- --label=org.opencontainers.image.source=https://github.com/trufflesecurity/{{ .ProjectName }}
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=AGPL-3.0
- --provenance=false
docker_manifests:
- name_template: trufflesecurity/{{ .ProjectName }}:{{ .Version }}
image_templates:
- trufflesecurity/{{ .ProjectName }}:{{ .Version }}-amd64
- trufflesecurity/{{ .ProjectName }}:{{ .Version }}-arm64v8
- name_template: trufflesecurity/{{ .ProjectName }}:latest
image_templates:
- trufflesecurity/{{ .ProjectName }}:{{ .Version }}-amd64
- trufflesecurity/{{ .ProjectName }}:{{ .Version }}-arm64v8
- name_template: ghcr.io/trufflesecurity/{{ .ProjectName }}:{{ .Version }}
image_templates:
- ghcr.io/trufflesecurity/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/trufflesecurity/{{ .ProjectName }}:{{ .Version }}-arm64v8
- name_template: ghcr.io/trufflesecurity/{{ .ProjectName }}:latest
image_templates:
- ghcr.io/trufflesecurity/{{ .ProjectName }}:{{ .Version }}-amd64
- ghcr.io/trufflesecurity/{{ .ProjectName }}:{{ .Version }}-arm64v8
brews:
- repository:
owner: trufflesecurity
name: homebrew-trufflehog
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
description: "Find credentials all over the place"
name: "trufflehog"
homepage: "https://github.com/trufflesecurity/trufflehog"
install: |
bin.install "trufflehog"
extra_install: |
man1.install "docs/man/trufflehog.1"
signs:
- cmd: cosign
signature: "${artifact}.sig"
certificate: "${artifact}.pem"
args:
- "sign-blob"
- "--oidc-issuer=https://token.actions.githubusercontent.com"
- "--output-certificate=${certificate}"
- "--output-signature=${signature}"
- "${artifact}"
- "--yes"
artifacts: checksum