Skip to content

Commit 79bcd93

Browse files
authored
Add platform-specific builds to goreleaser (#409)
* Add platform-specific builds for goreleaser
1 parent 186667d commit 79bcd93

10 files changed

Lines changed: 562 additions & 16 deletions

File tree

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ cli-docs
66
site
77
/pipeleak
88
/pipeleak.exe
9+
/pipeleak-gitlab
10+
/pipeleak-gitlab.exe
11+
/pipeleak-github
12+
/pipeleak-github.exe
13+
/pipeleak-bitbucket
14+
/pipeleak-bitbucket.exe
15+
/pipeleak-devops
16+
/pipeleak-devops.exe
17+
/pipeleak-gitea
18+
/pipeleak-gitea.exe
919
coverage.out
1020
coverage.html
1121
.vscode

CONTRIBUTING.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The fastest way to start contributing is using GitHub Codespaces:
1111
3. Click "Create codespace on main" (or your branch)
1212

1313
The codespace will automatically:
14+
1415
- Set up Go 1.24+ environment
1516
- Install golangci-lint for code linting
1617
- Install Python and MkDocs for documentation
@@ -32,22 +33,31 @@ If you prefer local development:
3233
### Setup Steps
3334

3435
1. Clone the repository:
36+
3537
```bash
3638
git clone https://github.com/CompassSecurity/pipeleak.git
3739
cd pipeleak
3840
```
3941

4042
2. Install golangci-lint:
43+
4144
```bash
4245
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
4346
```
4447

4548
3. Download dependencies:
49+
4650
```bash
4751
go mod download
4852
```
4953

50-
4. Build the binary:
54+
4. Run it:
55+
56+
```bash
57+
go run cmd/pipeleak/main.go
58+
```
59+
60+
5. Optional: Build the binary:
5161
```bash
5262
make build
5363
```

Makefile

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,60 @@
1-
.PHONY: help build test test-unit test-e2e lint clean coverage coverage-html serve-docs
1+
.PHONY: help build build-all build-gitlab build-github build-bitbucket build-devops build-gitea test test-unit test-e2e lint clean coverage coverage-html serve-docs
22

33
# Default target
44
help:
55
@echo "Pipeleak Makefile"
66
@echo ""
77
@echo "Available targets:"
8-
@echo " make build - Build the pipeleak binary"
9-
@echo " make test - Run all tests (unit + e2e)"
10-
@echo " make test-unit - Run unit tests only"
11-
@echo " make test-e2e - Run e2e tests (builds binary first)"
12-
@echo " make coverage - Generate test coverage report"
13-
@echo " make coverage-html - Generate and open HTML coverage report"
14-
@echo " make lint - Run golangci-lint"
15-
@echo " make serve-docs - Generate and serve CLI documentation"
16-
@echo " make clean - Remove built artifacts"
17-
18-
# Build the pipeleak binary
8+
@echo " make build - Build the main pipeleak binary"
9+
@echo " make build-all - Build all binaries (main + platform-specific)"
10+
@echo " make build-gitlab - Build GitLab-specific binary"
11+
@echo " make build-github - Build GitHub-specific binary"
12+
@echo " make build-bitbucket - Build BitBucket-specific binary"
13+
@echo " make build-devops - Build Azure DevOps-specific binary"
14+
@echo " make build-gitea - Build Gitea-specific binary"
15+
@echo " make test - Run all tests (unit + e2e)"
16+
@echo " make test-unit - Run unit tests only"
17+
@echo " make test-e2e - Run e2e tests (builds binary first)"
18+
@echo " make coverage - Generate test coverage report"
19+
@echo " make coverage-html - Generate and open HTML coverage report"
20+
@echo " make lint - Run golangci-lint"
21+
@echo " make serve-docs - Generate and serve CLI documentation"
22+
@echo " make clean - Remove built artifacts"
23+
24+
# Build the main pipeleak binary
1925
build:
2026
@echo "Building pipeleak..."
2127
go build -o pipeleak ./cmd/pipeleak
2228

29+
# Build GitLab-specific binary
30+
build-gitlab:
31+
@echo "Building pipeleak-gitlab..."
32+
go build -o pipeleak-gitlab ./cmd/pipeleak-gitlab
33+
34+
# Build GitHub-specific binary
35+
build-github:
36+
@echo "Building pipeleak-github..."
37+
go build -o pipeleak-github ./cmd/pipeleak-github
38+
39+
# Build BitBucket-specific binary
40+
build-bitbucket:
41+
@echo "Building pipeleak-bitbucket..."
42+
go build -o pipeleak-bitbucket ./cmd/pipeleak-bitbucket
43+
44+
# Build Azure DevOps-specific binary
45+
build-devops:
46+
@echo "Building pipeleak-devops..."
47+
go build -o pipeleak-devops ./cmd/pipeleak-devops
48+
49+
# Build Gitea-specific binary
50+
build-gitea:
51+
@echo "Building pipeleak-gitea..."
52+
go build -o pipeleak-gitea ./cmd/pipeleak-gitea
53+
54+
# Build all binaries
55+
build-all: build build-gitlab build-github build-bitbucket build-devops build-gitea
56+
@echo "All binaries built successfully"
57+
2358
# Run all tests
2459
test: test-unit test-e2e
2560

@@ -96,4 +131,9 @@ serve-docs: build
96131
clean:
97132
@echo "Cleaning up..."
98133
rm -f pipeleak pipeleak.exe coverage.out coverage.html
134+
rm -f pipeleak-gitlab pipeleak-gitlab.exe
135+
rm -f pipeleak-github pipeleak-github.exe
136+
rm -f pipeleak-bitbucket pipeleak-bitbucket.exe
137+
rm -f pipeleak-devops pipeleak-devops.exe
138+
rm -f pipeleak-gitea pipeleak-gitea.exe
99139
go clean -cache -testcache

cmd/pipeleak-bitbucket/main.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"github.com/CompassSecurity/pipeleak/internal/cmd/bitbucket"
5+
"github.com/CompassSecurity/pipeleak/internal/cmd/common"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
func main() {
10+
common.Run(newRootCmd())
11+
}
12+
13+
func newRootCmd() *cobra.Command {
14+
bbCmd := bitbucket.NewBitBucketRootCmd()
15+
bbCmd.Use = "pipeleak-bitbucket"
16+
bbCmd.Short = "Scan BitBucket Pipelines logs and artifacts for secrets"
17+
bbCmd.Long = `Pipeleak-BitBucket scans CI/CD logs and artifacts to detect leaked secrets and pivot from them.`
18+
bbCmd.Version = common.Version
19+
bbCmd.GroupID = ""
20+
21+
common.SetupPersistentPreRun(bbCmd)
22+
common.AddCommonFlags(bbCmd)
23+
24+
bbCmd.SetVersionTemplate(`{{.Version}}
25+
`)
26+
27+
return bbCmd
28+
}

cmd/pipeleak-devops/main.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"github.com/CompassSecurity/pipeleak/internal/cmd/common"
5+
"github.com/CompassSecurity/pipeleak/internal/cmd/devops"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
func main() {
10+
common.Run(newRootCmd())
11+
}
12+
13+
func newRootCmd() *cobra.Command {
14+
adCmd := devops.NewAzureDevOpsRootCmd()
15+
adCmd.Use = "pipeleak-devops"
16+
adCmd.Short = "Scan Azure DevOps Pipelines logs and artifacts for secrets"
17+
adCmd.Long = `Pipeleak-DevOps scans CI/CD logs and artifacts to detect leaked secrets and pivot from them.`
18+
adCmd.Version = common.Version
19+
adCmd.GroupID = ""
20+
21+
common.SetupPersistentPreRun(adCmd)
22+
common.AddCommonFlags(adCmd)
23+
24+
adCmd.SetVersionTemplate(`{{.Version}}
25+
`)
26+
27+
return adCmd
28+
}

cmd/pipeleak-gitea/main.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"github.com/CompassSecurity/pipeleak/internal/cmd/common"
5+
"github.com/CompassSecurity/pipeleak/internal/cmd/gitea"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
func main() {
10+
common.Run(newRootCmd())
11+
}
12+
13+
func newRootCmd() *cobra.Command {
14+
giteaCmd := gitea.NewGiteaRootCmd()
15+
giteaCmd.Use = "pipeleak-gitea"
16+
giteaCmd.Short = "Scan Gitea Actions logs and artifacts for secrets"
17+
giteaCmd.Long = `Pipeleak-Gitea scans CI/CD logs and artifacts to detect leaked secrets and pivot from them.`
18+
giteaCmd.Version = common.Version
19+
giteaCmd.GroupID = ""
20+
21+
common.SetupPersistentPreRun(giteaCmd)
22+
common.AddCommonFlags(giteaCmd)
23+
24+
giteaCmd.SetVersionTemplate(`{{.Version}}
25+
`)
26+
27+
return giteaCmd
28+
}

cmd/pipeleak-github/main.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"github.com/CompassSecurity/pipeleak/internal/cmd/common"
5+
"github.com/CompassSecurity/pipeleak/internal/cmd/github"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
func main() {
10+
common.Run(newRootCmd())
11+
}
12+
13+
func newRootCmd() *cobra.Command {
14+
ghCmd := github.NewGitHubRootCmd()
15+
ghCmd.Use = "pipeleak-github"
16+
ghCmd.Short = "Scan GitHub Actions logs and artifacts for secrets"
17+
ghCmd.Long = `Pipeleak-GitHub scans CI/CD logs and artifacts to detect leaked secrets and pivot from them.`
18+
ghCmd.Version = common.Version
19+
ghCmd.GroupID = ""
20+
21+
common.SetupPersistentPreRun(ghCmd)
22+
common.AddCommonFlags(ghCmd)
23+
24+
ghCmd.SetVersionTemplate(`{{.Version}}
25+
`)
26+
27+
return ghCmd
28+
}

cmd/pipeleak-gitlab/main.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package main
2+
3+
import (
4+
"github.com/CompassSecurity/pipeleak/internal/cmd/common"
5+
"github.com/CompassSecurity/pipeleak/internal/cmd/gitlab"
6+
"github.com/spf13/cobra"
7+
)
8+
9+
func main() {
10+
common.Run(newRootCmd())
11+
}
12+
13+
func newRootCmd() *cobra.Command {
14+
glCmd := gitlab.NewGitLabRootCmd()
15+
glCmd.Use = "pipeleak-gitlab"
16+
glCmd.Short = "Scan GitLab CI/CD logs and artifacts for secrets"
17+
glCmd.Long = `Pipeleak-GitLab scans CI/CD logs and artifacts to detect leaked secrets and pivot from them.`
18+
glCmd.Version = common.Version
19+
glCmd.GroupID = ""
20+
21+
common.SetupPersistentPreRun(glCmd)
22+
common.AddCommonFlags(glCmd)
23+
24+
glCmd.SetVersionTemplate(`{{.Version}}
25+
`)
26+
27+
return glCmd
28+
}

goreleaser.yaml

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
version: 2
22
project_name: pipeleak
33
builds:
4-
-
5-
id: "pipeleak"
4+
- id: "pipeleak"
65
main: ./cmd/pipeleak
76
binary: pipeleak
87
goos:
@@ -15,4 +14,80 @@ builds:
1514
- -s -w
1615
- -X github.com/CompassSecurity/pipeleak/internal/cmd.Version={{.Version}}
1716
- -X github.com/CompassSecurity/pipeleak/internal/cmd.Commit={{.Commit}}
18-
- -X github.com/CompassSecurity/pipeleak/internal/cmd.Date={{.Date}}
17+
- -X github.com/CompassSecurity/pipeleak/internal/cmd.Date={{.Date}}
18+
# Platform-specific builds - only built on release (tagged builds)
19+
- id: "pipeleak-gitlab"
20+
skip: "{{ .IsSnapshot }}"
21+
main: ./cmd/pipeleak-gitlab
22+
binary: pipeleak-gitlab
23+
goos:
24+
- linux
25+
- windows
26+
goarch:
27+
- amd64
28+
- arm64
29+
ldflags:
30+
- -s -w
31+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Version={{.Version}}
32+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Commit={{.Commit}}
33+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Date={{.Date}}
34+
- id: "pipeleak-github"
35+
skip: "{{ .IsSnapshot }}"
36+
main: ./cmd/pipeleak-github
37+
binary: pipeleak-github
38+
goos:
39+
- linux
40+
- windows
41+
goarch:
42+
- amd64
43+
- arm64
44+
ldflags:
45+
- -s -w
46+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Version={{.Version}}
47+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Commit={{.Commit}}
48+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Date={{.Date}}
49+
- id: "pipeleak-bitbucket"
50+
skip: "{{ .IsSnapshot }}"
51+
main: ./cmd/pipeleak-bitbucket
52+
binary: pipeleak-bitbucket
53+
goos:
54+
- linux
55+
- windows
56+
goarch:
57+
- amd64
58+
- arm64
59+
ldflags:
60+
- -s -w
61+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Version={{.Version}}
62+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Commit={{.Commit}}
63+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Date={{.Date}}
64+
- id: "pipeleak-devops"
65+
skip: "{{ .IsSnapshot }}"
66+
main: ./cmd/pipeleak-devops
67+
binary: pipeleak-devops
68+
goos:
69+
- linux
70+
- windows
71+
goarch:
72+
- amd64
73+
- arm64
74+
ldflags:
75+
- -s -w
76+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Version={{.Version}}
77+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Commit={{.Commit}}
78+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Date={{.Date}}
79+
- id: "pipeleak-gitea"
80+
skip: "{{ .IsSnapshot }}"
81+
main: ./cmd/pipeleak-gitea
82+
binary: pipeleak-gitea
83+
goos:
84+
- linux
85+
- windows
86+
goarch:
87+
- amd64
88+
- arm64
89+
ldflags:
90+
- -s -w
91+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Version={{.Version}}
92+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Commit={{.Commit}}
93+
- -X github.com/CompassSecurity/pipeleak/internal/cmd/common.Date={{.Date}}

0 commit comments

Comments
 (0)