Skip to content

Commit a94d342

Browse files
committed
add nightly release setup with pipeline and goreleaser settings
update goreleaser config with nightly settings use different token to push nightly tag revert core ci, change to pushing nightly tags prepare otelcol goreleaser setup for testing add new pipeline
1 parent 620847d commit a94d342

File tree

9 files changed

+154
-262
lines changed

9 files changed

+154
-262
lines changed

.github/workflows/base-release.yaml

Lines changed: 52 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ env:
2323

2424
jobs:
2525
prepare:
26+
outputs:
27+
GORELEASER_PREVIOUS_TAG: ${{ steps.prev-tag.outputs.GORELEASER_PREVIOUS_TAG }}
2628
strategy:
2729
matrix:
2830
GOOS: ${{ fromJSON(inputs.goos) }}
@@ -70,21 +72,38 @@ jobs:
7072
go-version: "~1.24"
7173
check-latest: true
7274

73-
- name: Generate distribution sources
74-
run: make generate-sources
75+
- name: Set GORELEASER_PREVIOUS_TAG in actual release
76+
id: prev-tag
77+
if: ${{ !contains(github.ref, '-nightly') }}
78+
# find previous tag by filtering out nightly tags and choosing the
79+
# second to last tag (last one is the current release)
80+
run: |
81+
prev_tag=$(git tag | grep -v "nightly" | sort -r --version-sort | head -n 2 | tail -n 1)
82+
echo "GORELEASER_PREVIOUS_TAG=$prev_tag" >> "$GITHUB_OUTPUT"
7583
76-
- name: Log into Docker.io
77-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
78-
with:
79-
username: ${{ secrets.DOCKER_USERNAME }}
80-
password: ${{ secrets.DOCKER_PASSWORD }}
84+
- name: Set nightly enabled
85+
id: nightly-check
86+
if: contains(github.ref, '-nightly')
87+
run: |
88+
echo "NIGHTLY_FLAG=--nightly" >> "$GITHUB_OUTPUT"
8189
82-
- name: Login to GitHub Package Registry
83-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
84-
with:
85-
registry: ghcr.io
86-
username: ${{ github.repository_owner }}
87-
password: ${{ secrets.GITHUB_TOKEN }}
90+
- name: Generate distribution sources
91+
run: make generate-sources
92+
env:
93+
DISTRIBUTIONS: ${{ inputs.distribution }}
94+
95+
# - name: Log into Docker.io
96+
# uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
97+
# with:
98+
# username: ${{ secrets.DOCKER_USERNAME }}
99+
# password: ${{ secrets.DOCKER_PASSWORD }}
100+
#
101+
# - name: Login to GitHub Package Registry
102+
# uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
103+
# with:
104+
# registry: ghcr.io
105+
# username: ${{ github.repository_owner }}
106+
# password: ${{ secrets.GITHUB_TOKEN }}
88107

89108
- name: Create artifacts directory to store build artifacts
90109
if: inputs.distribution == 'otelcol-contrib'
@@ -99,16 +118,17 @@ jobs:
99118
distribution: goreleaser-pro
100119
version: ${{ env.GORELEASER_PRO_VERSION }}
101120
workdir: distributions/${{ inputs.distribution }}
102-
args: release --clean --split --timeout 2h --config .goreleaser-build.yaml --release-header-tmpl=../../.github/release-template.md
121+
args: release --clean --split --timeout 2h --config .goreleaser-build.yaml --release-header-tmpl=../../.github/release-template.md ${{ steps.nightly-check.outputs.NIGHTLY_FLAG }}
103122
env:
104123
GOOS: ${{ matrix.GOOS }}
105124
GOARCH: ${{ matrix.GOARCH }}
106125
GOARM: "7" # Default is 6
107126
GOAMD64: v1
108127
GOPPC64: power8
109128
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
110-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111130
COSIGN_YES: true
131+
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
112132

113133
- name: Move built artifacts
114134
if: inputs.distribution == 'otelcol-contrib'
@@ -125,12 +145,12 @@ jobs:
125145
distribution: goreleaser-pro
126146
version: ${{ env.GORELEASER_PRO_VERSION }}
127147
workdir: distributions/${{ inputs.distribution }}
128-
args: release --clean --split --timeout 2h --release-header-tmpl=../../.github/release-template.md
148+
args: release --clean --split --timeout 2h --release-header-tmpl=../../.github/release-template.md ${{ steps.nightly-check.outputs.NIGHTLY_FLAG }}
129149
env:
130150
GOOS: ${{ matrix.GOOS }}
131151
GOARCH: ${{ matrix.GOARCH }}
132152
GOARM: 7 # Default is 6
133-
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
153+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
134154
COSIGN_YES: true
135155
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
136156

@@ -141,7 +161,7 @@ jobs:
141161
if-no-files-found: error
142162

143163
release:
144-
name: ${{ inputs.distribution }} Release
164+
name: Release
145165
runs-on: ${{ inputs.runner_os }}
146166
needs: prepare
147167

@@ -207,18 +227,18 @@ jobs:
207227
shell: bash
208228
run: ls -R distributions/${{ inputs.distribution }}/dist
209229

