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

Implement standardized versioning #44

Merged
merged 4 commits into from
Mar 19, 2024
Merged

Implement standardized versioning #44

merged 4 commits into from
Mar 19, 2024

Conversation

rfratto
Copy link
Member

@rfratto rfratto commented Mar 19, 2024

This PR implements standardized versioning as first proposed in grafana/agent#6100. A new file called VERSION at the root of the repository denotes what semantic version (with a v prefix) to report builds as.

This helps consistently identify running versions of Alloy, even if they come from the main branch.

The VERSION file always reports what version will be released. From the context of the main branch, this is the next major/minor release, and from the context of a release branch, this is the version that the release branch tracks (including the patch version). Due to this, the VERSION file is expected to be updated in the main branch following the creation of a release branch, as that indicates a new release is being worked on in main.

The VERSION file is ignored in two scenarios with descending precedence:

  • When the RELEASE_TAG environment variable is set (e.g., when Drone is publishing a release from a Git tag event)
  • When the current SHA matches a Git tag starting with v (e.g., when locally producing a build against a tag).

In all other cases, the VERSION file is used, and the prerelease is set to devel with the current commit added as a SHA.

rfratto added 4 commits March 19, 2024 12:48
Normalize version strings so they are consistently reported as vVERSION,
where VERSION is a valid semantic version string.

Custom versions that are not valid semvers are returned as is, and empty
strings are returned as v0.0.0.
This commit updates tools/image-tag to always report consistent build
information, with escape hatches to force the reported version:

1. If RELEASE_TAG is set (which happens via Drone pipelines), then the
   script emits the value of the RELEASE_TAG environment variable.

2. If a build is being performed against a Git tag, then the script
   emits the value of that Git tag.

3. Finally, if neither of the above are true, the version from the
   VERSION file is used, followed by the prerelease being set to `devel`
   and the short SHA added as build metadata.

Provided healthy workflwos where RELEASE_TAG and Git tags are always
semantic versions, this guarantees that versions reported by builds are
consistent and can be parsed properly.
@rfratto rfratto merged commit 550fec4 into main Mar 19, 2024
8 of 9 checks passed
@rfratto rfratto deleted the consistent-versioning branch March 19, 2024 17:42
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 19, 2024
@rfratto rfratto added the backport-to-agent:no PR should NOT be backported to the agent repo. label Apr 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport-to-agent:no PR should NOT be backported to the agent repo. frozen-due-to-age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant