@@ -42,22 +42,32 @@ const (
42
42
var (
43
43
ImagePrefixes = []string {DockerHub , GHCR }
44
44
Architectures = []string {"386" , "amd64" , "arm" , "arm64" , "ppc64le" , "s390x" }
45
- ArmVersions = []string {"7" }
46
45
DefaultConfigDists = map [string ]bool {CoreDistro : true , ContribDistro : true }
47
46
MSIWindowsDists = map [string ]bool {CoreDistro : true , ContribDistro : true , OTLPDistro : true }
48
47
K8sDockerSkipArchs = map [string ]bool {"arm" : true , "386" : true }
49
48
K8sGoos = []string {"linux" }
50
49
K8sArchs = []string {"amd64" , "arm64" , "ppc64le" , "s390x" }
51
50
)
52
51
53
- func Generate (dist string ) config.Project {
52
+ func GenerateContribBuildOnly (dist string , buildOrRest bool ) config.Project {
53
+ return config.Project {
54
+ ProjectName : "opentelemetry-collector-releases" ,
55
+ Builds : Builds (dist , buildOrRest ),
56
+ Version : 2 ,
57
+ Monorepo : config.Monorepo {
58
+ TagPrefix : "v" ,
59
+ },
60
+ }
61
+ }
62
+
63
+ func Generate (dist string , buildOrRest bool ) config.Project {
54
64
return config.Project {
55
65
ProjectName : "opentelemetry-collector-releases" ,
56
66
Checksum : config.Checksum {
57
67
NameTemplate : fmt .Sprintf ("{{ .ProjectName }}_%v_checksums.txt" , dist ),
58
68
},
59
69
Env : []string {"COSIGN_YES=true" },
60
- Builds : Builds (dist ),
70
+ Builds : Builds (dist , buildOrRest ),
61
71
Archives : Archives (dist ),
62
72
MSI : WinPackages (dist ),
63
73
NFPMs : Packages (dist ),
@@ -73,37 +83,41 @@ func Generate(dist string) config.Project {
73
83
}
74
84
}
75
85
76
- func Builds (dist string ) []config.Build {
86
+ func Builds (dist string , buildOrRest bool ) []config.Build {
77
87
return []config.Build {
78
- Build (dist ),
88
+ Build (dist , buildOrRest ),
79
89
}
80
90
}
81
91
82
92
// Build configures a goreleaser build.
83
93
// https://goreleaser.com/customization/build/
84
- func Build (dist string ) config.Build {
85
- var goos []string
86
- var archs []string
87
- var ignore []config.IgnoredBuild
88
- var armVersions []string
94
+ func Build (dist string , buildOrRest bool ) config.Build {
95
+ goos := []string {"darwin" , "linux" , "windows" }
96
+ archs := Architectures
97
+
98
+ if dist == ContribDistro && ! buildOrRest {
99
+ // only return build config for contrib build file
100
+ return config.Build {
101
+ ID : dist ,
102
+ Builder : "prebuilt" ,
103
+ PreBuilt : config.PreBuiltOptions {
104
+ Path : "artifacts/otelcol-contrib_{{ .Target }}" +
105
+ "/otelcol-contrib{{- if eq .Os \" windows\" }}.exe{{ end }}" ,
106
+ },
107
+ Goos : goos ,
108
+ Goarch : archs ,
109
+ Goarm : ArmVersions (dist ),
110
+ Dir : "_build" ,
111
+ Binary : dist ,
112
+ Ignore : IgnoreBuildCombinations (dist ),
113
+ }
114
+ }
115
+
89
116
if dist == K8sDistro {
90
117
goos = K8sGoos
91
118
archs = K8sArchs
92
- ignore = make ([]config.IgnoredBuild , 0 )
93
- armVersions = make ([]string , 0 )
94
- } else {
95
- goos = []string {"darwin" , "linux" , "windows" }
96
- archs = Architectures
97
- ignore = []config.IgnoredBuild {
98
- {Goos : "darwin" , Goarch : "386" },
99
- {Goos : "darwin" , Goarch : "arm" },
100
- {Goos : "darwin" , Goarch : "s390x" },
101
- {Goos : "windows" , Goarch : "arm" },
102
- {Goos : "windows" , Goarch : "arm64" },
103
- {Goos : "windows" , Goarch : "s390x" },
104
- }
105
- armVersions = ArmVersions
106
119
}
120
+
107
121
return config.Build {
108
122
ID : dist ,
109
123
Dir : "_build" ,
@@ -115,12 +129,33 @@ func Build(dist string) config.Build {
115
129
},
116
130
Goos : goos ,
117
131
Goarch : archs ,
118
- Goarm : armVersions ,
119
- Ignore : ignore ,
132
+ Goarm : ArmVersions ( dist ) ,
133
+ Ignore : IgnoreBuildCombinations ( dist ) ,
120
134
}
121
135
}
122
136
123
- func Archives (dist string ) (r []config.Archive ) {
137
+ func IgnoreBuildCombinations (dist string ) []config.IgnoredBuild {
138
+ if dist == K8sDistro {
139
+ return nil
140
+ }
141
+ return []config.IgnoredBuild {
142
+ {Goos : "darwin" , Goarch : "386" },
143
+ {Goos : "darwin" , Goarch : "arm" },
144
+ {Goos : "darwin" , Goarch : "s390x" },
145
+ {Goos : "windows" , Goarch : "arm" },
146
+ {Goos : "windows" , Goarch : "arm64" },
147
+ {Goos : "windows" , Goarch : "s390x" },
148
+ }
149
+ }
150
+
151
+ func ArmVersions (dist string ) []string {
152
+ if dist == K8sDistro {
153
+ return nil
154
+ }
155
+ return []string {"7" }
156
+ }
157
+
158
+ func Archives (dist string ) []config.Archive {
124
159
return []config.Archive {
125
160
Archive (dist ),
126
161
}
@@ -138,7 +173,7 @@ func Archive(dist string) config.Archive {
138
173
139
174
func WinPackages (dist string ) []config.MSI {
140
175
if _ , ok := MSIWindowsDists [dist ]; ! ok {
141
- return []config. MSI {}
176
+ return nil
142
177
}
143
178
return []config.MSI {
144
179
WinPackage (dist ),
@@ -160,9 +195,9 @@ func WinPackage(dist string) config.MSI {
160
195
}
161
196
}
162
197
163
- func Packages (dist string ) ( r []config.NFPM ) {
198
+ func Packages (dist string ) []config.NFPM {
164
199
if dist == K8sDistro {
165
- return []config. NFPM {}
200
+ return nil
166
201
}
167
202
return []config.NFPM {
168
203
Package (dist ),
@@ -191,21 +226,17 @@ func Package(dist string) config.NFPM {
191
226
})
192
227
}
193
228
return config.NFPM {
194
- ID : dist ,
195
- Builds : []string {dist },
196
- Formats : []string {"deb" , "rpm" },
197
-
229
+ ID : dist ,
230
+ Builds : []string {dist },
231
+ Formats : []string {"deb" , "rpm" },
198
232
License : "Apache 2.0" ,
199
233
Description : fmt .Sprintf ("OpenTelemetry Collector - %s" , dist ),
200
234
Maintainer :
"The OpenTelemetry Collector maintainers <[email protected] >" ,
201
235
Overrides : map [string ]config.NFPMOverridables {
202
236
"rpm" : {
203
- Dependencies : []string {
204
- "/bin/sh" ,
205
- },
237
+ Dependencies : []string {"/bin/sh" },
206
238
},
207
239
},
208
-
209
240
NFPMOverridables : config.NFPMOverridables {
210
241
PackageName : dist ,
211
242
Scripts : config.NFPMScripts {
@@ -219,16 +250,14 @@ func Package(dist string) config.NFPM {
219
250
}
220
251
221
252
func DockerImages (dist string ) []config.Docker {
222
- r := make ( []config.Docker , 0 )
253
+ var r []config.Docker
223
254
for _ , arch := range Architectures {
224
- if dist == K8sDistro {
225
- if _ , ok := K8sDockerSkipArchs [arch ]; ok {
226
- continue
227
- }
255
+ if dist == K8sDistro && K8sDockerSkipArchs [arch ] {
256
+ continue
228
257
}
229
258
switch arch {
230
259
case ArmArch :
231
- for _ , vers := range ArmVersions {
260
+ for _ , vers := range ArmVersions ( dist ) {
232
261
r = append (r , DockerImage (dist , arch , vers ))
233
262
}
234
263
default :
@@ -302,7 +331,7 @@ func DockerManifest(prefix, version, dist string) config.DockerManifest {
302
331
}
303
332
switch arch {
304
333
case ArmArch :
305
- for _ , armVers := range ArmVersions {
334
+ for _ , armVers := range ArmVersions ( dist ) {
306
335
dockerArchTag := strings .ReplaceAll (archName (arch , armVers ), "/" , "" )
307
336
imageTemplates = append (
308
337
imageTemplates ,
0 commit comments