Skip to content

fix: inject version number in Makefile and Dockerfile builds#376

Open
cx-ori-bendet wants to merge 2 commits intomasterfrom
fix/version-number-unix
Open

fix: inject version number in Makefile and Dockerfile builds#376
cx-ori-bendet wants to merge 2 commits intomasterfrom
fix/version-number-unix

Conversation

@cx-ori-bendet
Copy link
Copy Markdown

Summary

  • make build-local and docker build were missing the -X linker flag that injects the version at compile time
  • As a result, 2ms --version always reported 0.0.0 on Linux and in Docker containers, while macOS Homebrew installs showed the correct version
  • Fix:
    • Makefile build-local: added -X github.com/checkmarx/2ms/v5/cmd.Version=$(git describe --tags) so local builds automatically pick up the version from the current git tag (falls back to dev if no tag is present)
    • Dockerfile: added ARG VERSION=dev and the same -X flag so docker build --build-arg VERSION=x.y.z . produces a correctly versioned image; defaults to dev when no arg is supplied

Fixes #360

Test plan

  • Run make build-local on a tagged commit and verify ./2ms --version prints the correct tag
  • Run make build-local without a tag and verify it prints dev (or the short commit hash)
  • Run docker build --build-arg VERSION=1.2.3 -t 2ms-test . and verify docker run 2ms-test --version prints 2ms version 1.2.3
  • Run docker build -t 2ms-test . (no arg) and verify it prints 2ms version dev

I submit this contribution under the Apache-2.0 license.

🤖 Generated with Claude Code

Local and Docker builds were missing the -X linker flag that injects the
version at compile time, causing `2ms --version` to always report 0.0.0
on Linux and in containers.

- Makefile build-local: use `git describe --tags` to derive the version
  from the current git tag automatically, falling back to "dev"
- Dockerfile: add a VERSION build arg (default "dev") and pass it via
  -X so `docker build --build-arg VERSION=x.y.z .` produces a correctly
  versioned image

Fixes #360

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@cx-ori-bendet cx-ori-bendet requested a review from a team as a code owner March 2, 2026 16:53
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

kics-logo

KICS version: v1.7.13

Category Results
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 16
Files parsed placeholder 16
Files failed to scan placeholder 0
Total executed queries placeholder 53
Queries failed to execute placeholder 0
Execution time placeholder 1

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 2, 2026

Logo
Checkmarx One – Scan Summary & Details3d3782f4-f73a-49c2-b972-a703c85c53ee

Great job! No new security vulnerabilities introduced in this pull request

@cx-rogerio-dalot cx-rogerio-dalot changed the title fix(build): inject version number in Makefile and Dockerfile builds fix: inject version number in Makefile and Dockerfile builds Mar 26, 2026
@cx-rogerio-dalot
Copy link
Copy Markdown
Contributor

Can we take this opportunity and expand to fix all the go build commands in the release as well? They are all broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(unix): missing version number for unix

2 participants