Build extension for handling sem-version in build.zig.zon
- Zig 0.14.0 or latter.
You can use zig fetch
command to install it.
zig fetch --save=set_version git+https://github.com/ritalin/zig-set-version
Then add the following to build.zig
.
pub fn build(b: *std.Build) void {
@import("set_version").VersionSetterStep.addStep(b);
// (snip)
}
- Show current version in this project
- Replace to specified version
- Increlent version
$ zig build version -- show
0.0.0
$ zig build version -- renew 1.2.3
Updated to `1.2.3`
Warning
One of --major
, --minor
and --patch
must be specifed.
$ zig build version -- show
1.2.3
$ zig build version -- inc --patch
Updated to `1.2.4`
$ zig build version -- show
1.2.3
$ zig build version -- inc --minor
Updated to `1.3.0`
$ zig build version -- show
1.2.3
$ zig build version -- inc --major
Updated to `2.0.0`
Tip
--keep-pre
and --keep-build
is optional.
You can use specify it to keep pre
part and build
part.
If you don't only specify --keep-pre
, build
part is also discarded.
$ zig build version -- show
1.2.3-alpha+2048
$ zig build version -- inc --patch --keep-pre --keep-build
Updated to `1.2.4-alpha+2048`
$ zig build version -- show
1.2.3-alpha+2048
$ zig build version -- inc --patch --keep-pre
Updated to `1.2.4-alpha`