210-
- name: Log into Docker.io
211-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
212-
with:
213-
username: ${{ secrets.DOCKER_USERNAME }}
214-
password: ${{ secrets.DOCKER_PASSWORD }}
215-
216-
- name: Login to GitHub Package Registry
217-
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
218-
with:
219-
registry: ghcr.io
220-
username: ${{ github.repository_owner }}
221-
password: ${{ secrets.GITHUB_TOKEN }}
230+
# - name: Log into Docker.io
231+
# uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
232+
# with:
233+
# username: ${{ secrets.DOCKER_USERNAME }}
234+
# password: ${{ secrets.DOCKER_PASSWORD }}
235+
#
236+
# - name: Login to GitHub Package Registry
237+
# uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
238+
# with:
239+
# registry: ghcr.io
240+
# username: ${{ github.repository_owner }}
241+
# password: ${{ secrets.GITHUB_TOKEN }}
222242

223243
- uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
224244
with:
@@ -230,3 +250,5 @@ jobs:
230250
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
231251
COSIGN_YES: true
232252
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
253+
GORELEASER_PREVIOUS_TAG: ${{ needs.prepare.outputs.GORELEASER_PREVIOUS_TAG }}
254+
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}

.github/workflows/ci-goreleaser-core.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: CI - Core - GoReleaser
22

33
on:
4-
merge_group:
4+
merge_group:
55
push:
66
branches: [main]
77
paths:
@@ -34,12 +34,12 @@ jobs:
3434
secrets: inherit
3535

3636
package-tests:
37-
name: Package tests
38-
needs: check-goreleaser
39-
uses: ./.github/workflows/base-package-tests.yaml
40-
with:
41-
distribution: otelcol
42-
type: '[ "deb", "rpm" ]'
37+
name: Package tests
38+
needs: check-goreleaser
39+
uses: ./.github/workflows/base-package-tests.yaml
40+
with:
41+
distribution: otelcol
42+
type: '[ "deb", "rpm" ]'
4343

4444
msi-tests:
4545
name: MSI tests
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Nightly Release
2+
3+
on:
4+
workflow_dispatch:
5+
# schedule
6+
7+
permissions:
8+
contents: read
9+
10+
env:
11+
# renovate: datasource=github-tags depName=goreleaser-pro packageName=goreleaser/goreleaser-pro
12+
GORELEASER_PRO_VERSION: v2.7.0
13+
14+
jobs:
15+
nightly-release:
16+
name: Nightly Release
17+
runs-on: ubuntu-latest
18+
19+
permissions:
20+
contents: write
21+
22+
steps:
23+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
with:
25+
fetch-depth: 0
26+
token: ${{ secrets.GH_PAT }}
27+
28+
- name: 'Push new tag'
29+
run: |
30+
git config user.name "${GITHUB_ACTOR}"
31+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
32+
33+
# A previous release was created using a lightweight tag
34+
# git describe by default includes only annotated tags
35+
# git describe --tags includes lightweight tags as well
36+
DESCRIBE=`git tag -l --sort=-v:refname | grep -v nightly | head -n 1`
37+
MAJOR_VERSION=`echo $DESCRIBE | awk '{split($0,a,"."); print a[1]}'`
38+
MINOR_VERSION=`echo $DESCRIBE | awk '{split($0,a,"."); print a[2]}'`
39+
MINOR_VERSION="$((${MINOR_VERSION} + 1))"
40+
TAG="${MAJOR_VERSION}.${MINOR_VERSION}.0-nightly.$(date +'%Y%m%d%H%M')"
41+
git tag -a $TAG -m "$TAG: nightly build"
42+
git push origin $TAG

.github/workflows/release-core.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ jobs:
1414
goarch: '[ "386", "amd64", "arm64", "ppc64le", "arm", "s390x" ]'
1515
secrets: inherit
1616
permissions: write-all
17-
release-windows:
18-
name: Release Core (Windows)
19-
uses: ./.github/workflows/base-release.yaml
20-
with:
21-
distribution: otelcol
22-
goos: '[ "windows" ]'
23-
goarch: '[ "386", "amd64" ]'
24-
runner_os: windows-2022
25-
secrets: inherit
26-
permissions: write-all
17+
# release-windows:
18+
# name: Release Core (Windows)
19+
# uses: ./.github/workflows/base-release.yaml
20+
# with:
21+
# distribution: otelcol
22+
# goos: '[ "windows" ]'
23+
# goarch: '[ "386", "amd64" ]'
24+
# runner_os: windows-2022
25+
# secrets: inherit
26+
# permissions: write-all

cmd/goreleaser/internal/configure.go

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ const (
3535
k8sDistro = "otelcol-k8s"
3636
otlpDistro = "otelcol-otlp"
3737
ebpfProfilerDistro = "otelcol-ebpf-profiler"
38-
dockerHub = "otel"
39-
ghcr = "ghcr.io/open-telemetry/opentelemetry-collector-releases"
40-
binaryNamePrefix = "otelcol"
41-
imageNamePrefix = "opentelemetry-collector"
38+
dockerHub = "otel"
39+
ghcr = "ghcr.io/open-telemetry/opentelemetry-collector-releases"
40+
binaryNamePrefix = "otelcol"
41+
imageNamePrefix = "opentelemetry-collector"
4242
)
4343

