-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Expose structured Zig version at comptime #6466
Comments
The issues brought up in that discussion are due to changes in the standard library rather than ones in zig syntax (though I don't doubt people are hitting those too). IMO this goes into a discussion of how to depend on libraries; particularly ones with specific versions. |
I don't like that it forces you to choose the next version ahead of time. In many of my nodejs packages, I wouldn't know what version was next, maybe it would be a bug fix release, maybe a minor release, or maybe I would break compatibility. Right after you tag a release, you have no idea what the next one is going to be. I suppose one could do the bump immediately upon making such a change. So if you do a bug fix commit, the version would be x.x.1-pre-foo and then if you do a commit it becomes x.1.0-pre-bar and then if you do a breaking change it becomes 2.0.0-pre-baz. So you would end up with these pseudo version strings of releases that never happened. That seems like it might confuse people. |
@andrewrk i've seen that some projects use 'x.x.999' for development builds |
Agreed. I dislike the friction between semantic versioning and just doing something simple like |
projects like glibc use is 9000 (which has caused trouble with Zig #5082) but that forces a maximum amount of patch versions though that shouldn't introduce any problems but you never know |
It turns out the SemVer repo has a long-standing issue with vigorous debate on this topic: semver/semver#200 There was one proposal I liked, which is changing For the SemVer 2 status quo, I think this comment is the best takeaway:
For pre-1.0 Zig, I think we should just do 0.(n+1).0-dev and call it day. Sticking with SemVer for this proposal means that any version structure and parsing code will remain applicable for the future package manager. |
For what it worth, this may interest you: https://csemver.org/ |
Example version: 0.7.0-dev.2028+ge9434ff8f From a semantic versioning perspective, development builds will now be considered different from a tagged release build and respect ordering. Updates ziglang#6466
I feel compelled to strongly emphasize that nightly/development versioning is to SemVer like a square peg is to a round hole. SamVer communicates a few specific bits of guarantee about the public interface. When you don't have that to say, all SemVer can do is explicitly say that you are not saying it (this is what I strongly encourage considering the idea of doing SemVer for official releases and not-SemVer for things like nightlies or other non-release builds where you don't actually know what the corresponding release version or public interface changes will be. |
Development builds are just pre-releases, which is something that SemVer already supports. |
@jayschwa BNF of SemVer implies that things like build metadata go into metadata which is not part of a version at all. As for pre-release's, its a matter of opinion, and my opinion is that current |
Things that are critical to this proposal:
Constraints of SemVer (what Zig currently uses):
PR #6509 works within these constraints. It twiddles a couple characters in |
Well 0.x.x is not really a semantic versioning, only chronological. Zig's 0.x.x releases are more like 1.0.0-pre.x, since they are trying to be semantic. It could look like this
Or simulate post releases: |
Example version: 0.7.0-dev.2028+ge9434ff8f From a semantic versioning perspective, development builds will now be considered different from a tagged release build and respect ordering. Updates ziglang#6466
This will parse, format, and compare version strings following the SemVer 2 specification. See: https://semver.org Updates ziglang#6466
So I agree that you're doing the right thing assuming those constraints, but my point here is that even if you are using SemVer and want "the ability to compare Zig builds (including untagged builds)" you don't actually have to limit yourself to just the semantics of SemVer. I can't tell if you're making a common intuition mistake here, so I'll just make it explicit: Just because SemVer treats build metadata as irrelevant to SemVer comparison, does not mean SemVer disallows using build metadata for your comparisons in addition to SemVer. At least I see no reason why this should be the interpretation. When I read the SemVer spec, I don't see any implication that additional semantics beyond SemVer are disallowed - only what interpretations/usages are disallowed within SemVer semantics. So what I'm saying is, if Zig uses build metadata for development releases, and provides some function in its standard library which given a Zig version number says "this is a development build" (and sorts accordingly) based on the build metadata tag rather than on the pre-release tag, then to my language/spec "lawyer" intuitions, this does not feel like a violation of SemVer, but rather a composition/layering of SemVer semantics with additional semantics. |
This will parse, format, and compare version strings following the SemVer 2 specification. See: https://semver.org Updates ziglang#6466
This will parse, format, and compare version strings following the SemVer 2 specification. See: https://semver.org Updates ziglang#6466
Example version: 0.7.0-dev.2028+ge9434ff8f From a semantic versioning perspective, development builds will now be considered different from a tagged release build and respect ordering. Updates ziglang#6466
This will parse, format, and compare version strings following the SemVer 2 specification. See: https://semver.org Updates #6466
Example version: 0.8.0-dev.460+g81b343a16 From a semantic versioning perspective, development builds will now be considered distinct from a tagged release. The number of commits added since the last tag is included in the pre-release component. Updates ziglang#6466
Example version: 0.8.0-dev.460+g81b343a16 From a semantic versioning perspective, development builds will now be considered distinct from a tagged release. The number of commits added since the last tag is included in the pre-release component. Updates #6466
Updating the download page is stuck because in all cases `zig version` is outputting 0.8.0 rather than e.g. 0.8.0-dev.716+fbf269cc4. See #6466
`git describe` is used for version string creation, but it had to be reverted in commit 69da6ba because it was broken in CI builds. Azure Pipelines and Drone perform shallow clones by default. This change reconfigures them to do normal clones and fetch tags. This adds an extra 10-20 seconds, which is negligible compared to overall build and test time. Related: ziglang#6466, ziglang#6509, ziglang#7601
git describe is used for version string creation, but it had to be reverted in commit 69da6ba because it was broken in CI builds. Azure Pipelines and Drone perform shallow clones by default. This change reconfigures them to fetch history and tags. It adds tens of seconds, which is negligible compared to overall build and test time. Related: ziglang#6466, ziglang#6509, ziglang#7601
git describe is used for version string creation, but it had to be reverted in commit 69da6ba because it was broken in CI builds. Azure Pipelines and Drone perform shallow clones by default. This change reconfigures them to fetch history and tags. It adds tens of seconds, which is negligible compared to overall build and test time. Related: ziglang#6466, ziglang#6509, ziglang#7601
git describe is used for version string creation, but it had to be reverted in commit 69da6ba because it was broken in CI builds. Azure Pipelines and Drone perform shallow clones by default. This change reconfigures them to fetch history and tags. It adds tens of seconds, which is negligible compared to overall build and test time. Related: #6466, #6509, #7601
This will enable code to perform version checks and make it easier to support multiple versions of Zig. Within the SemVer implementation, an intermediate value needed to be coerced to a slice to workaround a comptime bug. TODO: Add tests. Closes ziglang#6466
Example version: 0.8.0-dev.460+g81b343a16 From a semantic versioning perspective, development builds will now be considered distinct from a tagged release. The number of commits added since the last tag is included in the pre-release component. Updates ziglang#6466
git describe is used for version string creation, but it had to be reverted in commit 69da6ba because it was broken in CI builds. Azure Pipelines and Drone perform shallow clones by default. This change reconfigures them to fetch history and tags. It adds tens of seconds, which is negligible compared to overall build and test time. Related: ziglang#6466, ziglang#6509, ziglang#7601
This will enable code to perform version checks and make it easier to support multiple versions of Zig. Within the SemVer implementation, an intermediate value needed to be coerced to a slice to workaround a comptime bug. Closes ziglang#6466
This will enable code to perform version checks and make it easier to support multiple versions of Zig. Within the SemVer implementation, an intermediate value needed to be coerced to a slice to workaround a comptime bug. Closes ziglang#6466
This will enable code to perform version checks and make it easier to support multiple versions of Zig. Within the SemVer implementation, an intermediate value needed to be coerced to a slice to workaround a comptime bug. Closes ziglang#6466
This will enable code to perform version checks and make it easier to support multiple versions of Zig. Within the SemVer implementation, an intermediate value needed to be coerced to a slice to workaround a comptime bug. Closes ziglang#6466
This will enable code to perform version checks and make it easier to support multiple versions of Zig. Within the SemVer implementation, an intermediate value needed to be coerced to a slice to workaround a comptime bug. Closes ziglang#6466
This will enable code to perform version checks and make it easier to support multiple versions of Zig. Within the SemVer implementation, an intermediate value needed to be coerced to a slice to workaround a comptime bug. Closes #6466
Example version: 0.8.0-dev.460+g81b343a16 From a semantic versioning perspective, development builds will now be considered distinct from a tagged release. The number of commits added since the last tag is included in the pre-release component. Updates ziglang#6466
git describe is used for version string creation, but it had to be reverted in commit 69da6ba because it was broken in CI builds. Azure Pipelines and Drone perform shallow clones by default. This change reconfigures them to fetch history and tags. It adds tens of seconds, which is negligible compared to overall build and test time. Related: ziglang#6466, ziglang#6509, ziglang#7601
This will enable code to perform version checks and make it easier to support multiple versions of Zig. Within the SemVer implementation, an intermediate value needed to be coerced to a slice to workaround a comptime bug. Closes ziglang#6466
In a recent discussion of Zig, some new users complained about broken example code. They encountered these problems because they installed the latest tagged release of Zig (probably from their system package manager) rather than the latest development build. As the Zig ecosystem grows, this is likely to be an ongoing pain point. It will help if authors of published Zig code (outside the Zig project) have an easy way to inspect the Zig version at
comptime
.@hasDecl
is already a great way to perform compile-time "feature detection". However, it may not be enough if one wants to determine whether or not a file with new syntax can be imported, or if it's a version of Zig that shipped with a known bug that needs to be worked around. I propose the following changes:zig version
reports itself as0.6.0+bd89bd6fd
. For semantic versioning compliance, it ought to be something like0.7.0-pre+bd89bd6fd
. A fancier implementation could include commit height from the most recent tag, e.g.0.7.0-pre.123+bd89bd6fd
. Implemented by Comply with semantic versioning pre-release format #6509.std.builtin.Version
type to support pre-release labels according to the Semantic Versioning spec. Implemented by std: Introduce SemanticVersion data structure #6566.std.builtin.version
). Implemented by builtin: Add zig_version #7673.Julia had a similar convention during its wild west pre-1.0 days. I maintained a package during that time, and retaining compatibility with multiple toolchain versions was helpful for end-users.
The text was updated successfully, but these errors were encountered: