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

Set version to unknown if not set #4521

Merged
merged 1 commit into from
Aug 12, 2018
Merged

Set version to unknown if not set #4521

merged 1 commit into from
Aug 12, 2018

Conversation

danielnelson
Copy link
Contributor

Prevents setting the branch version to the last major release, and as a bonus we no longer need to set this variable on release:

$ go build -ldflags "-X main.version=1.8.0 -X main.commit=fa08656a -X main.branch=default-version" ./cmd/telegraf
$ ./telegraf version
Telegraf 1.8.0 (git: default-version fa08656a)
$ go build -ldflags " -X main.commit=fa08656a -X main.branch=default-version" ./cmd/telegraf
$ ./telegraf version
Telegraf unknown (git: default-version fa08656a)
$ go build ./cmd/telegraf
$ ./telegraf version
Telegraf unknown

closes #4516

Required for all PRs:

  • Signed CLA.
  • Associated README.md updated.
  • Has appropriate unit tests.

@danielnelson danielnelson added area/packaging fix pr to fix corresponding bug labels Aug 6, 2018
@danielnelson danielnelson added this to the 1.8.0 milestone Aug 6, 2018
@kaspergrubbe
Copy link

Wouldn't it be better to update the variable nextVersion to match the release tag when a release is made?

So if I checkout 1.8.1 from git then nextVersion would be set to 1.8.1.

Or did you already do this and forgot? I wonder if it is easy to automate.

I do not know your release procedures, but I guess a script like this would help you:

if tagname.nil?
  STDOUT.puts "USAGE:"
  STDOUT.puts "To tag: git_tag_and_push.rb tagname"
  exit 1
else
  # Update the version
  system("sed -i \"s/1.7.0/1.8.0/g\" cmd/telegraf/telegraf.go")

  # Add the new file, and commit
  system("git add cmd/telegraf/telegraf.go")
  system("git commit -m 'Update version number #{tagname}'")

  # Add the tag
  system("git tag -a #{tagname} -m 'Tagging for release: #{tagname}'")

  system("git push origin #{tagname}")
end

@danielnelson
Copy link
Contributor Author

Wouldn't it be better to update the variable nextVersion to match the release tag when a release is made?

I think this is a valid argument but I would prefer to have one less step when it comes to preparing a release. My philosophy here is that if it isn't a release then it doesn't have a version. I highly recommend that you use the Makefile to ensure this is set automatically when building a tag.

@kaspergrubbe
Copy link

Fair enough, thanks for pointing out the Makefile, I missed the versioning that it does 👍

I noticed that the build-task in the Makefile does not include -w -s as you recommended in #4516 is that on purpose?

Thanks.

@danielnelson
Copy link
Contributor Author

We use the ldflags in the official builds because they shrink the size of the binary, but not during development. You probably want these flags if you are not planning to use a debugger, although I'm not sure exactly how much the functionality is limited by stripping symbols.

The official releases are made using scripts/build.py, at some point I would like this script to call the Makefile to create the binaries but it's not a big priority.

@danielnelson danielnelson merged commit 31e1c04 into master Aug 12, 2018
@danielnelson danielnelson deleted the default-version branch August 12, 2018 23:52
rgitzel pushed a commit to rgitzel/telegraf that referenced this pull request Oct 17, 2018
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
dupondje pushed a commit to dupondje/telegraf that referenced this pull request Apr 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/packaging fix pr to fix corresponding bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong version reported after building Telegraf
3 participants