Skip to content

Commit 1de0ae1

Browse files
authored
Add support for VERSION_QUALIFIER DRA (#2920)
* Add support for VERSION_QUALIFIER * add qualifier to binary version output * add qualifier to binary version output * shfmt * consistency on VERSION_QUALIFIER expansio * set VERSION_QUALIFIER for main branch to alpha1 (temporary)
1 parent cbadcb7 commit 1de0ae1

File tree

6 files changed

+33
-5
lines changed

6 files changed

+33
-5
lines changed

.buildkite/pipeline.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ agents:
55
image: "family/platform-ingest-beats-ubuntu-2204"
66

77
steps:
8+
# TODO: this will be removed/changed for 9.0 branch
9+
- label: ":writing_hand: Conditionally set VERSION_QUALIFIER for main branch"
10+
if: build.branch == "main"
11+
env:
12+
VERSION_QUALIFIER: "alpha1"
13+
command: "echo 'Setting VERSION_QUALIFIER for branch main'"
14+
815
- label: ":package: Package Cloudbeat - Snapshot"
916
if: build.branch == 'main' || build.branch =~ /^[0-9]+\.[0-9x]+\$/ || build.env("RUN_RELEASE") == "true"
1017
env:
@@ -20,16 +27,19 @@ steps:
2027
env:
2128
WORKFLOW: "snapshot"
2229

30+
# Allow building staging from main when VERSION_QUALIFIER is set (allow prerelease testing)
31+
# TODO remove || build.env('VERSION_QUALIFIER') != null
2332
- label: ":package: Package Cloudbeat - Staging"
24-
if: build.branch =~ /^[0-9]+\.[0-9]+\$/ || build.env("RUN_RELEASE") == "true"
33+
if: build.branch =~ /^[0-9]+\.[0-9]+\$/ || build.env("RUN_RELEASE") == "true" || build.env('VERSION_QUALIFIER') != null
2534
env:
2635
WORKFLOW: "staging"
2736
key: "package-staging"
2837
command: "./.buildkite/scripts/package.sh"
2938
artifact_paths: "build/distributions/*"
3039

40+
# TODO remove || build.env('VERSION_QUALIFIER') != null
3141
- label: ":rocket: Publishing Staging DRA artifacts"
32-
if: build.branch =~ /^[0-9]+\.[0-9]+\$/ || build.env("RUN_RELEASE") == "true"
42+
if: build.branch =~ /^[0-9]+\.[0-9]+\$/ || build.env("RUN_RELEASE") == "true" || build.env('VERSION_QUALIFIER') != null
3343
depends_on: "package-staging"
3444
command: "./.buildkite/scripts/publish.sh"
3545
env:

.buildkite/scripts/package.sh

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ source ./bin/activate-hermit
88
CLOUDBEAT_VERSION=$(grep defaultBeatVersion version/version.go | cut -d'=' -f2 | tr -d '" ')
99
PYTHON_BIN=./build/ve/$(go env GOOS)/bin
1010
PYTHON=$PYTHON_BIN/python
11+
VERSION_QUALIFIER="${VERSION_QUALIFIER:-""}"
1112

1213
if [ "$WORKFLOW" = "snapshot" ]; then
1314
export SNAPSHOT="true"
@@ -21,6 +22,9 @@ mage package
2122

2223
CSV_FILE="build/dependencies-${CLOUDBEAT_VERSION}"
2324
[ -n "${SNAPSHOT+x}" ] && CSV_FILE+="-SNAPSHOT"
25+
if [[ -n "$VERSION_QUALIFIER" ]]; then
26+
CSV_FILE+="-${VERSION_QUALIFIER}"
27+
fi
2428

2529
echo "Generating $CSV_FILE.csv"
2630
$PYTHON ./.buildkite/scripts/generate_notice.py --csv "$CSV_FILE.csv"

.buildkite/scripts/publish.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ elif [ -n "$(git ls-remote --heads origin $MAJOR.x)" ]; then
1313
else
1414
BRANCH=main
1515
fi
16+
VERSION_QUALIFIER="${VERSION_QUALIFIER:-""}"
1617

1718
# Download artifacts from other stages
1819
echo "Downloading artifacts..."
@@ -38,4 +39,5 @@ docker run --rm \
3839
--commit "${BUILDKITE_COMMIT}" \
3940
--workflow "${WORKFLOW}" \
4041
--version "${VERSION}" \
41-
--artifact-set main
42+
--artifact-set main \
43+
--qualifier "${VERSION_QUALIFIER}"

magefile.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ import (
4949
)
5050

5151
const (
52-
snapshotEnv = "SNAPSHOT"
53-
agentDropPath = "AGENT_DROP_PATH"
52+
snapshotEnv = "SNAPSHOT"
53+
agentDropPath = "AGENT_DROP_PATH"
54+
cloudbeatModulePath = "github.com/elastic/cloudbeat"
5455
)
5556

5657
func init() {
@@ -80,6 +81,9 @@ func Build() error {
8081

8182
args := devtools.DefaultBuildArgs()
8283
args.CGO = false
84+
if versionQualifier, versionQualified := os.LookupEnv("VERSION_QUALIFIER"); versionQualified {
85+
args.Vars[cloudbeatModulePath+"/version.qualifier"] = versionQualifier
86+
}
8387
return devtools.Build(args)
8488
}
8589

@@ -95,6 +99,9 @@ func Clean() error {
9599
func GolangCrossBuild() error {
96100
args := devtools.DefaultGolangCrossBuildArgs()
97101
args.CGO = false
102+
if versionQualifier, versionQualified := os.LookupEnv("VERSION_QUALIFIER"); versionQualified {
103+
args.Vars[cloudbeatModulePath+"/version.qualifier"] = versionQualifier
104+
}
98105
return devtools.GolangCrossBuild(args)
99106
}
100107

version/settings.go

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ func cloudbeatCommitTime() string {
5252

5353
// CloudbeatSemanticVersion returns the current cloudbeat version.
5454
func CloudbeatSemanticVersion() string {
55+
if qualifier != "" {
56+
return defaultBeatVersion + "-" + qualifier
57+
}
5558
return defaultBeatVersion
5659
}
5760

version/version.go

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ package version
2020
// name matches github.com/elastic/beats/v7/dev-tools/mage/settings.go parseBeatVersion
2121
const defaultBeatVersion = "9.0.0"
2222

23+
var qualifier = ""
24+
2325
// Version represents version information for a package
2426
type Version struct {
2527
Version string `mapstructure:"version,omitempty"` // Version is the semantic version of the package

0 commit comments

Comments
 (0)