Skip to content

Commit dabcba1

Browse files
authored
ci: fix artifact upload to draft release (#459)
1 parent 0f5848e commit dabcba1

File tree

9 files changed

+134
-123
lines changed

9 files changed

+134
-123
lines changed

.github/workflows/ci-base.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,18 @@ jobs:
209209
distributions/${{ inputs.distribution }}/dist
210210
key: ${{ steps.generate_binary_key.outputs.binary_key }}
211211

212+
- name: Force artifact version via git tag
213+
run: |
214+
version=$(./scripts/get-version.sh)
215+
echo "Manifest version: $version"
216+
217+
if git rev-parse "$version" >/dev/null 2>&1; then
218+
echo "Tag $version already exists, skipping tag creation"
219+
else
220+
echo "Tagging locally with $version to force goreleaser to use correct version in artifact names"
221+
git tag "$version"
222+
fi
223+
212224
- name: Build binaries & packages with GoReleaser
213225
if: inputs.publish || steps.cache-goreleaser.outputs.cache-hit != 'true'
214226
id: goreleaser

.github/workflows/release-draft.yaml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,34 @@ jobs:
174174
if [ ! -f "artifacts/dist/artifacts.json" ]; then
175175
echo "❌ artifacts.json not found"
176176
exit 1
177+
else
178+
jq '.' artifacts/dist/artifacts.json
177179
fi
178180
179181
echo "📦 Uploading artifacts for ${{ matrix.distribution }}${{ matrix.fips && ' (FIPS)' || '' }}"
180182
183+
release_tag="${{ needs.draft-release.outputs.release-tag }}"
184+
181185
# Read artifacts.json and upload each file with a path
182186
jq -r '.[] | select(has("path")) | .path' artifacts/dist/artifacts.json | while IFS= read -r artifact_path; do
187+
# Skip unrelated build artifacts
188+
if [[ ! "$artifact_path" =~ \.(gz|asc|sum|deb|rpm|zip)$ ]]; then
189+
echo "⏭️ Skipping: $artifact_path"
190+
continue
191+
fi
192+
193+
# Extract filename from path
194+
artifact_filename=$(basename "$artifact_path")
195+
196+
# Validate that filename contains the release tag
197+
if [[ ! "$artifact_filename" =~ $release_tag ]]; then
198+
echo "❌ Artifact filename does not contain release tag '$release_tag': $artifact_filename"
199+
exit 1
200+
fi
201+
183202
if [ -f "artifacts/$artifact_path" ]; then
184203
echo "⬆️ Uploading: $artifact_path"
185-
gh release upload ${{ needs.draft-release.outputs.release-tag }} \
204+
gh release upload "$release_tag" \
186205
"artifacts/$artifact_path" \
187206
--clobber
188207
else

.goreleaser.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,14 @@ release:
1111
### Draft Checklist
1212
- [ ] Tests from last nightly build have passed and are stable.
1313
- [ ] Release notes below have been reviewed and edited as needed.
14-
- [ ] Binaries from each distro have been built and are attached to the release.
15-
- [ ] nrdot-collector-host
16-
- [ ] nrdot-collector-k8s
14+
- [ ] Binaries/Archives/Packages.
15+
- [ ] Artifacts for each distro have been attached to the draft release
16+
- [ ] Any new artifact type is attached to the draft release (we filter on upload for expected file types)
1717
- [ ] Docker images for each distro have been published to ECR
18-
- [ ] nrdot-collector-host image published and tagged
19-
- [ ] nrdot-collector-k8s image published and tagged
2018
### Publish Checklist
2119
- [ ] Checklist has been reviewed and all items are complete.
2220
- [ ] Draft header has been removed.
2321
- [ ] Docker images for each distro have been published to docker hub and tagged as latest
24-
- [ ] [nrdot-collector-host](https://hub.docker.com/repository/docker/newrelic/nrdot-collector-host/tags) version {{ .Version }} tagged as latest
25-
- [ ] [nrdot-collector-k8s](https://hub.docker.com/repository/docker/newrelic/nrdot-collector-k8s/tags) version {{ .Version }} tagged as latest
2622
- [ ] Slack notifications have been sent to appropriate channels
2723
- [ ] PR has been generated to update docs in [docs.newrelic.com](https://github.com/newrelic/docs-website/pulls)
2824
###### !!! REMOVE THIS HEADER BEFORE PUBLISHING !!!

cmd/goreleaser/internal/configure.go

Lines changed: 79 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@ const (
3434
)
3535

3636
type Distribution struct {
37-
BaseName string
38-
FullName string // dist or dist-fips
39-
Fips bool
40-
Goos []string
41-
IgnoredBuilds []config.IgnoredBuild
42-
IncludeConfig bool
43-
SkipBinaries bool
44-
SkipArchives bool
37+
BaseName string
38+
FullName string // dist or dist-fips
39+
Fips bool
40+
Goos []string
41+
IgnoredBuilds []config.IgnoredBuild
42+
IncludeConfig bool
43+
SkipPackages bool
44+
SkipArchives bool
45+
SkipUploadToBlobStorage bool
46+
SkipChecksums bool
47+
SkipSigning bool
4548
}
4649

4750
var (
@@ -55,18 +58,14 @@ func Generate(distFlag string, fips bool) config.Project {
5558
dist := NewDistribution(distFlag, fips)
5659

5760
return config.Project{
58-
ProjectName: projectName,
59-
Checksum: config.Checksum{
60-
NameTemplate: "{{ .ArtifactName }}.sum",
61-
Split: true,
62-
Algorithm: "sha256",
63-
},
61+
ProjectName: projectName,
62+
Checksum: Checksum(dist),
6463
Builds: Builds(dist),
6564
Archives: Archives(dist),
6665
NFPMs: Packages(dist),
6766
Dockers: DockerImages(dist),
6867
DockerManifests: DockerManifests(dist),
69-
Signs: Sign(),
68+
Signs: Signs(dist),
7069
Version: 2,
7170
Changelog: config.Changelog{Disable: "true"},
7271
Snapshot: config.Snapshot{
@@ -97,34 +96,48 @@ func NewDistribution(baseDist string, fips bool) Distribution {
9796
IgnoredBuilds: []config.IgnoredBuild{
9897
{Goos: "windows", Goarch: "arm64"},
9998
},
100-
IncludeConfig: true,
101-
SkipBinaries: false,
102-
SkipArchives: false,
99+
IncludeConfig: true,
100+
SkipUploadToBlobStorage: false,
101+
SkipPackages: false,
102+
SkipArchives: false,
103+
SkipSigning: false,
104+
SkipChecksums: false,
103105
}
104106

105-
if baseDist == K8sDistro {
107+
if isNoConfigDistro(baseDist) {
106108
dist.IncludeConfig = false
107109
}
108110

109-
if baseDist == K8sDistro || fips {
111+
if isImageOnlyDistro(baseDist, fips) {
110112
dist.Goos = []string{"linux"}
111113
dist.IgnoredBuilds = nil
112-
dist.SkipBinaries = true
114+
dist.SkipPackages = true
113115
dist.SkipArchives = true
116+
dist.SkipUploadToBlobStorage = true
117+
dist.SkipSigning = true
118+
dist.SkipChecksums = true
114119
}
115120

116121
if baseDist == ExperimentalDistro {
117122
dist.Goos = []string{"linux"}
118123
dist.IgnoredBuilds = nil
119-
dist.IncludeConfig = false
120-
dist.SkipBinaries = true
124+
dist.SkipPackages = true
125+
dist.SkipUploadToBlobStorage = true
121126
}
122127

123128
return dist
124129
}
125130

131+
func isNoConfigDistro(dist string) bool {
132+
return dist == K8sDistro || dist == ExperimentalDistro
133+
}
134+
135+
func isImageOnlyDistro(dist string, fips bool) bool {
136+
return dist == K8sDistro || fips
137+
}
138+
126139
func Blobs(dist Distribution) []config.Blob {
127-
if dist.SkipBinaries {
140+
if dist.SkipUploadToBlobStorage {
128141
return nil
129142
}
130143

@@ -209,7 +222,12 @@ func Build(dist Distribution) config.Build {
209222

210223
func Archives(dist Distribution) []config.Archive {
211224
if dist.SkipArchives {
212-
return nil
225+
// https://goreleaser.com/customization/archive/#do-not-archive
226+
return []config.Archive{
227+
{
228+
Formats: []string{"binary"},
229+
},
230+
}
213231
}
214232

215233
return []config.Archive{
@@ -243,7 +261,7 @@ func Archive(dist Distribution) config.Archive {
243261
}
244262

245263
func Packages(dist Distribution) []config.NFPM {
246-
if dist.SkipBinaries {
264+
if dist.SkipPackages {
247265
return nil
248266
}
249267

@@ -411,21 +429,42 @@ func DockerManifest(version string, dist Distribution) config.DockerManifest {
411429
}
412430
}
413431

414-
func Sign() []config.Sign {
432+
func Checksum(dist Distribution) config.Checksum {
433+
if dist.SkipChecksums {
434+
return config.Checksum{
435+
Disable: true,
436+
}
437+
}
438+
return config.Checksum{
439+
NameTemplate: "{{ .ArtifactName }}.sum",
440+
Split: true,
441+
Algorithm: "sha256",
442+
}
443+
}
444+
445+
func Signs(dist Distribution) []config.Sign {
446+
if dist.SkipSigning {
447+
return nil
448+
}
449+
415450
return []config.Sign{
416-
{
417-
Artifacts: "all",
418-
Signature: "${artifact}.asc",
419-
Args: []string{
420-
"--batch",
421-
"-u",
422-
"{{ .Env.GPG_FINGERPRINT }}",
423-
"--output",
424-
"${signature}",
425-
"--detach-sign",
426-
"--armor",
427-
"${artifact}",
428-
},
451+
SignAllArtifacts(),
452+
}
453+
}
454+
455+
func SignAllArtifacts() config.Sign {
456+
return config.Sign{
457+
Artifacts: "all",
458+
Signature: "${artifact}.asc",
459+
Args: []string{
460+
"--batch",
461+
"-u",
462+
"{{ .Env.GPG_FINGERPRINT }}",
463+
"--output",
464+
"${signature}",
465+
"--detach-sign",
466+
"--armor",
467+
"${artifact}",
429468
},
430469
}
431470
}

distributions/nrdot-collector-experimental/.goreleaser-fips.yaml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ builds:
3535
env:
3636
- CC=aarch64-linux-gnu-gcc
3737
- CXX=aarch64-linux-gnu-g++
38+
archives:
39+
- formats:
40+
- binary
3841
snapshot:
3942
version_template: '{{ incpatch .Version }}-SNAPSHOT-{{.ShortCommit}}'
4043
checksum:
41-
name_template: '{{ .ArtifactName }}.sum'
42-
algorithm: sha256
43-
split: true
44+
disable: true
4445
dockers:
4546
- goos: linux
4647
goarch: amd64
@@ -81,15 +82,3 @@ docker_manifests:
8182
- '{{ .Env.REGISTRY }}/nrdot-collector-experimental:{{ .Version }}-fips-arm64'
8283
changelog:
8384
disable: "true"
84-
signs:
85-
- args:
86-
- --batch
87-
- -u
88-
- '{{ .Env.GPG_FINGERPRINT }}'
89-
- --output
90-
- ${signature}
91-
- --detach-sign
92-
- --armor
93-
- ${artifact}
94-
signature: ${artifact}.asc
95-
artifacts: all

distributions/nrdot-collector-host/.goreleaser-fips.yaml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ builds:
3535
env:
3636
- CC=aarch64-linux-gnu-gcc
3737
- CXX=aarch64-linux-gnu-g++
38+
archives:
39+
- formats:
40+
- binary
3841
snapshot:
3942
version_template: '{{ incpatch .Version }}-SNAPSHOT-{{.ShortCommit}}'
4043
checksum:
41-
name_template: '{{ .ArtifactName }}.sum'
42-
algorithm: sha256
43-
split: true
44+
disable: true
4445
dockers:
4546
- goos: linux
4647
goarch: amd64
@@ -85,15 +86,3 @@ docker_manifests:
8586
- '{{ .Env.REGISTRY }}/nrdot-collector-host:{{ .Version }}-fips-arm64'
8687
changelog:
8788
disable: "true"
88-
signs:
89-
- args:
90-
- --batch
91-
- -u
92-
- '{{ .Env.GPG_FINGERPRINT }}'
93-
- --output
94-
- ${signature}
95-
- --detach-sign
96-
- --armor
97-
- ${artifact}
98-
signature: ${artifact}.asc
99-
artifacts: all

distributions/nrdot-collector-k8s/.goreleaser-fips.yaml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ builds:
3535
env:
3636
- CC=aarch64-linux-gnu-gcc
3737
- CXX=aarch64-linux-gnu-g++
38+
archives:
39+
- formats:
40+
- binary
3841
snapshot:
3942
version_template: '{{ incpatch .Version }}-SNAPSHOT-{{.ShortCommit}}'
4043
checksum:
41-
name_template: '{{ .ArtifactName }}.sum'
42-
algorithm: sha256
43-
split: true
44+
disable: true
4445
dockers:
4546
- goos: linux
4647
goarch: amd64
@@ -81,15 +82,3 @@ docker_manifests:
8182
- '{{ .Env.REGISTRY }}/nrdot-collector-k8s:{{ .Version }}-fips-arm64'
8283
changelog:
8384
disable: "true"
84-
signs:
85-
- args:
86-
- --batch
87-
- -u
88-
- '{{ .Env.GPG_FINGERPRINT }}'
89-
- --output
90-
- ${signature}
91-
- --detach-sign
92-
- --armor
93-
- ${artifact}
94-
signature: ${artifact}.asc
95-
artifacts: all

distributions/nrdot-collector-k8s/.goreleaser.yaml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ builds:
2121
env:
2222
- CGO_ENABLED=0
2323
- GOEXPERIMENT=
24+
archives:
25+
- formats:
26+
- binary
2427
snapshot:
2528
version_template: '{{ incpatch .Version }}-SNAPSHOT-{{.ShortCommit}}'
2629
checksum:
27-
name_template: '{{ .ArtifactName }}.sum'
28-
algorithm: sha256
29-
split: true
30+
disable: true
3031
dockers:
3132
- goos: linux
3233
goarch: amd64
@@ -73,15 +74,3 @@ docker_manifests:
7374
- '{{ .Env.REGISTRY }}/nrdot-collector-k8s:latest-arm64'
7475
changelog:
7576
disable: "true"
76-
signs:
77-
- args:
78-
- --batch
79-
- -u
80-
- '{{ .Env.GPG_FINGERPRINT }}'
81-
- --output
82-
- ${signature}
83-
- --detach-sign
84-
- --armor
85-
- ${artifact}
86-
signature: ${artifact}.asc
87-
artifacts: all

0 commit comments

Comments
 (0)