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

Add version #154

Merged
merged 6 commits into from
Feb 16, 2024
Merged

Add version #154

merged 6 commits into from
Feb 16, 2024

Conversation

aufi
Copy link
Member

@aufi aufi commented Feb 14, 2024

Adding tool version to CLI that should return version number and commit hash. Usage: kantra version.

The version can be setup when building the kantra, example:

$ go build --ldflags="-X 'github.com/konveyor-ecosystem/kantra/cmd.Version=1.1.1' -X 'github.com/konveyor-ecosystem/kantra/cmd.BuildCommit=$(git rev-parse HEAD)'"
$ ./kantra version
version: 1.1.1
SHA: 75daa9736c52e85cad832d1cd2eb95d2d98dad8e

The default development version 99.0.0 follows operator and UI convention.

Fixes: https://issues.redhat.com/browse/MTA-2201

Adding tool version to CLI that should return version number and commit
hash. Usage: `kantra version`.

Fixes: https://issues.redhat.com/browse/MTA-2201

Signed-off-by: Marek Aufart <maufart@redhat.com>
Signed-off-by: Marek Aufart <maufart@redhat.com>
@aufi
Copy link
Member Author

aufi commented Feb 14, 2024

@djzager @fbladilo Hi, would it be possible set the CLI tool version with ldflags on build or is it needed to use another way? Thanks!

Copy link
Member

@djzager djzager left a comment

Choose a reason for hiding this comment

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

Hi, would it be possible set the CLI tool version with ldflags on build or is it needed to use another way? Thanks!

For the upstream:

  1. Update the Dockerfile go build(s) that takes the version/git as ARG
  2. Update the workflow that passes the version stuff along to the build step.

Copy link
Contributor

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

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

I will defer to @djzager on this one, once he is happy that this doesn't break the build system the new command looks fine to me

Signed-off-by: Marek Aufart <maufart@redhat.com>
Signed-off-by: Marek Aufart <maufart@redhat.com>
Signed-off-by: Marek Aufart <maufart@redhat.com>
@aufi
Copy link
Member Author

aufi commented Feb 16, 2024

Hi, would it be possible set the CLI tool version with ldflags on build or is it needed to use another way? Thanks!

For the upstream:

  1. Update the Dockerfile go build(s) that takes the version/git as ARG
  2. Update the workflow that passes the version stuff along to the build step.

Thanks David! Arguments were added to Dockerfile and workflows. The VERSION should be read from tag in release-tools build env and the BUILD_COMMIT is set to env using pre_build_cmd.

@aufi aufi requested a review from djzager February 16, 2024 11:01
Copy link
Member

@djzager djzager left a comment

Choose a reason for hiding this comment

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

Lgtm

cmd/version.go Outdated Show resolved Hide resolved
Co-authored-by: David Zager <dzager@redhat.com>
Signed-off-by: Marek Aufart <aufi.cz@gmail.com>
@eemcmullan eemcmullan merged commit 2437f36 into konveyor:main Feb 16, 2024
2 checks passed
aufi added a commit to aufi/kantra that referenced this pull request Feb 16, 2024
Using github variables to provide version and commit sha variables for
build.

Follow-up to konveyor#154

Signed-off-by: Marek Aufart <maufart@redhat.com>
aufi added a commit to aufi/kantra that referenced this pull request Feb 16, 2024
Using github variables to provide version and commit sha variables for
build.

Follow-up to konveyor#154

Signed-off-by: Marek Aufart <maufart@redhat.com>
djzager pushed a commit that referenced this pull request Feb 16, 2024
Fix version variables evaluation in build

Using github variables to provide version and commit sha variables for
build.

Follow-up to #154

Signed-off-by: Marek Aufart <maufart@redhat.com>
@aufi aufi added the cherry-pick/release-0.3 This PR should be cherry-picked to release-0.3 branch. label Feb 19, 2024
aufi added a commit to aufi/kantra that referenced this pull request Feb 21, 2024
* Add version command

Adding tool version to CLI that should return version number and commit
hash. Usage: `kantra version`.

Fixes: https://issues.redhat.com/browse/MTA-2201

Signed-off-by: Marek Aufart <maufart@redhat.com>

* Update build flags

Signed-off-by: Marek Aufart <maufart@redhat.com>

* Update build scripts

Signed-off-by: Marek Aufart <maufart@redhat.com>

* Try fix buildah cmd

Signed-off-by: Marek Aufart <maufart@redhat.com>

* Set buildcommit before

Signed-off-by: Marek Aufart <maufart@redhat.com>

* Update cmd/version.go

Co-authored-by: David Zager <dzager@redhat.com>
Signed-off-by: Marek Aufart <aufi.cz@gmail.com>

---------

Signed-off-by: Marek Aufart <maufart@redhat.com>
Signed-off-by: Marek Aufart <aufi.cz@gmail.com>
Co-authored-by: David Zager <dzager@redhat.com>
aufi added a commit to aufi/kantra that referenced this pull request Feb 21, 2024
Fix version variables evaluation in build

Using github variables to provide version and commit sha variables for
build.

Follow-up to konveyor#154

Signed-off-by: Marek Aufart <maufart@redhat.com>
@aufi aufi mentioned this pull request Feb 21, 2024
aufi added a commit that referenced this pull request Feb 21, 2024
* Add version (#154)

* Add version command

Adding tool version to CLI that should return version number and commit
hash. Usage: `kantra version`.

Fixes: https://issues.redhat.com/browse/MTA-2201

Signed-off-by: Marek Aufart <maufart@redhat.com>

* Update build flags

Signed-off-by: Marek Aufart <maufart@redhat.com>

* Update build scripts

Signed-off-by: Marek Aufart <maufart@redhat.com>

* Try fix buildah cmd

Signed-off-by: Marek Aufart <maufart@redhat.com>

* Set buildcommit before

Signed-off-by: Marek Aufart <maufart@redhat.com>

* Update cmd/version.go

Co-authored-by: David Zager <dzager@redhat.com>
Signed-off-by: Marek Aufart <aufi.cz@gmail.com>

---------

Signed-off-by: Marek Aufart <maufart@redhat.com>
Signed-off-by: Marek Aufart <aufi.cz@gmail.com>
Co-authored-by: David Zager <dzager@redhat.com>

* Fix version variables evaluation in github build (#156)

Fix version variables evaluation in build

Using github variables to provide version and commit sha variables for
build.

Follow-up to #154

Signed-off-by: Marek Aufart <maufart@redhat.com>

---------

Signed-off-by: Marek Aufart <maufart@redhat.com>
Signed-off-by: Marek Aufart <aufi.cz@gmail.com>
Co-authored-by: David Zager <dzager@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick/release-0.3 This PR should be cherry-picked to release-0.3 branch.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants