Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build version qualifier #8310

Merged
merged 3 commits into from
Sep 18, 2018
Merged

Conversation

graphaelli
Copy link
Member

using the BEAT_VERSION_QUALIFIER environment variable.

This produces the expected packages:

default (on master)

$ mage package
# produces
build/distributions/auditbeat-7.0.0-i686.rpm
build/distributions/auditbeat-7.0.0-darwin-x86_64.dmg
build/distributions/auditbeat-7.0.0-darwin-x86_64.tar.gz
build/distributions/auditbeat-7.0.0-i386.deb
build/distributions/auditbeat-7.0.0-x86_64.rpm
build/distributions/auditbeat-7.0.0-amd64.deb
build/distributions/auditbeat-7.0.0-linux-x86_64.tar.gz
build/distributions/auditbeat-7.0.0-linux-x86.tar.gz
build/distributions/auditbeat-7.0.0-windows-x86_64.zip
build/distributions/auditbeat-7.0.0-windows-x86.zip
...

# contents have no build qualifier
$ tar tzvf build/distributions/auditbeat-7.0.0-linux-x86_64.tar.gz 
-rwxr-xr-x  0 root   root 35414362 Sep 13 15:41 auditbeat-7.0.0-linux-x86_64/auditbeat
...

# binary still has qualifier for now
$ ./build/distributions/auditbeat-7.0.0-darwin-x86_64/Library/Application\ Support/Elastic/auditbeat/bin/auditbeat version
auditbeat version 7.0.0-alpha1 (amd64), libbeat 7.0.0-alpha1 [b3acf68963da81253e09d816ea47fe2d226c435f built 2018-09-13 19:41:23 +0000 UTC]

alpha2

$ BEAT_VERSION_QUALIFIER=alpha2 mage package
## produces
build/distributions/auditbeat-7.0.0-alpha2-darwin-x86_64.dmg
build/distributions/auditbeat-7.0.0-alpha2-darwin-x86_64.tar.gz
...

## contents have build qualifier
$ tar tzvf build/distributions/auditbeat-7.0.0-alpha2-darwin-x86_64.tar.gz
-rwxr-xr-x  0 root   root 26074952 Sep 13 16:04 auditbeat-7.0.0-alpha2-darwin-x86_64/auditbeat
...

# binary has externally specified build qualifier
$ ./build/distributions/auditbeat-7.0.0-alpha2-darwin-x86_64/Library/Application\ Support/Elastic/auditbeat/bin/auditbeat version
auditbeat version 7.0.0-alpha2 (amd64), libbeat 7.0.0-alpha2 [021a9e0b2126ba61362be8b01c66a29121c76326 built 2018-09-13 20:46:09 +0000 UTC]

release (empty but set build qualifier)

$ BEAT_VERSION_QUALIFIER= mage -v package
## produces
build/distributions/auditbeat-7.0.0-darwin-x86_64.dmg
build/distributions/auditbeat-7.0.0-darwin-x86_64.tar.gz
...

## contents have no build qualifier
$ tar tzvf build/distributions/auditbeat-7.0.0-darwin-x86_64.tar.gz
-rw-r--r--  0 root   root    13675 Aug 20 15:01 auditbeat-7.0.0-darwin-x86_64/LICENSE.txt
...

## binary has no build qualifier
$ ./build/distributions/auditbeat-7.0.0-darwin-x86_64/Library/Application\ Support/Elastic/auditbeat/bin/auditbeat version
auditbeat version 7.0.0 (amd64), libbeat 7.0.0 [021a9e0b2126ba61362be8b01c66a29121c76326 built 2018-09-13 20:48:04 +0000 UTC]

README templates were already version aware, eg the alpha2 build produced:

README.md
1:# Welcome to Auditbeat 7.0.0-alpha2
27:https://www.elastic.co/guide/en/beats/libbeat/master/release-notes-7.0.0-alpha2.html

This change leaves a default embedded version qualifier alpha1 in place, to be removed when release manager is updated to pass one in.

I propose we update kibana template versions with embedded "version": "7.0.0-alpha1" separately.

closes #8186

@@ -98,6 +101,8 @@ func init() {
if err != nil {
panic(errors.Errorf("failed to parse SNAPSHOT env value", err))
}

versionQualifier, versionQualified = os.LookupEnv("BEAT_VERSION_QUALIFIER")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand versionQualified is always == versionQualifier != "". Would it make sense to remove that variable to avoid confusion?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do that once the default build qualifier is empty. See the description where mage package produces a binary where the version subcommand is different than that produced by BEAT_VERSION_QUALIFIER= mage package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do that immediately if we update release manager first.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks for the clarification

@tsg tsg requested a review from andrewkroh September 17, 2018 09:40
@tsg
Copy link
Contributor

tsg commented Sep 17, 2018

@andrewkroh FYI, I dropped my PR in favour of this, because we've got the requirements wrong. Can you review this one, please?

Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks @graphaelli

@@ -310,6 +317,20 @@ var (
beatVersionOnce sync.Once
)

// BeatQualifiedVersion returns the Beat's qualified version. The value can be overwritten by
// setting BEAT_VERSION_QUALIFIER in the environment.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think we should put BEAT_VERSION_QUALIFIER in the godocs for the release targets (duplicated in each magefile)?

filebeat akroh$ mage -h package
mage package:

Package packages the Beat for distribution.
Use SNAPSHOT=true to build snapshots.
Use PLATFORMS to control the target platforms.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea, I'll add that now.

per review feedback.
Copy link
Contributor

@tsg tsg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Tested a bit and looks good from what I can see.

@graphaelli graphaelli merged commit 8137c44 into elastic:master Sep 18, 2018
@graphaelli graphaelli deleted the build-version-qualifier branch September 18, 2018 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow the build process to receive a version qualifier at compile time
4 participants