Skip to content

Commit 1eed3bd

Browse files
authored
add option to allow enabling cgo in distributions (#913)
1 parent 22cc481 commit 1eed3bd

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

cmd/goreleaser/internal/configure.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ type distribution struct {
384384
dockerSigns []config.Sign
385385
sboms []config.SBOM
386386
checksum config.Checksum
387+
enableCgo bool
387388
}
388389

389390
func (d *distribution) BuildProject() config.Project {
@@ -392,18 +393,22 @@ func (d *distribution) BuildProject() config.Project {
392393
builds = append(builds, buildConfig.Build(d.name))
393394
}
394395

396+
env := []string{
397+
"COSIGN_YES=true",
398+
"LD_FLAGS=-s -w",
399+
"BUILD_FLAGS=-trimpath",
400+
}
401+
if !d.enableCgo {
402+
env = append(env, "CGO_ENABLED=0")
403+
}
404+
395405
return config.Project{
396406
ProjectName: "opentelemetry-collector-releases",
397407
Release: config.Release{
398408
ReplaceExistingArtifacts: true,
399409
},
400-
Checksum: d.checksum,
401-
Env: []string{
402-
"COSIGN_YES=true",
403-
"LD_FLAGS=-s -w",
404-
"CGO_ENABLED=0",
405-
"BUILD_FLAGS=-trimpath",
406-
},
410+
Checksum: d.checksum,
411+
Env: env,
407412
Builds: builds,
408413
Archives: d.archives,
409414
MSI: d.msiConfig,

distributions/otelcol-contrib/.goreleaser-build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ project_name: opentelemetry-collector-releases
33
env:
44
- COSIGN_YES=true
55
- LD_FLAGS=-s -w
6-
- CGO_ENABLED=0
76
- BUILD_FLAGS=-trimpath
7+
- CGO_ENABLED=0
88
release:
99
replace_existing_artifacts: true
1010
builds:

distributions/otelcol-contrib/.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ project_name: opentelemetry-collector-releases
33
env:
44
- COSIGN_YES=true
55
- LD_FLAGS=-s -w
6-
- CGO_ENABLED=0
76
- BUILD_FLAGS=-trimpath
7+
- CGO_ENABLED=0
88
release:
99
replace_existing_artifacts: true
1010
msi:

distributions/otelcol-k8s/.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ project_name: opentelemetry-collector-releases
33
env:
44
- COSIGN_YES=true
55
- LD_FLAGS=-s -w
6-
- CGO_ENABLED=0
76
- BUILD_FLAGS=-trimpath
7+
- CGO_ENABLED=0
88
release:
99
replace_existing_artifacts: true
1010
builds:

distributions/otelcol-otlp/.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ project_name: opentelemetry-collector-releases
33
env:
44
- COSIGN_YES=true
55
- LD_FLAGS=-s -w
6-
- CGO_ENABLED=0
76
- BUILD_FLAGS=-trimpath
7+
- CGO_ENABLED=0
88
release:
99
replace_existing_artifacts: true
1010
msi:

distributions/otelcol/.goreleaser.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ project_name: opentelemetry-collector-releases
33
env:
44
- COSIGN_YES=true
55
- LD_FLAGS=-s -w
6-
- CGO_ENABLED=0
76
- BUILD_FLAGS=-trimpath
7+
- CGO_ENABLED=0
88
release:
99
replace_existing_artifacts: true
1010
msi:

0 commit comments

Comments
 (0)