4444
var (
@@ -58,14 +58,8 @@ var (
5858
&fullBuildConfig{targetOS: "darwin", targetArch: darwinArchs},
5959
&fullBuildConfig{targetOS: "windows", targetArch: winArchs},
6060
}
61-
d.containerImages = slices.Concat(
62-
newContainerImages(d.name, "linux", baseArchs, containerImageOptions{armVersion: "7"}),
63-
newContainerImages(d.name, "windows", winContainerArchs, containerImageOptions{winVersion: "2019"}),
64-
newContainerImages(d.name, "windows", winContainerArchs, containerImageOptions{winVersion: "2022"}),
65-
)
66-
d.containerImageManifests = slices.Concat(
67-
newContainerImageManifests(d.name, "linux", baseArchs, containerImageOptions{}),
68-
)
61+
d.containerImages = nil
62+
d.containerImageManifests = nil
6963
}).WithPackagingDefaults().WithDefaultConfigIncluded().Build()
7064

7165
// otlp distro
@@ -143,7 +137,7 @@ var (
143137
d.containerImageManifests = slices.Concat(
144138
newContainerImageManifests(d.name, "linux", k8sArchs, containerImageOptions{}),
145139
)
146-
}).WithDefaultArchives().WithDefaultChecksum().WithDefaultSigns().WithDefaultDockerSigns().WithDefaultSBOMs().Build()
140+
}).WithDefaultArchives().WithDefaultChecksum().WithDefaultSigns().WithDefaultDockerSigns().WithDefaultSBOMs().WithNightlyConfig().Build()
147141

148142
// ebpf-profiler distro
149143
ebpfProfilerDist = newDistributionBuilder(ebpfProfilerDistro).WithConfigFunc(func(d *distribution) {
@@ -315,6 +309,22 @@ func (b *distributionBuilder) dockerSigns() []config.Sign {
315309
}
316310
}
317311

312+
func (b *distributionBuilder) WithNightlyConfig() *distributionBuilder {
313+
b.configFuncs = append(b.configFuncs, func(d *distribution) {
314+
b.dist.nightly = b.nightly()
315+
})
316+
return b
317+
}
318+
319+
func (b *distributionBuilder) nightly() config.Nightly {
320+
return config.Nightly{
321+
VersionTemplate: "{{ incpatch .Version}}-nightly.{{ .Now.Format \"200601021504\" }}",
322+
TagName: "nightly",
323+
PublishRelease: true,
324+
KeepSingleRelease: false,
325+
}
326+
}
327+
318328
func (b *distributionBuilder) WithDefaultSBOMs() *distributionBuilder {
319329
b.configFuncs = append(b.configFuncs, func(d *distribution) {
320330
d.sboms = b.sboms()
@@ -351,7 +361,8 @@ func (b *distributionBuilder) WithPackagingDefaults() *distributionBuilder {
351361
WithDefaultMSIConfig().
352362
WithDefaultSigns().
353363
WithDefaultDockerSigns().
354-
WithDefaultSBOMs()
364+
WithDefaultSBOMs().
365+
WithNightlyConfig()
355366
}
356367

357368
func (b *distributionBuilder) WithConfigFunc(configFunc func(*distribution)) *distributionBuilder {
@@ -402,6 +413,7 @@ type distribution struct {
402413
signs []config.Sign
403414
dockerSigns []config.Sign
404415
sboms []config.SBOM
416+
nightly config.Nightly
405417
checksum config.Checksum
406418
enableCgo bool
407419
ldFlags string
@@ -447,6 +459,7 @@ func (d *distribution) BuildProject() config.Project {
447459
Signs: d.signs,
448460
DockerSigns: d.dockerSigns,
449461
SBOMs: d.sboms,
462+
Nightly: d.nightly,
450463
Version: 2,
451464
Monorepo: config.Monorepo{
452465
TagPrefix: "v",

distributions/otelcol-contrib/.goreleaser.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,3 +329,7 @@ monorepo:
329329
tag_prefix: v
330330
partial:
331331
by: target
332+
nightly:
333+
version_template: '{{ incpatch .Version}}-nightly.{{ .Now.Format "200601021504" }}'
334+
tag_name: nightly
335+
publish_release: true

distributions/otelcol-k8s/.goreleaser.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,7 @@ monorepo:
209209
tag_prefix: v
210210
partial:
211211
by: target
212+
nightly:
213+
version_template: '{{ incpatch .Version}}-nightly.{{ .Now.Format "200601021504" }}'
214+
tag_name: nightly
215+
publish_release: true

distributions/otelcol-otlp/.goreleaser.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,3 +304,7 @@ monorepo:
304304
tag_prefix: v
305305
partial:
306306
by: target
307+
nightly:
308+
version_template: '{{ incpatch .Version}}-nightly.{{ .Now.Format "200601021504" }}'
309+
tag_name: nightly
310+
publish_release: true

0 commit comments

Comments
 (0)