Skip to content

Conversation

pd93
Copy link
Member

@pd93 pd93 commented Mar 20, 2025

There have been many issues raised over the content of version.go - The file where we get the Task version used for the --version flag and .TASK_VERSION variable.

Currently, we use a mixture of debug.ReadBuildInfo and -ldflags to set the version variable. The issue with this is that build info is only available when built with a Git checkout and -ldflags requires the maintainer of the release mechanism to maintain the version string/checksum correctly. Thins leads to inconsistencies between various builds.

This PR overhauls the whole thing to make some permanent improvements:

  • When we run the release script, a version.txt file will be generated containing the version number
  • The version.txt file is then embedded into the binary at build time using //go:embed
  • This can still be overridden by -ldflags so we aren't breaking any existing overrides
  • debug.ReadBuildInfo is queried and the commit/dirty status appended to the version if the information is available and is a development build (not tagged)
  • Removed the Task version: prefix so that the output is easier to parse
  • Removed the checksum

Examples:

# Any tagged build or when built outside a Git checkout 3.42.1 # Untagged commit in a Git checkout 3.42.1-2110245 # Uncommitted changes on an untagged commit in a Git checkout 3.42.1-2110245-dirty
@pd93 pd93 marked this pull request as ready for review March 20, 2025 10:01
@pd93 pd93 requested review from andreynering and vmaerten March 26, 2025 21:51
@vmaerten vmaerten requested a review from Copilot April 5, 2025 19:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Files not reviewed (1)
  • internal/version/version.txt: Language not supported
Copy link
Member

@vmaerten vmaerten left a comment

Choose a reason for hiding this comment

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

Nice !
I've added Copilot as reviewer to see if he has something good to say

@pd93 pd93 merged commit 55790be into main Apr 5, 2025
16 of 20 checks passed
@pd93 pd93 deleted the version branch April 5, 2025 22:09
pd93 added a commit that referenced this pull request Apr 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants